Showing
25 changed files
with
918 additions
and
97 deletions
| @@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
| 12 | "pages/customer/list", | 12 | "pages/customer/list", |
| 13 | "pages/customer/remind", | 13 | "pages/customer/remind", |
| 14 | "pages/me/index", | 14 | "pages/me/index", |
| 15 | - "pages/reservr/index", | 15 | + "pages/reserve/index", |
| 16 | "pages/me/setting", | 16 | "pages/me/setting", |
| 17 | "pages/me/list", | 17 | "pages/me/list", |
| 18 | "pages/book/b_addnew", | 18 | "pages/book/b_addnew", |
| @@ -36,10 +36,10 @@ | @@ -36,10 +36,10 @@ | ||
| 36 | "borderStyle": "", | 36 | "borderStyle": "", |
| 37 | "list": [ | 37 | "list": [ |
| 38 | { | 38 | { |
| 39 | - "pagePath": "pages/reservr/index", | 39 | + "pagePath": "pages/reserve/index", |
| 40 | "text": "订座", | 40 | "text": "订座", |
| 41 | - "iconPath": "pages/image/tabicon-reservr.png", | ||
| 42 | - "selectedIconPath": "pages/image/tabicon-reservr-checked.png" | 41 | + "iconPath": "pages/image/tabicon-reserve.png", |
| 42 | + "selectedIconPath": "pages/image/tabicon-reserve-checked.png" | ||
| 43 | }, | 43 | }, |
| 44 | { | 44 | { |
| 45 | "pagePath": "pages/customer/list", | 45 | "pagePath": "pages/customer/list", |
components/reserve/seller-box/seller-box.js
0 → 100644
| 1 | +// components/reserve/seller-box/seller-box.js | ||
| 2 | +Component({ | ||
| 3 | + /** | ||
| 4 | + * 组件的属性列表 | ||
| 5 | + */ | ||
| 6 | + properties: { | ||
| 7 | + seller:{ | ||
| 8 | + type:Object, | ||
| 9 | + value:{} | ||
| 10 | + } | ||
| 11 | + }, | ||
| 12 | + | ||
| 13 | + /** | ||
| 14 | + * 组件的初始数据 | ||
| 15 | + */ | ||
| 16 | + data: { | ||
| 17 | + hasShow:false, | ||
| 18 | + }, | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * 组件的方法列表 | ||
| 22 | + */ | ||
| 23 | + methods: { | ||
| 24 | + show(){ | ||
| 25 | + this.setData({ | ||
| 26 | + hasShow:true, | ||
| 27 | + }) | ||
| 28 | + }, | ||
| 29 | + hide(){ | ||
| 30 | + this.setData({ | ||
| 31 | + hasShow:false, | ||
| 32 | + }) | ||
| 33 | + this.triggerEvent('event',{type:'hide'}); | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | +}) |
| 1 | +<!--components/showModal/showModal.wxml--> | ||
| 2 | +<cover-view class="mask flex-vr" hidden="{{!hasShow}}" bindtap="hide"> | ||
| 3 | + <cover-view class="showModal"> | ||
| 4 | + <cover-view class="header"> | ||
| 5 | + {{seller.seller_name}} | ||
| 6 | + </cover-view> | ||
| 7 | + <cover-view class="body">{{opt.body}}</cover-view> | ||
| 8 | + <cover-view class="footer flex-cc"> | ||
| 9 | + <button class="button-none cancel" plain wx:if="{{opt.cancelText}}" | ||
| 10 | + bindtap="tapButton" data-type="cancel" | ||
| 11 | + style="color:{{opt.cancelColor}};">{{opt.cancelText}}</button> | ||
| 12 | + <button class="button-none" plain | ||
| 13 | + bindtap="tapButton" data-type="confirm" | ||
| 14 | + style="color:{{opt.confirmColor}};">{{opt.confirmText}}</button> | ||
| 15 | + </cover-view> | ||
| 16 | + </cover-view> | ||
| 17 | +</cover-view> |
| 1 | +/* components/reserve/seller-box/seller-box.wxss */ | ||
| 2 | +@import "../../../app.wxss"; | ||
| 3 | +.mask{ | ||
| 4 | + position: fixed; | ||
| 5 | + width: 100%; | ||
| 6 | + height: 100%; | ||
| 7 | + background-color: rgba(0,0,0,.5); | ||
| 8 | + top:0; | ||
| 9 | + left: 0; | ||
| 10 | +} | ||
| 11 | + | ||
| 12 | +.showModal{ | ||
| 13 | + width: 90%; | ||
| 14 | + background-color: #fff; | ||
| 15 | + padding: 20rpx 5% 0 5%; | ||
| 16 | +} | ||
| 17 | +.showModal .header{ | ||
| 18 | + font-size: 40rpx; | ||
| 19 | + line-height: 120rpx; | ||
| 20 | + height: 120rpx; | ||
| 21 | +} | ||
| 22 | +.showModal .body{ | ||
| 23 | + font-size: 30rpx; | ||
| 24 | + margin-bottom: 30rpx; | ||
| 25 | +} | ||
| 26 | +.footer{ | ||
| 27 | + border-top: 2rpx solid #ccc; | ||
| 28 | + background-color: #fff; | ||
| 29 | + width: 90%; | ||
| 30 | +} | ||
| 31 | +.footer .button-none{ | ||
| 32 | + line-height: 120rpx; | ||
| 33 | + height: 120rpx; | ||
| 34 | + border-width: 0; | ||
| 35 | +} | ||
| 36 | +.footer .button-none.cancel{ | ||
| 37 | + border-right: 2rpx solid #ccc !important; | ||
| 38 | +} |
components/showModal/showModal.js
0 → 100644
| 1 | +// components/showModal/showModal.js | ||
| 2 | +import util from '../../utils/util' | ||
| 3 | +const properties={ | ||
| 4 | + cancelText:{type:String,value:''}, | ||
| 5 | + cancelColor:{type:String,value:'#000'}, | ||
| 6 | + confirmText:{type:String,value:'确认'}, | ||
| 7 | + confirmColor:{type:String,value:'#393'}, | ||
| 8 | + header:{type:String,value:'确认信息'}, | ||
| 9 | + body:{type:String,value:'确认信息'}, | ||
| 10 | +}; | ||
| 11 | +Component({ | ||
| 12 | + /** | ||
| 13 | + * 组件的属性列表 | ||
| 14 | + */ | ||
| 15 | + properties: properties, | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 组件的初始数据 | ||
| 19 | + */ | ||
| 20 | + data: { | ||
| 21 | + hasShow:false, | ||
| 22 | + }, | ||
| 23 | + attached(){ | ||
| 24 | + let opt={}; | ||
| 25 | + Object.keys(properties).forEach((k)=>{ | ||
| 26 | + opt[k]=this.data[k] | ||
| 27 | + }) | ||
| 28 | + this.setData({ | ||
| 29 | + opt:opt | ||
| 30 | + }) | ||
| 31 | + }, | ||
| 32 | + /** | ||
| 33 | + * 组件的方法列表 | ||
| 34 | + */ | ||
| 35 | + methods: { | ||
| 36 | + options(obj){ | ||
| 37 | + let opt=this.data.opt; | ||
| 38 | + this.setData({ | ||
| 39 | + opt:{ | ||
| 40 | + ...opt, | ||
| 41 | + ...obj | ||
| 42 | + } | ||
| 43 | + }) | ||
| 44 | + return this; | ||
| 45 | + }, | ||
| 46 | + show(){ | ||
| 47 | + console.log(this.data.opt) | ||
| 48 | + this.setData({ | ||
| 49 | + hasShow:true, | ||
| 50 | + }) | ||
| 51 | + }, | ||
| 52 | + tapButton(e){ | ||
| 53 | + this.triggerEvent('showModal',{type:util.attr(e,'type')}) | ||
| 54 | + this.hide(); | ||
| 55 | + }, | ||
| 56 | + hide(){ | ||
| 57 | + this.setData({ | ||
| 58 | + hasShow:false, | ||
| 59 | + }) | ||
| 60 | + } | ||
| 61 | + } | ||
| 62 | +}) |
components/showModal/showModal.json
0 → 100644
components/showModal/showModal.wxml
0 → 100644
| 1 | +<!--components/showModal/showModal.wxml--> | ||
| 2 | +<cover-view class="mask flex-vc" hidden="{{!hasShow}}"> | ||
| 3 | + <cover-view class="showModal"> | ||
| 4 | + <cover-view class="header"> | ||
| 5 | + {{opt.header}} | ||
| 6 | + </cover-view> | ||
| 7 | + <cover-view class="body">{{opt.body}}</cover-view> | ||
| 8 | + </cover-view> | ||
| 9 | + <cover-view class="footer flex-cc"> | ||
| 10 | + <button class="button-none cancel" plain wx:if="{{opt.cancelText}}" | ||
| 11 | + bindtap="tapButton" data-type="cancel" | ||
| 12 | + style="color:{{opt.cancelColor}};">{{opt.cancelText}}</button> | ||
| 13 | + <button class="button-none" plain | ||
| 14 | + bindtap="tapButton" data-type="confirm" | ||
| 15 | + style="color:{{opt.confirmColor}};">{{opt.confirmText}}</button> | ||
| 16 | + </cover-view> | ||
| 17 | +</cover-view> |
components/showModal/showModal.wxss
0 → 100644
| 1 | +/* components/showModal/showModal.wxss */ | ||
| 2 | +@import "../../app.wxss"; | ||
| 3 | +.mask{ | ||
| 4 | + position: fixed; | ||
| 5 | + width: 100%; | ||
| 6 | + height: 100%; | ||
| 7 | + background-color: rgba(0,0,0,.5); | ||
| 8 | + top:0; | ||
| 9 | + left: 0; | ||
| 10 | +} | ||
| 11 | +.showModal{ | ||
| 12 | + width: 80%; | ||
| 13 | + background-color: #fff; | ||
| 14 | + padding: 20rpx 5% 0 5%; | ||
| 15 | +} | ||
| 16 | +.showModal .header{ | ||
| 17 | + font-size: 40rpx; | ||
| 18 | + line-height: 120rpx; | ||
| 19 | + height: 120rpx; | ||
| 20 | +} | ||
| 21 | +.showModal .body{ | ||
| 22 | + font-size: 30rpx; | ||
| 23 | + margin-bottom: 30rpx; | ||
| 24 | +} | ||
| 25 | +.footer{ | ||
| 26 | + border-top: 2rpx solid #ccc; | ||
| 27 | + background-color: #fff; | ||
| 28 | + width: 90%; | ||
| 29 | +} | ||
| 30 | +.footer .button-none{ | ||
| 31 | + line-height: 120rpx; | ||
| 32 | + height: 120rpx; | ||
| 33 | + border-width: 0; | ||
| 34 | +} | ||
| 35 | +.footer .button-none.cancel{ | ||
| 36 | + border-right: 2rpx solid #ccc !important; | ||
| 37 | +} |
pages/image/d.d.png
0 → 100644
698 Bytes
pages/image/ding.d.png
0 → 100644
3.57 KB
pages/image/ding.png
0 → 100644
2.26 KB
pages/image/pos.png
0 → 100644
1.34 KB
pages/reserve/index.js
0 → 100644
| 1 | +// pages/reservr/index.js | ||
| 2 | +import util from '../../utils/util'; | ||
| 3 | +import App from '../../utils/api'; | ||
| 4 | +const {regeneratorRuntime} = global | ||
| 5 | +import QQMapWX from '../../utils/qqmap-wx-jssdk' | ||
| 6 | +Page({ | ||
| 7 | + | ||
| 8 | + /** | ||
| 9 | + * 页面的初始数据 | ||
| 10 | + */ | ||
| 11 | + data: { | ||
| 12 | + map:{ | ||
| 13 | + latitude: 23.099994, | ||
| 14 | + longitude: 113.324520, | ||
| 15 | + scale:18, | ||
| 16 | + height:300, | ||
| 17 | + }, | ||
| 18 | + markers: [{ | ||
| 19 | + iconPath: "/pages/image/ding.d.png", | ||
| 20 | + id: 0, | ||
| 21 | + latitude: 23.099994, | ||
| 22 | + longitude: 113.324520, | ||
| 23 | + width: 50, | ||
| 24 | + height: 50 | ||
| 25 | + }], | ||
| 26 | + seller:{}, | ||
| 27 | + }, | ||
| 28 | + qqmapsdk:null, | ||
| 29 | + /** | ||
| 30 | + * 生命周期函数--监听页面加载 | ||
| 31 | + */ | ||
| 32 | + onLoad: function (options) { | ||
| 33 | + this.qqmapsdk=new QQMapWX({ | ||
| 34 | + key: 'SDEBZ-I74W4-QLGUX-XXYXU-HIR23-3QFBJ' | ||
| 35 | + }); | ||
| 36 | + }, | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 生命周期函数--监听页面初次渲染完成 | ||
| 40 | + */ | ||
| 41 | + onReady: function () { | ||
| 42 | + | ||
| 43 | + }, | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * 生命周期函数--监听页面显示 | ||
| 47 | + */ | ||
| 48 | + onShow: function () { | ||
| 49 | + this.getPos(); | ||
| 50 | + }, | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 生命周期函数--监听页面隐藏 | ||
| 54 | + */ | ||
| 55 | + onHide: function () { | ||
| 56 | + | ||
| 57 | + }, | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * 生命周期函数--监听页面卸载 | ||
| 61 | + */ | ||
| 62 | + onUnload: function () { | ||
| 63 | + | ||
| 64 | + }, | ||
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * 页面相关事件处理函数--监听用户下拉动作 | ||
| 68 | + */ | ||
| 69 | + onPullDownRefresh: function () { | ||
| 70 | + | ||
| 71 | + }, | ||
| 72 | + | ||
| 73 | + /** | ||
| 74 | + * 页面上拉触底事件的处理函数 | ||
| 75 | + */ | ||
| 76 | + onReachBottom: function () { | ||
| 77 | + | ||
| 78 | + }, | ||
| 79 | + | ||
| 80 | + /** | ||
| 81 | + * 用户点击右上角分享 | ||
| 82 | + */ | ||
| 83 | + onShareAppMessage: function () { | ||
| 84 | + | ||
| 85 | + }, | ||
| 86 | + getPos(){ | ||
| 87 | + this._getPos().then(res=>{ | ||
| 88 | + console.log('wx.getLocation.then',res); | ||
| 89 | + let map=this.data.map; | ||
| 90 | + map.latitude=res.latitude; | ||
| 91 | + map.longitude=res.longitude; | ||
| 92 | + map.height=getApp().system.windowHeight | ||
| 93 | + this.setData({ | ||
| 94 | + map:map, | ||
| 95 | + }) | ||
| 96 | + this.getMarkers(); | ||
| 97 | + }).catch(()=>{ | ||
| 98 | + this.selectComponent('#showModal').options({ | ||
| 99 | + header:'定位失败', | ||
| 100 | + body:'需要地理位置授权' | ||
| 101 | + }).show(); | ||
| 102 | + }) | ||
| 103 | + }, | ||
| 104 | + _getPos(){ | ||
| 105 | + return new Promise((success,fail)=>{ | ||
| 106 | + wx.getLocation({ | ||
| 107 | + type:'gcj02', | ||
| 108 | + success:(res)=>{ | ||
| 109 | + success(res) | ||
| 110 | + }, | ||
| 111 | + fail:(res)=>{ | ||
| 112 | + fail(res) | ||
| 113 | + }, | ||
| 114 | + complete:(res)=>{ | ||
| 115 | + console.log('wx.getLocation',res) | ||
| 116 | + } | ||
| 117 | + }); | ||
| 118 | + }) | ||
| 119 | + }, | ||
| 120 | + showModal(e){ | ||
| 121 | + wx.openSetting() | ||
| 122 | + }, | ||
| 123 | + regionchange(e){ | ||
| 124 | + //console.log(e) | ||
| 125 | + }, | ||
| 126 | + mapUpdated(e){ | ||
| 127 | + //console.log('mapUpdated',e) | ||
| 128 | + }, | ||
| 129 | + markertap(e){ | ||
| 130 | + console.log(e) | ||
| 131 | + let seller_id=e.markerId; | ||
| 132 | + this.setData({ | ||
| 133 | + seller:{ | ||
| 134 | + id:seller_id, | ||
| 135 | + seller_name:'商户名名称'+seller_id, | ||
| 136 | + seller_addr:'商户地址'+seller_id, | ||
| 137 | + seller_phone:'商户电话'+seller_id, | ||
| 138 | + } | ||
| 139 | + }) | ||
| 140 | + this.selectComponent('#seller-box').show(); | ||
| 141 | + wx.hideTabBar(); | ||
| 142 | + }, | ||
| 143 | + getMarkers(){ | ||
| 144 | + let map=this.data.map; | ||
| 145 | + let markers=[]; | ||
| 146 | + for(var i=1;i<50;i++){ | ||
| 147 | + markers.push({ | ||
| 148 | + id: i, | ||
| 149 | + iconPath: "/pages/image/ding.png", | ||
| 150 | + latitude: parseFloat(map.latitude) + Math.random()*(parseInt(Math.random()*10)%2==0?-1:1)/500, | ||
| 151 | + longitude: parseFloat(map.longitude) +Math.random()*(parseInt(Math.random()*10)%2==0?-1:1)/500, | ||
| 152 | + width: 24, | ||
| 153 | + height: 30, | ||
| 154 | + title:'店铺名称t'+i, | ||
| 155 | + // callout:{ | ||
| 156 | + // content:'店铺名称cc'+i, | ||
| 157 | + // color:'#f00', | ||
| 158 | + // fontSize:30, | ||
| 159 | + // borderRadius:5, | ||
| 160 | + // borderWidth:1, | ||
| 161 | + // borderColor:'#f00', | ||
| 162 | + // bgColor:'#fff', | ||
| 163 | + // padding:5, | ||
| 164 | + // display:'BYCLICK',//BYCLICK,ALWAYS | ||
| 165 | + // textAlign:'center', | ||
| 166 | + // }, | ||
| 167 | + label:{ | ||
| 168 | + content:'店铺名称lc'+i, | ||
| 169 | + color:'#353535', | ||
| 170 | + fontSize:13, | ||
| 171 | + anchorX:-50, | ||
| 172 | + anchorY:1, | ||
| 173 | + borderWidth:1, | ||
| 174 | + borderColor:'#B4B0B0', | ||
| 175 | + borderRadius:20, | ||
| 176 | + bgColor:'#fff', | ||
| 177 | + padding:5, | ||
| 178 | + textAlign:'center', | ||
| 179 | + }, | ||
| 180 | + }) | ||
| 181 | + } | ||
| 182 | + this.setData({ | ||
| 183 | + markers:markers, | ||
| 184 | + }) | ||
| 185 | + }, | ||
| 186 | + sellerBoxEvent(e){ | ||
| 187 | + wx.showTabBar(); | ||
| 188 | + } | ||
| 189 | + | ||
| 190 | +}) |
| @@ -4,6 +4,8 @@ | @@ -4,6 +4,8 @@ | ||
| 4 | "navigationBarTitleText":"订个座儿", | 4 | "navigationBarTitleText":"订个座儿", |
| 5 | "usingComponents": { | 5 | "usingComponents": { |
| 6 | "formids":"/components/formids/formids", | 6 | "formids":"/components/formids/formids", |
| 7 | - "nav":"/components/nav/nav" | 7 | + "nav":"/components/nav/nav", |
| 8 | + "showModal":"/components/showModal/showModal", | ||
| 9 | + "seller-box":"/components/reserve/seller-box/seller-box" | ||
| 8 | } | 10 | } |
| 9 | } | 11 | } |
pages/reserve/index.wxml
0 → 100644
| 1 | +<!--pages/reservr/index.wxml--> | ||
| 2 | +<view class="page"> | ||
| 3 | + <view class="flex-vc map"> | ||
| 4 | + <map id="map" longitude="{{map.longitude}}" latitude="{{map.latitude}}" scale="{{map.scale}}" | ||
| 5 | + markers="{{markers}}" | ||
| 6 | + bindmarkertap="markertap" | ||
| 7 | + bindregionchange="regionchange" | ||
| 8 | + bindupdated="mapUpdated" | ||
| 9 | + show-location | ||
| 10 | + enable-3D | ||
| 11 | + enable-zoom | ||
| 12 | + enable-scroll | ||
| 13 | + enable-rotate | ||
| 14 | + show-compass | ||
| 15 | + style="width: 100%; height: {{map.height}}px;"></map> | ||
| 16 | + </view> | ||
| 17 | +</view> | ||
| 18 | +<showModal id="showModal" confirmText="去授权" bindshowModal="showModal"></showModal> | ||
| 19 | +<seller-box id="seller-box" seller="{{seller}}" bindevent="sellerBoxEvent"></seller-box> | ||
| 20 | + |
pages/reserve/index.wxss
0 → 100644
pages/reservr/index.js
deleted
100644 → 0
| 1 | -// pages/reservr/index.js | ||
| 2 | -Page({ | ||
| 3 | - | ||
| 4 | - /** | ||
| 5 | - * 页面的初始数据 | ||
| 6 | - */ | ||
| 7 | - data: { | ||
| 8 | - | ||
| 9 | - }, | ||
| 10 | - | ||
| 11 | - /** | ||
| 12 | - * 生命周期函数--监听页面加载 | ||
| 13 | - */ | ||
| 14 | - onLoad: function (options) { | ||
| 15 | - | ||
| 16 | - }, | ||
| 17 | - | ||
| 18 | - /** | ||
| 19 | - * 生命周期函数--监听页面初次渲染完成 | ||
| 20 | - */ | ||
| 21 | - onReady: function () { | ||
| 22 | - | ||
| 23 | - }, | ||
| 24 | - | ||
| 25 | - /** | ||
| 26 | - * 生命周期函数--监听页面显示 | ||
| 27 | - */ | ||
| 28 | - onShow: function () { | ||
| 29 | - | ||
| 30 | - }, | ||
| 31 | - | ||
| 32 | - /** | ||
| 33 | - * 生命周期函数--监听页面隐藏 | ||
| 34 | - */ | ||
| 35 | - onHide: function () { | ||
| 36 | - | ||
| 37 | - }, | ||
| 38 | - | ||
| 39 | - /** | ||
| 40 | - * 生命周期函数--监听页面卸载 | ||
| 41 | - */ | ||
| 42 | - onUnload: function () { | ||
| 43 | - | ||
| 44 | - }, | ||
| 45 | - | ||
| 46 | - /** | ||
| 47 | - * 页面相关事件处理函数--监听用户下拉动作 | ||
| 48 | - */ | ||
| 49 | - onPullDownRefresh: function () { | ||
| 50 | - | ||
| 51 | - }, | ||
| 52 | - | ||
| 53 | - /** | ||
| 54 | - * 页面上拉触底事件的处理函数 | ||
| 55 | - */ | ||
| 56 | - onReachBottom: function () { | ||
| 57 | - | ||
| 58 | - }, | ||
| 59 | - | ||
| 60 | - /** | ||
| 61 | - * 用户点击右上角分享 | ||
| 62 | - */ | ||
| 63 | - onShareAppMessage: function () { | ||
| 64 | - | ||
| 65 | - } | ||
| 66 | -}) |
pages/reservr/index.wxml
deleted
100644 → 0
pages/reservr/index.wxss
deleted
100644 → 0
| 1 | { | 1 | { |
| 2 | "description": "项目配置文件。", | 2 | "description": "项目配置文件。", |
| 3 | "setting": { | 3 | "setting": { |
| 4 | - "urlCheck": true, | 4 | + "urlCheck": false, |
| 5 | "es6": true, | 5 | "es6": true, |
| 6 | "postcss": true, | 6 | "postcss": true, |
| 7 | "minified": true, | 7 | "minified": true, |
| @@ -30,7 +30,7 @@ | @@ -30,7 +30,7 @@ | ||
| 30 | "list": [] | 30 | "list": [] |
| 31 | }, | 31 | }, |
| 32 | "miniprogram": { | 32 | "miniprogram": { |
| 33 | - "current": 6, | 33 | + "current": 18, |
| 34 | "list": [ | 34 | "list": [ |
| 35 | { | 35 | { |
| 36 | "id": 0, | 36 | "id": 0, |
| @@ -169,6 +169,18 @@ | @@ -169,6 +169,18 @@ | ||
| 169 | "pathName": "pages/book/b_addnew", | 169 | "pathName": "pages/book/b_addnew", |
| 170 | "query": "id=51", | 170 | "query": "id=51", |
| 171 | "scene": "1001" | 171 | "scene": "1001" |
| 172 | + }, | ||
| 173 | + { | ||
| 174 | + "id": -1, | ||
| 175 | + "name": "pages/reserve/index 在线订座", | ||
| 176 | + "pathName": "pages/reserve/index", | ||
| 177 | + "query": "", | ||
| 178 | + "scene": "1044", | ||
| 179 | + "shareInfo": { | ||
| 180 | + "groupName": "测试模拟群1", | ||
| 181 | + "shareName": "8DEbIRpK4pa9mH_QY2vU4ZUKYPuI97WoQ4BQoFej-Q8@cr4dev", | ||
| 182 | + "shareKey": "PZhnqMlY2TnRuHhATyGeSamVmBQUDXXr_WtjRSddeeFK17UAiOP-HNOdhxiEN7PFub5S1DjAeUl0IXOdW-VDqg~~" | ||
| 183 | + } | ||
| 172 | } | 184 | } |
| 173 | ] | 185 | ] |
| 174 | } | 186 | } |
utils/qqmap-wx-jssdk.js
0 → 100644
| 1 | +/** | ||
| 2 | + * 微信小程序JavaScriptSDK | ||
| 3 | + * | ||
| 4 | + * @version 1.0 | ||
| 5 | + * @date 2017-01-10 | ||
| 6 | + * @author jaysonzhou@tencent.com | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | +var ERROR_CONF = { | ||
| 10 | + KEY_ERR: 311, | ||
| 11 | + KEY_ERR_MSG: 'key格式错误', | ||
| 12 | + PARAM_ERR: 310, | ||
| 13 | + PARAM_ERR_MSG: '请求参数信息有误', | ||
| 14 | + SYSTEM_ERR: 600, | ||
| 15 | + SYSTEM_ERR_MSG: '系统错误', | ||
| 16 | + WX_ERR_CODE: 1000, | ||
| 17 | + WX_OK_CODE: 200 | ||
| 18 | +}; | ||
| 19 | +var BASE_URL = 'https://apis.map.qq.com/ws/'; | ||
| 20 | +var URL_SEARCH = BASE_URL + 'place/v1/search'; | ||
| 21 | +var URL_SUGGESTION = BASE_URL + 'place/v1/suggestion'; | ||
| 22 | +var URL_GET_GEOCODER = BASE_URL + 'geocoder/v1/'; | ||
| 23 | +var URL_CITY_LIST = BASE_URL + 'district/v1/list'; | ||
| 24 | +var URL_AREA_LIST = BASE_URL + 'district/v1/getchildren'; | ||
| 25 | +var URL_DISTANCE = BASE_URL + 'distance/v1/'; | ||
| 26 | +var Utils = { | ||
| 27 | + /** | ||
| 28 | + * 得到终点query字符串 | ||
| 29 | + * @param {Array|String} 检索数据 | ||
| 30 | + */ | ||
| 31 | + location2query(data) { | ||
| 32 | + if (typeof data == 'string') { | ||
| 33 | + return data; | ||
| 34 | + } | ||
| 35 | + var query = ''; | ||
| 36 | + for (var i = 0; i < data.length; i++) { | ||
| 37 | + var d = data[i]; | ||
| 38 | + if (!!query) { | ||
| 39 | + query += ';'; | ||
| 40 | + } | ||
| 41 | + if (d.location) { | ||
| 42 | + query = query + d.location.lat + ',' + d.location.lng; | ||
| 43 | + } | ||
| 44 | + if (d.latitude && d.longitude) { | ||
| 45 | + query = query + d.latitude + ',' + d.longitude; | ||
| 46 | + } | ||
| 47 | + } | ||
| 48 | + return query; | ||
| 49 | + }, | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 使用微信接口进行定位 | ||
| 53 | + */ | ||
| 54 | + getWXLocation(success, fail, complete) { | ||
| 55 | + wx.getLocation({ | ||
| 56 | + type: 'gcj02', | ||
| 57 | + success: success, | ||
| 58 | + fail: fail, | ||
| 59 | + complete: complete | ||
| 60 | + }); | ||
| 61 | + }, | ||
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * 获取location参数 | ||
| 65 | + */ | ||
| 66 | + getLocationParam(location) { | ||
| 67 | + if (typeof location == 'string') { | ||
| 68 | + var locationArr = location.split(','); | ||
| 69 | + if (locationArr.length === 2) { | ||
| 70 | + location = { | ||
| 71 | + latitude: location.split(',')[0], | ||
| 72 | + longitude: location.split(',')[1] | ||
| 73 | + }; | ||
| 74 | + } else { | ||
| 75 | + location = {}; | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + return location; | ||
| 79 | + }, | ||
| 80 | + | ||
| 81 | + /** | ||
| 82 | + * 回调函数默认处理 | ||
| 83 | + */ | ||
| 84 | + polyfillParam(param) { | ||
| 85 | + param.success = param.success || function () { }; | ||
| 86 | + param.fail = param.fail || function () { }; | ||
| 87 | + param.complete = param.complete || function () { }; | ||
| 88 | + }, | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * 验证param对应的key值是否为空 | ||
| 92 | + * | ||
| 93 | + * @param {Object} param 接口参数 | ||
| 94 | + * @param {String} key 对应参数的key | ||
| 95 | + */ | ||
| 96 | + checkParamKeyEmpty(param, key) { | ||
| 97 | + if (!param[key]) { | ||
| 98 | + var errconf = this.buildErrorConfig(ERROR_CONF.PARAM_ERR, ERROR_CONF.PARAM_ERR_MSG + key +'参数格式有误'); | ||
| 99 | + param.fail(errconf); | ||
| 100 | + param.complete(errconf); | ||
| 101 | + return true; | ||
| 102 | + } | ||
| 103 | + return false; | ||
| 104 | + }, | ||
| 105 | + | ||
| 106 | + /** | ||
| 107 | + * 验证参数中是否存在检索词keyword | ||
| 108 | + * | ||
| 109 | + * @param {Object} param 接口参数 | ||
| 110 | + */ | ||
| 111 | + checkKeyword(param){ | ||
| 112 | + return !this.checkParamKeyEmpty(param, 'keyword'); | ||
| 113 | + }, | ||
| 114 | + | ||
| 115 | + /** | ||
| 116 | + * 验证location值 | ||
| 117 | + * | ||
| 118 | + * @param {Object} param 接口参数 | ||
| 119 | + */ | ||
| 120 | + checkLocation(param) { | ||
| 121 | + var location = this.getLocationParam(param.location); | ||
| 122 | + if (!location || !location.latitude || !location.longitude) { | ||
| 123 | + var errconf = this.buildErrorConfig(ERROR_CONF.PARAM_ERR, ERROR_CONF.PARAM_ERR_MSG + ' location参数格式有误') | ||
| 124 | + param.fail(errconf); | ||
| 125 | + param.complete(errconf); | ||
| 126 | + return false; | ||
| 127 | + } | ||
| 128 | + return true; | ||
| 129 | + }, | ||
| 130 | + | ||
| 131 | + /** | ||
| 132 | + * 构造错误数据结构 | ||
| 133 | + * @param {Number} errCode 错误码 | ||
| 134 | + * @param {Number} errMsg 错误描述 | ||
| 135 | + */ | ||
| 136 | + buildErrorConfig(errCode, errMsg) { | ||
| 137 | + return { | ||
| 138 | + status: errCode, | ||
| 139 | + message: errMsg | ||
| 140 | + }; | ||
| 141 | + }, | ||
| 142 | + | ||
| 143 | + /** | ||
| 144 | + * 构造微信请求参数,公共属性处理 | ||
| 145 | + * | ||
| 146 | + * @param {Object} param 接口参数 | ||
| 147 | + * @param {Object} param 配置项 | ||
| 148 | + */ | ||
| 149 | + buildWxRequestConfig(param, options) { | ||
| 150 | + var that = this; | ||
| 151 | + options.header = { "content-type": "application/json" }; | ||
| 152 | + options.method = 'GET'; | ||
| 153 | + options.success = function (res) { | ||
| 154 | + var data = res.data; | ||
| 155 | + if (data.status === 0) { | ||
| 156 | + param.success(data); | ||
| 157 | + } else { | ||
| 158 | + param.fail(data); | ||
| 159 | + } | ||
| 160 | + }; | ||
| 161 | + options.fail = function (res) { | ||
| 162 | + res.statusCode = ERROR_CONF.WX_ERR_CODE; | ||
| 163 | + param.fail(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, result.errMsg)); | ||
| 164 | + }; | ||
| 165 | + options.complete = function (res) { | ||
| 166 | + var statusCode = +res.statusCode; | ||
| 167 | + switch(statusCode) { | ||
| 168 | + case ERROR_CONF.WX_ERR_CODE: { | ||
| 169 | + param.complete(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)); | ||
| 170 | + break; | ||
| 171 | + } | ||
| 172 | + case ERROR_CONF.WX_OK_CODE: { | ||
| 173 | + var data = res.data; | ||
| 174 | + if (data.status === 0) { | ||
| 175 | + param.complete(data); | ||
| 176 | + } else { | ||
| 177 | + param.complete(that.buildErrorConfig(data.status, data.message)); | ||
| 178 | + } | ||
| 179 | + break; | ||
| 180 | + } | ||
| 181 | + default:{ | ||
| 182 | + param.complete(that.buildErrorConfig(ERROR_CONF.SYSTEM_ERR, ERROR_CONF.SYSTEM_ERR_MSG)); | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + } | ||
| 186 | + } | ||
| 187 | + return options; | ||
| 188 | + }, | ||
| 189 | + | ||
| 190 | + /** | ||
| 191 | + * 处理用户参数是否传入坐标进行不同的处理 | ||
| 192 | + */ | ||
| 193 | + locationProcess(param, locationsuccess, locationfail, locationcomplete) { | ||
| 194 | + var that = this; | ||
| 195 | + locationfail = locationfail || function (res) { | ||
| 196 | + res.statusCode = ERROR_CONF.WX_ERR_CODE; | ||
| 197 | + param.fail(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)); | ||
| 198 | + }; | ||
| 199 | + locationcomplete = locationcomplete || function (res) { | ||
| 200 | + if (res.statusCode == ERROR_CONF.WX_ERR_CODE) { | ||
| 201 | + param.complete(that.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, res.errMsg)); | ||
| 202 | + } | ||
| 203 | + }; | ||
| 204 | + if (!param.location) { | ||
| 205 | + that.getWXLocation(locationsuccess, locationfail, locationcomplete); | ||
| 206 | + } else if (that.checkLocation(param)) { | ||
| 207 | + var location = Utils.getLocationParam(param.location); | ||
| 208 | + locationsuccess(location); | ||
| 209 | + } | ||
| 210 | + } | ||
| 211 | +} | ||
| 212 | + | ||
| 213 | + | ||
| 214 | +class QQMapWX { | ||
| 215 | + | ||
| 216 | + /** | ||
| 217 | + * 构造函数 | ||
| 218 | + * | ||
| 219 | + * @param {Object} options 接口参数,key 为必选参数 | ||
| 220 | + */ | ||
| 221 | + constructor(options) { | ||
| 222 | + if (!options.key) { | ||
| 223 | + throw Error('key值不能为空'); | ||
| 224 | + } | ||
| 225 | + this.key = options.key; | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + /** | ||
| 229 | + * POI周边检索 | ||
| 230 | + * | ||
| 231 | + * @param {Object} options 接口参数对象 | ||
| 232 | + * | ||
| 233 | + * 参数对象结构可以参考 | ||
| 234 | + * @see http://lbs.qq.com/webservice_v1/guide-search.html | ||
| 235 | + */ | ||
| 236 | + search(options) { | ||
| 237 | + var that = this; | ||
| 238 | + options = options || {}; | ||
| 239 | + | ||
| 240 | + Utils.polyfillParam(options); | ||
| 241 | + | ||
| 242 | + if (!Utils.checkKeyword(options)) { | ||
| 243 | + return; | ||
| 244 | + } | ||
| 245 | + | ||
| 246 | + var requestParam = { | ||
| 247 | + keyword: options.keyword, | ||
| 248 | + orderby: options.orderby || '_distance', | ||
| 249 | + page_size: options.page_size || 10, | ||
| 250 | + page_index: options.page_index || 1, | ||
| 251 | + output: 'json', | ||
| 252 | + key: that.key | ||
| 253 | + }; | ||
| 254 | + | ||
| 255 | + if (options.address_format) { | ||
| 256 | + requestParam.address_format = options.address_format; | ||
| 257 | + } | ||
| 258 | + | ||
| 259 | + if (options.filter) { | ||
| 260 | + requestParam.filter = options.filter; | ||
| 261 | + } | ||
| 262 | + | ||
| 263 | + var distance = options.distance || "1000"; | ||
| 264 | + var auto_extend = options.auto_extend || 1; | ||
| 265 | + | ||
| 266 | + var locationsuccess = function (result) { | ||
| 267 | + requestParam.boundary = "nearby(" + result.latitude + "," + result.longitude + "," + distance + "," + auto_extend +")"; | ||
| 268 | + wx.request(Utils.buildWxRequestConfig(options, { | ||
| 269 | + url: URL_SEARCH, | ||
| 270 | + data: requestParam | ||
| 271 | + })); | ||
| 272 | + } | ||
| 273 | + Utils.locationProcess(options, locationsuccess); | ||
| 274 | + } | ||
| 275 | + | ||
| 276 | + /** | ||
| 277 | + * sug模糊检索 | ||
| 278 | + * | ||
| 279 | + * @param {Object} options 接口参数对象 | ||
| 280 | + * | ||
| 281 | + * 参数对象结构可以参考 | ||
| 282 | + * http://lbs.qq.com/webservice_v1/guide-suggestion.html | ||
| 283 | + */ | ||
| 284 | + getSuggestion(options) { | ||
| 285 | + var that = this; | ||
| 286 | + options = options || {}; | ||
| 287 | + Utils.polyfillParam(options); | ||
| 288 | + | ||
| 289 | + if (!Utils.checkKeyword(options)) { | ||
| 290 | + return; | ||
| 291 | + } | ||
| 292 | + | ||
| 293 | + var requestParam = { | ||
| 294 | + keyword: options.keyword, | ||
| 295 | + region: options.region || '全国', | ||
| 296 | + region_fix: options.region_fix || 0, | ||
| 297 | + policy: options.policy || 0, | ||
| 298 | + output: 'json', | ||
| 299 | + key: that.key | ||
| 300 | + }; | ||
| 301 | + wx.request(Utils.buildWxRequestConfig(options, { | ||
| 302 | + url: URL_SUGGESTION, | ||
| 303 | + data: requestParam | ||
| 304 | + })); | ||
| 305 | + } | ||
| 306 | + | ||
| 307 | + /** | ||
| 308 | + * 逆地址解析 | ||
| 309 | + * | ||
| 310 | + * @param {Object} options 接口参数对象 | ||
| 311 | + * | ||
| 312 | + * 请求参数结构可以参考 | ||
| 313 | + * http://lbs.qq.com/webservice_v1/guide-gcoder.html | ||
| 314 | + */ | ||
| 315 | + reverseGeocoder(options) { | ||
| 316 | + var that = this; | ||
| 317 | + options = options || {}; | ||
| 318 | + Utils.polyfillParam(options); | ||
| 319 | + var requestParam = { | ||
| 320 | + coord_type: options.coord_type || 5, | ||
| 321 | + get_poi: options.get_poi || 0, | ||
| 322 | + output: 'json', | ||
| 323 | + key: that.key | ||
| 324 | + }; | ||
| 325 | + if (options.poi_options) { | ||
| 326 | + requestParam.poi_options = options.poi_options | ||
| 327 | + } | ||
| 328 | + | ||
| 329 | + var locationsuccess = function (result) { | ||
| 330 | + requestParam.location = result.latitude + ',' + result.longitude; | ||
| 331 | + wx.request(Utils.buildWxRequestConfig(options, { | ||
| 332 | + url: URL_GET_GEOCODER, | ||
| 333 | + data: requestParam | ||
| 334 | + })); | ||
| 335 | + }; | ||
| 336 | + Utils.locationProcess(options, locationsuccess); | ||
| 337 | + } | ||
| 338 | + | ||
| 339 | + /** | ||
| 340 | + * 地址解析 | ||
| 341 | + * | ||
| 342 | + * @param {Object} options 接口参数对象 | ||
| 343 | + * | ||
| 344 | + * 请求参数结构可以参考 | ||
| 345 | + * http://lbs.qq.com/webservice_v1/guide-geocoder.html | ||
| 346 | + */ | ||
| 347 | + geocoder(options) { | ||
| 348 | + var that = this; | ||
| 349 | + options = options || {}; | ||
| 350 | + Utils.polyfillParam(options); | ||
| 351 | + | ||
| 352 | + if (Utils.checkParamKeyEmpty(options, 'address')) { | ||
| 353 | + return; | ||
| 354 | + } | ||
| 355 | + | ||
| 356 | + var requestParam = { | ||
| 357 | + address: options.address, | ||
| 358 | + output: 'json', | ||
| 359 | + key: that.key | ||
| 360 | + }; | ||
| 361 | + | ||
| 362 | + wx.request(Utils.buildWxRequestConfig(options, { | ||
| 363 | + url: URL_GET_GEOCODER, | ||
| 364 | + data: requestParam | ||
| 365 | + })); | ||
| 366 | + } | ||
| 367 | + | ||
| 368 | + | ||
| 369 | + /** | ||
| 370 | + * 获取城市列表 | ||
| 371 | + * | ||
| 372 | + * @param {Object} options 接口参数对象 | ||
| 373 | + * | ||
| 374 | + * 请求参数结构可以参考 | ||
| 375 | + * http://lbs.qq.com/webservice_v1/guide-region.html | ||
| 376 | + */ | ||
| 377 | + getCityList(options) { | ||
| 378 | + var that = this; | ||
| 379 | + options = options || {}; | ||
| 380 | + Utils.polyfillParam(options); | ||
| 381 | + var requestParam = { | ||
| 382 | + output: 'json', | ||
| 383 | + key: that.key | ||
| 384 | + }; | ||
| 385 | + | ||
| 386 | + wx.request(Utils.buildWxRequestConfig(options, { | ||
| 387 | + url: URL_CITY_LIST, | ||
| 388 | + data: requestParam | ||
| 389 | + })); | ||
| 390 | + } | ||
| 391 | + | ||
| 392 | + /** | ||
| 393 | + * 获取对应城市ID的区县列表 | ||
| 394 | + * | ||
| 395 | + * @param {Object} options 接口参数对象 | ||
| 396 | + * | ||
| 397 | + * 请求参数结构可以参考 | ||
| 398 | + * http://lbs.qq.com/webservice_v1/guide-region.html | ||
| 399 | + */ | ||
| 400 | + getDistrictByCityId(options) { | ||
| 401 | + var that = this; | ||
| 402 | + options = options || {}; | ||
| 403 | + Utils.polyfillParam(options); | ||
| 404 | + | ||
| 405 | + if (Utils.checkParamKeyEmpty(options, 'id')) { | ||
| 406 | + return; | ||
| 407 | + } | ||
| 408 | + | ||
| 409 | + var requestParam = { | ||
| 410 | + id: options.id || '', | ||
| 411 | + output: 'json', | ||
| 412 | + key: that.key | ||
| 413 | + }; | ||
| 414 | + | ||
| 415 | + wx.request(Utils.buildWxRequestConfig(options, { | ||
| 416 | + url: URL_AREA_LIST, | ||
| 417 | + data: requestParam | ||
| 418 | + })); | ||
| 419 | + } | ||
| 420 | + | ||
| 421 | + /** | ||
| 422 | + * 用于单起点到多终点的路线距离(非直线距离)计算: | ||
| 423 | + * 支持两种距离计算方式:步行和驾车。 | ||
| 424 | + * 起点到终点最大限制直线距离10公里。 | ||
| 425 | + * | ||
| 426 | + * @param {Object} options 接口参数对象 | ||
| 427 | + * | ||
| 428 | + * 请求参数结构可以参考 | ||
| 429 | + * http://lbs.qq.com/webservice_v1/guide-distance.html | ||
| 430 | + */ | ||
| 431 | + calculateDistance(options) { | ||
| 432 | + var that = this; | ||
| 433 | + options = options || {}; | ||
| 434 | + Utils.polyfillParam(options); | ||
| 435 | + | ||
| 436 | + if (Utils.checkParamKeyEmpty(options, 'to')) { | ||
| 437 | + return; | ||
| 438 | + } | ||
| 439 | + | ||
| 440 | + var requestParam = { | ||
| 441 | + mode: options.mode || 'walking', | ||
| 442 | + to: Utils.location2query(options.to), | ||
| 443 | + output: 'json', | ||
| 444 | + key: that.key | ||
| 445 | + }; | ||
| 446 | + | ||
| 447 | + var locationsuccess = function (result) { | ||
| 448 | + requestParam.from = result.latitude + ',' + result.longitude; | ||
| 449 | + wx.request(Utils.buildWxRequestConfig(options, { | ||
| 450 | + url: URL_DISTANCE, | ||
| 451 | + data: requestParam | ||
| 452 | + })); | ||
| 453 | + } | ||
| 454 | + if (options.from) { | ||
| 455 | + options.location = options.from; | ||
| 456 | + } | ||
| 457 | + | ||
| 458 | + Utils.locationProcess(options, locationsuccess); | ||
| 459 | + } | ||
| 460 | +} | ||
| 461 | + | ||
| 462 | +module.exports = QQMapWX; |
-
Please register or login to post a comment