diff --git a/scr/.eslintrc.js b/scr/.eslintrc.js new file mode 100644 index 0000000..115cc02 --- /dev/null +++ b/scr/.eslintrc.js @@ -0,0 +1,31 @@ +/* + * Eslint config file + * Documentation: https://eslint.org/docs/user-guide/configuring/ + * Install the Eslint extension before using this feature. + */ +module.exports = { + env: { + es6: true, + browser: true, + node: true, + }, + ecmaFeatures: { + modules: true, + }, + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + }, + globals: { + wx: true, + App: true, + Page: true, + getCurrentPages: true, + getApp: true, + Component: true, + requirePlugin: true, + requireMiniProgram: true, + }, + // extends: 'eslint:recommended', + rules: {}, +} diff --git a/scr/app.js b/scr/app.js new file mode 100644 index 0000000..1ed57c4 --- /dev/null +++ b/scr/app.js @@ -0,0 +1,19 @@ +// app.js +App({ + onLaunch() { + // 展示本地存储能力 + const logs = wx.getStorageSync('logs') || [] + logs.unshift(Date.now()) + wx.setStorageSync('logs', logs) + + // 登录 + wx.login({ + success: res => { + // 发送 res.code 到后台换取 openId, sessionKey, unionId + } + }) + }, + globalData: { + userInfo: null + } +}) diff --git a/scr/app.json b/scr/app.json new file mode 100644 index 0000000..993dba1 --- /dev/null +++ b/scr/app.json @@ -0,0 +1,19 @@ +{ + "pages":[ + "pages/index/index", + "pages/logs/logs" + ], + "window":{ + "backgroundTextStyle":"light", + "navigationBarBackgroundColor": "#fff", + "navigationBarTitleText": "Weixin", + "navigationBarTextStyle":"black" + }, + "style": "v2", + "sitemapLocation": "sitemap.json", + "permission": { + "scope.userLocation":{ + "desc": "点击确认" + } + } +} diff --git a/scr/app.wxss b/scr/app.wxss new file mode 100644 index 0000000..06c6fc9 --- /dev/null +++ b/scr/app.wxss @@ -0,0 +1,10 @@ +/**app.wxss**/ +.container { + height: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-between; + padding: 200rpx 0; + box-sizing: border-box; +} diff --git a/scr/pages/index/index.js b/scr/pages/index/index.js new file mode 100644 index 0000000..3ae9025 --- /dev/null +++ b/scr/pages/index/index.js @@ -0,0 +1,140 @@ +// miniprogram/pages/gao_de/gao_de.js +var amapFile = require('../../libs/amap-wx.js');//如:..­/..­/libs/amap-wx.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + markers: [{ + iconPath: "../../img/mapicon_navi_s.png", + id: 0, + latitude: 39.989643, + longitude: 116.481028, + width: 23, + height: 33 + },{ + iconPath: "../../img/mapicon_navi_e.png", + id: 0, + latitude: 39.90816, + longitude: 116.434446, + width: 24, + height: 34 + }], + distance: '', + cost: '', + polyline: [] + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var that = this; + var myAmapFun = new amapFile.AMapWX({key: b090d6cfb5aa7ca17535c1625777307a}); + myAmapFun.getPoiAround({ + success: function(data){ + console.log(data) + //成功回调 + }, + fail: function(info){ + //失败回调 + console.log(info) + } + }) + //获取自己所在地址的定位 + myAmapFun.getRegeo({ + success: function(data){ + //成功回调 + console.log('---------') + + console.log(data) + }, + fail: function(info){ + //失败回调 + console.log(info) + } + }) + + //获取定位地点天气内容 + myAmapFun.getWeather({ + success: function(data){ + console.log(data,'123') + //成功回调 + }, + fail: function(info){ + //失败回调 + console.log(info) + } + }) + + //路线 + myAmapFun.getDrivingRoute({ + origin: '116.481028,39.989643', + destination: '116.434446,39.90816', + success: function(data){ + var points = []; + if(data.paths && data.paths[0] && data.paths[0].steps){ + var steps = data.paths[0].steps; + for(var i = 0; i < steps.length; i++){ + var poLen = steps[i].polyline.split(';'); + for(var j = 0;j < poLen.length; j++){ + points.push({ + longitude: parseFloat(poLen[j].split(',')[0]), + latitude: parseFloat(poLen[j].split(',')[1]) + }) + } + } + } + that.setData({ + polyline: [{ + points: points, + color: "#0091ff", + width: 6 + }] + }); + if(data.paths[0] && data.paths[0].distance){ + that.setData({ + distance: data.paths[0].distance + '米' + }); + } + if(data.taxi_cost){ + that.setData({ + cost: '打车约' + parseInt(data.taxi_cost) + '元' + }); + } + + }, + fail: function(info){ + + } + }) + + }, + goDetail: function(){ + wx.navigateTo({ + url: '../navigation_car_detail/navigation' + }) + }, + goToCar: function (e) { + wx.redirectTo({ + url: '../navigation_car/navigation' + }) + }, + goToBus: function (e) { + wx.redirectTo({ + url: '../navigation_bus/navigation' + }) + }, + goToRide: function (e) { + wx.redirectTo({ + url: '../navigation_ride/navigation' + }) + }, + goToWalk: function (e) { + wx.redirectTo({ + url: '../navigation_walk/navigation' + }) + }, + +}) diff --git a/scr/pages/index/index.wxml b/scr/pages/index/index.wxml new file mode 100644 index 0000000..a4ee8a4 --- /dev/null +++ b/scr/pages/index/index.wxml @@ -0,0 +1,15 @@ + + 驾车 + 步行 + 公交 + 骑行 + + + + + + + {{distance}} + {{cost}} + 详情 + diff --git a/scr/pages/index/index.wxss b/scr/pages/index/index.wxss new file mode 100644 index 0000000..0c4cd5a --- /dev/null +++ b/scr/pages/index/index.wxss @@ -0,0 +1,48 @@ +.flex-style{ + display: -webkit-box; + display: -webkit-flex; + display: flex; +} +.flex-item{ + height: 35px; + line-height: 35px; + text-align: center; + -webkit-box-flex: 1; + -webkit-flex: 1; + flex: 1 +} +.flex-item.active{ + color:#0091ff; +} +.map_box{ + position:absolute; + top: 35px; + bottom: 90px; + left: 0px; + right: 0px; +} +#navi_map{ + width: 100%; + height: 100%; +} +.text_box{ + position:absolute; + height: 90px; + bottom: 0px; + left: 0px; + right: 0px; +} +.text_box .text{ + margin: 15px; +} +.detail_button{ + position:absolute; + bottom: 30px; + right: 10px; + padding: 3px 5px; + color: #fff; + background: #0091ff; + width:50px; + text-align:center; + border-radius:5px; +} diff --git a/scr/pages/logs/logs.js b/scr/pages/logs/logs.js new file mode 100644 index 0000000..85f6aac --- /dev/null +++ b/scr/pages/logs/logs.js @@ -0,0 +1,18 @@ +// logs.js +const util = require('../../utils/util.js') + +Page({ + data: { + logs: [] + }, + onLoad() { + this.setData({ + logs: (wx.getStorageSync('logs') || []).map(log => { + return { + date: util.formatTime(new Date(log)), + timeStamp: log + } + }) + }) + } +}) diff --git a/scr/pages/logs/logs.json b/scr/pages/logs/logs.json new file mode 100644 index 0000000..3ee76c1 --- /dev/null +++ b/scr/pages/logs/logs.json @@ -0,0 +1,4 @@ +{ + "navigationBarTitleText": "查看启动日志", + "usingComponents": {} +} \ No newline at end of file diff --git a/scr/pages/logs/logs.wxml b/scr/pages/logs/logs.wxml new file mode 100644 index 0000000..0b6b645 --- /dev/null +++ b/scr/pages/logs/logs.wxml @@ -0,0 +1,6 @@ + + + + {{index + 1}}. {{log.date}} + + diff --git a/scr/project.config.json b/scr/project.config.json new file mode 100644 index 0000000..5c7f847 --- /dev/null +++ b/scr/project.config.json @@ -0,0 +1,51 @@ +{ + "description": "项目配置文件", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "bundle": false, + "userConfirmedBundleSwitch": false, + "urlCheck": true, + "scopeDataCheck": false, + "coverView": true, + "es6": true, + "postcss": true, + "compileHotReLoad": false, + "lazyloadPlaceholderEnable": false, + "preloadBackgroundData": false, + "minified": true, + "autoAudits": false, + "newFeature": false, + "uglifyFileName": false, + "uploadWithSourceMap": true, + "useIsolateContext": true, + "nodeModules": false, + "enhance": true, + "useMultiFrameRuntime": true, + "useApiHook": true, + "useApiHostProcess": true, + "showShadowRootInWxmlPanel": true, + "packNpmManually": false, + "enableEngineNative": false, + "packNpmRelationList": [], + "minifyWXSS": true, + "showES6CompileOption": false, + "minifyWXML": true, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "compileType": "miniprogram", + "libVersion": "2.19.4", + "appid": "wx5871b0202e96c9d3", + "projectname": "miniprogram-92", + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 2 + } +} \ No newline at end of file diff --git a/scr/project.private.config.json b/scr/project.private.config.json new file mode 100644 index 0000000..5bc1aaf --- /dev/null +++ b/scr/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "scr", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/scr/sitemap.json b/scr/sitemap.json new file mode 100644 index 0000000..ca02add --- /dev/null +++ b/scr/sitemap.json @@ -0,0 +1,7 @@ +{ + "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", + "rules": [{ + "action": "allow", + "page": "*" + }] +} \ No newline at end of file diff --git a/scr/utils/util.js b/scr/utils/util.js new file mode 100644 index 0000000..764bc2c --- /dev/null +++ b/scr/utils/util.js @@ -0,0 +1,19 @@ +const formatTime = date => { + const year = date.getFullYear() + const month = date.getMonth() + 1 + const day = date.getDate() + const hour = date.getHours() + const minute = date.getMinutes() + const second = date.getSeconds() + + return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}` +} + +const formatNumber = n => { + n = n.toString() + return n[1] ? n : `0${n}` +} + +module.exports = { + formatTime +}