Commit dcb46afb23a0396152dc81aef5479c771f48a4ae

Authored by wangfan
1 parent fbe3c2a1

smsbatch

@@ -9,24 +9,18 @@ Page({ @@ -9,24 +9,18 @@ Page({
9 * 页面的初始数据 9 * 页面的初始数据
10 */ 10 */
11 data: { 11 data: {
12 - map:{  
13 - latitude: 23.099994,  
14 - longitude: 113.324520,  
15 - scale:18,  
16 - height:300,  
17 - },  
18 - markers: [{  
19 - iconPath: "http://qn.colorcun.com/custom/lite-yd/image/ding.d.png",  
20 - id: 0,  
21 - latitude: 23.099994,  
22 - longitude: 113.324520,  
23 - width: 50,  
24 - height: 50  
25 - }],  
26 - //polygons:{}, 12 + map: {
  13 + latitude: 23.099994,
  14 + longitude: 113.324520,
  15 + scale: 18,
  16 + height: 300,
  17 + },
  18 + markers: [],
  19 + //polygons:{},
27 }, 20 },
28 //qqmapsdk:null, 21 //qqmapsdk:null,
29 - sellers:[], 22 + sellers: [],
  23 + sellersIds:[],
30 /** 24 /**
31 * 生命周期函数--监听页面加载 25 * 生命周期函数--监听页面加载
32 */ 26 */
@@ -39,15 +33,31 @@ Page({ @@ -39,15 +33,31 @@ Page({
39 /** 33 /**
40 * 生命周期函数--监听页面初次渲染完成 34 * 生命周期函数--监听页面初次渲染完成
41 */ 35 */
  36 + mapCtx: null,
  37 + mapData:{
  38 + latitude: 23.099994,
  39 + longitude: 113.324520,
  40 + scale: 18,
  41 + hasRegionchange:false,
  42 + },
42 onReady: function () { 43 onReady: function () {
43 - 44 + this.mapCtx = wx.createMapContext('map')
  45 + this.mapCtx.moveToLocation({
  46 + success:(res)=>{
  47 + console.log('moveToLocation',res)
  48 + }
  49 + })
44 }, 50 },
45 51
46 /** 52 /**
47 * 生命周期函数--监听页面显示 53 * 生命周期函数--监听页面显示
48 */ 54 */
49 onShow: function () { 55 onShow: function () {
50 - this.getPos(); 56 + //this.getPos();
  57 + this.setData({
  58 + [`map.height`]: getApp().system.windowHeight,
  59 + })
  60 + //this.getMarkers();
51 }, 61 },
52 62
53 /** 63 /**
@@ -84,172 +94,202 @@ Page({ @@ -84,172 +94,202 @@ Page({
84 onShareAppMessage: function () { 94 onShareAppMessage: function () {
85 95
86 }, 96 },
  97 + /*
87 getPos(){ 98 getPos(){
88 - this._getPos().then(res=>{  
89 - console.log('wx.getLocation.then',res);  
90 - let map=this.data.map;  
91 - map.latitude=res.latitude;  
92 - map.longitude=res.longitude;  
93 - map.height=getApp().system.windowHeight  
94 - this.setData({  
95 - map:map,  
96 - })  
97 - this.getMarkers();  
98 - //this.getMapPos();  
99 - }).catch((e)=>{  
100 - console.log('wx.getLocation.catch',e);  
101 - if('getLocation:fail auth deny'==e.errMsg){  
102 - this.selectComponent('#showModal').options({  
103 - header:'定位失败',  
104 - body:'需要地理位置授权'  
105 - }).show();  
106 - }else{  
107 - setTimeout(()=>{  
108 - this.getPos()  
109 - },500)  
110 - } 99 + this._getPos().then(res => {
  100 + console.log('wx.getLocation.then', res);
  101 + let map = this.data.map;
  102 + map.latitude = res.latitude;
  103 + map.longitude = res.longitude;
  104 + map.height = getApp().system.windowHeight
  105 + this.setData({
  106 + map: map,
  107 + })
  108 + this.getMarkers();
  109 + //this.getMapPos();
  110 + }).catch((e) => {
  111 + console.log('wx.getLocation.catch', e);
  112 + if ('getLocation:fail auth deny' == e.errMsg) {
  113 + this.selectComponent('#showModal').options({
  114 + header: '定位失败',
  115 + body: '需要地理位置授权'
  116 + }).show();
  117 + } else {
  118 + setTimeout(() => {
  119 + this.getPos()
  120 + }, 500)
  121 + }
111 122
112 }) 123 })
113 }, 124 },
114 - _getPos(){  
115 - return new Promise((success,fail)=>{  
116 - wx.getLocation({  
117 - type:'gcj02',  
118 - success:(res)=>{  
119 - success(res)  
120 - },  
121 - fail:(res)=>{  
122 - fail(res)  
123 - },  
124 - complete:(res)=>{  
125 - console.log('wx.getLocation',res)  
126 - }  
127 - });  
128 - })  
129 - },  
130 - showModal(e){  
131 - wx.openSetting()  
132 - },  
133 - regionchange(e){  
134 - console.log('regionchange',e)  
135 - },  
136 - mapUpdated(e){  
137 - console.log('mapUpdated',e)  
138 - },  
139 - markertap(e){  
140 - console.log(e)  
141 - let seller={  
142 - id:e.markerId  
143 - };  
144 - this.sellers.forEach(se=>{  
145 - if(se.id==seller.id){  
146 - seller=se;  
147 - return false;  
148 - } 125 + _getPos(){
  126 + return new Promise((success, fail) => {
  127 + wx.getLocation({
  128 + type: 'gcj02',
  129 + success: (res) => {
  130 + success('getLocation',res)
  131 + },
  132 + fail: (res) => {
  133 + fail(res)
  134 + },
  135 + complete: (res) => {
  136 + console.log('wx.getLocation', res)
  137 + }
  138 + });
  139 + })
  140 + },
  141 + */
  142 + showModal(e){
  143 + wx.openSetting()
  144 + },
  145 + regionchange(e){
  146 + console.log('regionchange', e)
  147 + this.mapCtx.getCenterLocation({
  148 + success:(res)=>{
  149 + console.log('getCenterLocation',res)
  150 + if(res.latitude!=this.mapData.latitude
  151 + || res.longitude!=this.mapData.longitude){
  152 + this.mapData.hasRegionchange=true;
  153 + this.mapData.latitude=res.latitude;
  154 + this.mapData.longitude=res.longitude;
  155 + this.getMarkers();
  156 + }
  157 + },
  158 + });
  159 + },
  160 + mapUpdated(e){
  161 + console.log('mapUpdated', e)
  162 + this.mapCtx.getCenterLocation({
  163 + success:(res)=>{
  164 + console.log('getCenterLocation',res)
  165 + if(res.latitude!=this.mapData.latitude
  166 + || res.longitude!=this.mapData.longitude){
  167 + this.mapData.hasRegionchange=true;
  168 + this.mapData.latitude=res.latitude;
  169 + this.mapData.longitude=res.longitude;
  170 + this.getMarkers();
  171 + }
  172 + },
  173 + });
  174 + },
  175 + markertap(e){
  176 + console.log(e)
  177 + let seller = {
  178 + id: e.markerId
  179 + };
  180 + this.sellers.forEach(se => {
  181 + if (se.id == seller.id) {
  182 + seller = se;
  183 + return false;
  184 + }
  185 + })
  186 + this.selectComponent('#seller-box').show(seller);
  187 + wx.hideTabBar();
  188 + },
  189 + getMarkers(){
  190 + let map = this.mapData;
  191 + let markers = [];
  192 + App.Reserve.SellerList({
  193 + lat: map.latitude,
  194 + lng: map.longitude,
  195 + offset: 0,
  196 + rows: 100,
  197 + distance: 100,
  198 + }).then(res => {
  199 + if (res.ret == 200) {
  200 + let sellersIds=[];
  201 + res.data.forEach(seller=>{
  202 + sellersIds.push(seller.id);
149 }) 203 })
150 - this.selectComponent('#seller-box').show(seller);  
151 - wx.hideTabBar();  
152 - },  
153 - getMarkers(){  
154 - let map=this.data.map;  
155 - let markers=[];  
156 - App.Reserve.SellerList({  
157 - lat:map.latitude,  
158 - lng:map.longitude,  
159 - offset:0,  
160 - rows:10000,  
161 - distance:100000,  
162 - }).then(res=>{  
163 - if(res.ret==200){  
164 - this.sellers=res.data;  
165 - res.data.forEach(seller=>{  
166 - let namelength=seller.sellername.replace(/[^\x00-\xff]/g,"01").length+8;  
167 - markers.push({  
168 - id: seller.id,  
169 - iconPath: "http://qn.colorcun.com/custom/lite-yd/image/ding.png",  
170 - latitude: seller.lat,  
171 - longitude: seller.long,  
172 - width: 24,  
173 - height: 30,  
174 - //title:seller.seller_name,  
175 - label:{  
176 - content:' '+seller.sellername+' ',  
177 - color:'#353535',  
178 - fontSize:13,  
179 - anchorX:-(namelength/2*5),  
180 - anchorY:1,  
181 - borderWidth:1,  
182 - borderColor:'#B4B0B0',  
183 - borderRadius:20,  
184 - bgColor:'#fff',  
185 - padding:5,  
186 - textAlign:'center',  
187 - }  
188 - })  
189 - })  
190 - }else{  
191 - markers.push({  
192 - id: 1,  
193 - iconPath: "http://qn.colorcun.com/custom/lite-yd/image/ding.png",  
194 - latitude: parseFloat(map.latitude) + 1/1000,  
195 - longitude: parseFloat(map.longitude) +1/1000 ,  
196 - width: 24,  
197 - height: 30,  
198 - //title:'演示店铺',  
199 - label:{  
200 - content:' 演示店铺 ',  
201 - color:'#353535',  
202 - fontSize:13,  
203 - anchorX:-50,  
204 - anchorY:1,  
205 - borderWidth:1,  
206 - borderColor:'#B4B0B0',  
207 - borderRadius:20,  
208 - bgColor:'#fff',  
209 - padding:3,  
210 - textAlign:'center'  
211 - },  
212 - }) 204 + if(sellersIds.toString()==this.sellersIds.toString()) {
  205 + return;
  206 + }
  207 + this.sellersIds=sellersIds;
  208 + this.sellers = res.data;
  209 + res.data.forEach(seller => {
  210 + let namelength = seller.sellername.replace(/[^\x00-\xff]/g, "01").length + 8;
  211 + markers.push({
  212 + id: seller.id,
  213 + iconPath: "http://qn.colorcun.com/custom/lite-yd/image/ding.png",
  214 + latitude: seller.lat,
  215 + longitude: seller.long,
  216 + width: 24,
  217 + height: 30,
  218 + //title:seller.seller_name,
  219 + label: {
  220 + content: ' ' + seller.sellername + ' ',
  221 + color: '#353535',
  222 + fontSize: 13,
  223 + anchorX: -(namelength / 2 * 5),
  224 + anchorY: 1,
  225 + borderWidth: 1,
  226 + borderColor: '#B4B0B0',
  227 + borderRadius: 20,
  228 + bgColor: '#fff',
  229 + padding: 5,
  230 + textAlign: 'center',
213 } 231 }
214 - this.setData({  
215 - markers:markers,  
216 - }) 232 + })
217 }) 233 })
218 -  
219 - },  
220 - //seller box 通知  
221 - sellerBoxEvent(e){  
222 - wx.showTabBar();  
223 - },  
224 - //根据中心点计算坐标范围  
225 - getMapPos(){  
226 - let map=this.data.map;  
227 - let latitude=parseFloat(map.latitude);  
228 - let longitude=parseFloat(map.longitude);  
229 - let w2=getApp().system.windowWidth/2  
230 - let h2=getApp().system.windowHeight/2  
231 - let ys=w2*map.scale/1000000;  
232 - let xs=h2*map.scale/1000000;  
233 - let polygons=[  
234 - {  
235 - points:[  
236 - {latitude: latitude-xs, longitude: longitude+ys},  
237 -  
238 -  
239 - {latitude: latitude+xs, longitude: longitude+ys},  
240 - {latitude: latitude-xs, longitude: longitude-ys},  
241 -  
242 - {latitude: latitude+xs, longitude: longitude-ys},  
243 -  
244 - ],  
245 - strokeWidth:5,  
246 - strokeColor:'#00000055',  
247 - fillColor:'#00000088'  
248 - }  
249 - ];  
250 - this.setData({  
251 - polygons:polygons, 234 + } else {
  235 + markers.push({
  236 + id: 1,
  237 + iconPath: "http://qn.colorcun.com/custom/lite-yd/image/ding.png",
  238 + latitude: parseFloat(map.latitude) + 1 / 1000,
  239 + longitude: parseFloat(map.longitude) + 1 / 1000,
  240 + width: 24,
  241 + height: 30,
  242 + //title:'演示店铺',
  243 + label: {
  244 + content: ' 演示店铺 ',
  245 + color: '#353535',
  246 + fontSize: 13,
  247 + anchorX: -50,
  248 + anchorY: 1,
  249 + borderWidth: 1,
  250 + borderColor: '#B4B0B0',
  251 + borderRadius: 20,
  252 + bgColor: '#fff',
  253 + padding: 3,
  254 + textAlign: 'center'
  255 + },
252 }) 256 })
253 - this.getMarkers()  
254 - }, 257 + }
  258 + this.setData({
  259 + markers: markers,
  260 + })
  261 + })
  262 +
  263 + },
  264 + //seller box 通知
  265 + sellerBoxEvent(e){
  266 + wx.showTabBar();
  267 + },
  268 + //根据中心点计算坐标范围
  269 + getMapPos(){
  270 + let map = this.data.map;
  271 + let latitude = parseFloat(map.latitude);
  272 + let longitude = parseFloat(map.longitude);
  273 + let w2 = getApp().system.windowWidth / 2
  274 + let h2 = getApp().system.windowHeight / 2
  275 + let ys = w2 * map.scale / 1000000;
  276 + let xs = h2 * map.scale / 1000000;
  277 + let polygons = [
  278 + {
  279 + points: [
  280 + {latitude: latitude - xs, longitude: longitude + ys},
  281 + {latitude: latitude + xs, longitude: longitude + ys},
  282 + {latitude: latitude - xs, longitude: longitude - ys},
  283 + {latitude: latitude + xs, longitude: longitude - ys},
  284 + ],
  285 + strokeWidth: 5,
  286 + strokeColor: '#00000055',
  287 + fillColor: '#00000088'
  288 + }
  289 + ];
  290 + this.setData({
  291 + polygons: polygons,
  292 + })
  293 + this.getMarkers()
  294 + },
255 }) 295 })
1 <!--pages/reservr/index.wxml--> 1 <!--pages/reservr/index.wxml-->
2 <view class="page"> 2 <view class="page">
3 <view class="flex-vc map"> 3 <view class="flex-vc map">
4 - <map id="map" longitude="{{map.longitude}}" latitude="{{map.latitude}}" scale="{{map.scale}}" 4 + <map id="map" scale="{{map.scale}}"
5 markers="{{markers}}" polygons="{{polygons}}" 5 markers="{{markers}}" polygons="{{polygons}}"
6 bindmarkertap="markertap" 6 bindmarkertap="markertap"
7 bindregionchange="regionchange" 7 bindregionchange="regionchange"
@@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
30 "list": [] 30 "list": []
31 }, 31 },
32 "miniprogram": { 32 "miniprogram": {
33 - "current": 31, 33 + "current": 32,
34 "list": [ 34 "list": [
35 { 35 {
36 "id": 0, 36 "id": 0,
@@ -267,6 +267,13 @@ @@ -267,6 +267,13 @@
267 "pathName": "pages/book/smsbatch/index", 267 "pathName": "pages/book/smsbatch/index",
268 "query": "seller_id=80", 268 "query": "seller_id=80",
269 "scene": "1011" 269 "scene": "1011"
  270 + },
  271 + {
  272 + "id": -1,
  273 + "name": "pages/reserve/index",
  274 + "pathName": "pages/reserve/index",
  275 + "query": "",
  276 + "scene": "1001"
270 } 277 }
271 ] 278 ]
272 } 279 }