|
@@ -32,11 +32,20 @@ Page({ |
|
@@ -32,11 +32,20 @@ Page({ |
|
32
|
eventChannel:null,
|
32
|
eventChannel:null,
|
|
33
|
onLoad: async function (options) {
|
33
|
onLoad: async function (options) {
|
|
34
|
//lat=34.21719&lng=108.89155&map={"errMsg":"getMapRegion:ok","southwest":{"longitude":108.87545674591064,"latitude":34.204520114013846},"northeast":{"longitude":108.90764325408935,"latitude":34.229857981005225},"scale":15}&multiIndex=1&tags=1,2
|
34
|
//lat=34.21719&lng=108.89155&map={"errMsg":"getMapRegion:ok","southwest":{"longitude":108.87545674591064,"latitude":34.204520114013846},"northeast":{"longitude":108.90764325408935,"latitude":34.229857981005225},"scale":15}&multiIndex=1&tags=1,2
|
|
|
|
35
|
+ //lat=39.65273&lng=118.15813&map={"errMsg":"getMapRegion:ok","southwest":{"longitude":118.11012337295534,"latitude":39.61934377763755},"northeast":{"longitude":118.1262166270447,"latitude":39.63137569933196},"scale":15}&multiIndex=0¢re_pos=39.625360,118.118170&hasSuggestion=1&keywordTip=唐山站
|
|
35
|
this.options=options;
|
36
|
this.options=options;
|
|
36
|
if(options.hasSuggestion){
|
37
|
if(options.hasSuggestion){
|
|
|
|
38
|
+ let pos=options.centre_pos.split(',')
|
|
|
|
39
|
+ this.suggestion={
|
|
|
|
40
|
+ latitude:pos[0],
|
|
|
|
41
|
+ longitude:pos[1],
|
|
|
|
42
|
+ title:options.keyword,
|
|
|
|
43
|
+ }
|
|
37
|
this.setData({
|
44
|
this.setData({
|
|
38
|
- hasSuggestion:true
|
45
|
+ hasSuggestion:true,
|
|
|
|
46
|
+ suggestion:this.suggestion
|
|
39
|
})
|
47
|
})
|
|
|
|
48
|
+ delete this.options.keyword
|
|
40
|
}
|
49
|
}
|
|
41
|
let tags=[
|
50
|
let tags=[
|
|
42
|
{id:1,name:'环境好'},
|
51
|
{id:1,name:'环境好'},
|
|
@@ -106,7 +115,9 @@ Page({ |
|
@@ -106,7 +115,9 @@ Page({ |
|
106
|
* 生命周期函数--监听页面卸载
|
115
|
* 生命周期函数--监听页面卸载
|
|
107
|
*/
|
116
|
*/
|
|
108
|
onUnload: function () {
|
117
|
onUnload: function () {
|
|
109
|
- PubSub.off('searchParamList')
|
118
|
+ if(this.hasOneListPage()){
|
|
|
|
119
|
+ PubSub.off('searchParamList')
|
|
|
|
120
|
+ }
|
|
110
|
},
|
121
|
},
|
|
111
|
|
122
|
|
|
112
|
/**
|
123
|
/**
|
|
@@ -122,20 +133,28 @@ Page({ |
|
@@ -122,20 +133,28 @@ Page({ |
|
122
|
onReachBottom: function () {
|
133
|
onReachBottom: function () {
|
|
123
|
this.getListMore()
|
134
|
this.getListMore()
|
|
124
|
},
|
135
|
},
|
|
|
|
136
|
+ hasOneListPage(){//判断是否只有一个列表页面
|
|
|
|
137
|
+ let pages = getCurrentPages();
|
|
|
|
138
|
+ let pc=0
|
|
|
|
139
|
+ pages.forEach(p=>{
|
|
|
|
140
|
+ if(p.route=='pages/reserve/indexList'){
|
|
|
|
141
|
+ pc++;
|
|
|
|
142
|
+ }
|
|
|
|
143
|
+ })
|
|
|
|
144
|
+ if(pc==1){//只有一个列表页
|
|
|
|
145
|
+ return true
|
|
|
|
146
|
+ }
|
|
|
|
147
|
+ return false
|
|
|
|
148
|
+ },
|
|
125
|
hasGetSellerEnd:false,
|
149
|
hasGetSellerEnd:false,
|
|
|
|
150
|
+ hasCleanSuggestion:false,
|
|
126
|
async getList(){
|
151
|
async getList(){
|
|
127
|
let mapParam=this.options
|
152
|
let mapParam=this.options
|
|
128
|
this.offset=1 //page
|
153
|
this.offset=1 //page
|
|
129
|
this.size=20 //page size
|
154
|
this.size=20 //page size
|
|
130
|
- if(mapParam.keywordTip){
|
|
|
|
131
|
- this.setData({
|
|
|
|
132
|
- keyword:mapParam.keywordTip,
|
|
|
|
133
|
- })
|
|
|
|
134
|
- }else{
|
|
|
|
135
|
- this.setData({
|
|
|
|
136
|
- keyword:mapParam.keyword||'',
|
|
|
|
137
|
- })
|
|
|
|
138
|
- }
|
155
|
+ this.setData({
|
|
|
|
156
|
+ keyword:mapParam.keyword||'',
|
|
|
|
157
|
+ })
|
|
139
|
|
158
|
|
|
140
|
if(mapParam.keyword){
|
159
|
if(mapParam.keyword){
|
|
141
|
this.param={
|
160
|
this.param={
|
|
@@ -161,7 +180,11 @@ Page({ |
|
@@ -161,7 +180,11 @@ Page({ |
|
161
|
this.setData({
|
180
|
this.setData({
|
|
162
|
keyword:this.suggestion.title,
|
181
|
keyword:this.suggestion.title,
|
|
163
|
})
|
182
|
})
|
|
164
|
- }else{
|
183
|
+ }else if(this.hasCleanSuggestion){//清理地标使用人的位置
|
|
|
|
184
|
+ lat=this.location.latitude
|
|
|
|
185
|
+ lng=this.location.longitude
|
|
|
|
186
|
+ }
|
|
|
|
187
|
+ if(!lat || !lng){//不完整时,使用地图中心点
|
|
165
|
let map=JSON.parse(mapParam.map);
|
188
|
let map=JSON.parse(mapParam.map);
|
|
166
|
lat=map.northeast.latitude-(map.northeast.latitude-map.southwest.latitude)/2;
|
189
|
lat=map.northeast.latitude-(map.northeast.latitude-map.southwest.latitude)/2;
|
|
167
|
lng=map.northeast.longitude-(map.northeast.longitude-map.southwest.longitude)/2;
|
190
|
lng=map.northeast.longitude-(map.northeast.longitude-map.southwest.longitude)/2;
|
|
@@ -175,7 +198,7 @@ Page({ |
|
@@ -175,7 +198,7 @@ Page({ |
|
175
|
size:this.size,
|
198
|
size:this.size,
|
|
176
|
distance:50,
|
199
|
distance:50,
|
|
177
|
};
|
200
|
};
|
|
178
|
- if(this.suggestion){
|
201
|
+ if(this.suggestion || this.hasCleanSuggestion){
|
|
179
|
this.param.centre_pos=`${lat},${lng}`
|
202
|
this.param.centre_pos=`${lat},${lng}`
|
|
180
|
}else{
|
203
|
}else{
|
|
181
|
if(mapParam.centre_pos){
|
204
|
if(mapParam.centre_pos){
|
|
@@ -260,13 +283,15 @@ Page({ |
|
@@ -260,13 +283,15 @@ Page({ |
|
260
|
value:[e.detail]
|
283
|
value:[e.detail]
|
|
261
|
}
|
284
|
}
|
|
262
|
})
|
285
|
})
|
|
263
|
- PubSub.emit(
|
|
|
|
264
|
- 'searchParam',
|
|
|
|
265
|
- {
|
|
|
|
266
|
- fun:'caixiActive',
|
|
|
|
267
|
- e:e,
|
|
|
|
268
|
- }
|
|
|
|
269
|
- )
|
286
|
+ if(this.hasOneListPage()){
|
|
|
|
287
|
+ PubSub.emit(
|
|
|
|
288
|
+ 'searchParam',
|
|
|
|
289
|
+ {
|
|
|
|
290
|
+ fun:'caixiActive',
|
|
|
|
291
|
+ e:e,
|
|
|
|
292
|
+ }
|
|
|
|
293
|
+ )
|
|
|
|
294
|
+ }
|
|
270
|
},
|
295
|
},
|
|
271
|
bindMultiPickerChange(e){
|
296
|
bindMultiPickerChange(e){
|
|
272
|
console.log(e);
|
297
|
console.log(e);
|
|
@@ -292,13 +317,15 @@ Page({ |
|
@@ -292,13 +317,15 @@ Page({ |
|
292
|
this.setData({
|
317
|
this.setData({
|
|
293
|
tags:tags,
|
318
|
tags:tags,
|
|
294
|
})
|
319
|
})
|
|
295
|
- PubSub.emit(
|
|
|
|
296
|
- 'searchParam',
|
|
|
|
297
|
- {
|
|
|
|
298
|
- fun:'tagsChange',
|
|
|
|
299
|
- e:e,
|
|
|
|
300
|
- }
|
|
|
|
301
|
- )
|
320
|
+ if(this.hasOneListPage()) {
|
|
|
|
321
|
+ PubSub.emit(
|
|
|
|
322
|
+ 'searchParam',
|
|
|
|
323
|
+ {
|
|
|
|
324
|
+ fun: 'tagsChange',
|
|
|
|
325
|
+ e: e,
|
|
|
|
326
|
+ }
|
|
|
|
327
|
+ )
|
|
|
|
328
|
+ }
|
|
302
|
setTimeout(()=>{this.getList();},0)
|
329
|
setTimeout(()=>{this.getList();},0)
|
|
303
|
},
|
330
|
},
|
|
304
|
gotoDetail(e){
|
331
|
gotoDetail(e){
|
|
@@ -404,4 +431,15 @@ Page({ |
|
@@ -404,4 +431,15 @@ Page({ |
|
404
|
})
|
431
|
})
|
|
405
|
this.getList()
|
432
|
this.getList()
|
|
406
|
},
|
433
|
},
|
|
|
|
434
|
+ moveToLocation(){
|
|
|
|
435
|
+ this.suggestion=null
|
|
|
|
436
|
+ this.hasCleanSuggestion=true,
|
|
|
|
437
|
+ this.setData({
|
|
|
|
438
|
+ suggestion:null,
|
|
|
|
439
|
+ hasSuggestion:false,
|
|
|
|
440
|
+ keyword:'',
|
|
|
|
441
|
+ })
|
|
|
|
442
|
+ PubSub.emit('searchParam', {fun:'moveToLocation'})
|
|
|
|
443
|
+ setTimeout(()=>{this.getList()},0)
|
|
|
|
444
|
+ },
|
|
407
|
}) |
445
|
}) |