|
@@ -26,7 +26,7 @@ Page({ |
|
@@ -26,7 +26,7 @@ Page({ |
|
26
|
* 生命周期函数--监听页面加载
|
26
|
* 生命周期函数--监听页面加载
|
|
27
|
*/
|
27
|
*/
|
|
28
|
onLoad: function (options) {
|
28
|
onLoad: function (options) {
|
|
29
|
- this.getPos()
|
29
|
+ this.selectComponent('#getpos').getPos();
|
|
30
|
},
|
30
|
},
|
|
31
|
|
31
|
|
|
32
|
/**
|
32
|
/**
|
|
@@ -109,15 +109,18 @@ Page({ |
|
@@ -109,15 +109,18 @@ Page({ |
|
109
|
keyword:''
|
109
|
keyword:''
|
|
110
|
})
|
110
|
})
|
|
111
|
}
|
111
|
}
|
|
112
|
- App.Customer.KeywordTips({
|
112
|
+ let prarms={
|
|
113
|
keyword:this.inputVal,
|
113
|
keyword:this.inputVal,
|
|
114
|
region:this.location.city||'',
|
114
|
region:this.location.city||'',
|
|
115
|
region_fix:0,
|
115
|
region_fix:0,
|
|
116
|
- location:this.location.latitude+','+this.location.longitude,
|
|
|
|
117
|
page_size:20,
|
116
|
page_size:20,
|
|
118
|
page_index:1,
|
117
|
page_index:1,
|
|
119
|
key:map_key,
|
118
|
key:map_key,
|
|
120
|
- }).then(res=>{
|
119
|
+ }
|
|
|
|
120
|
+ if(this.location.latitude){
|
|
|
|
121
|
+ prarms.location=this.location.latitude+','+this.location.longitude
|
|
|
|
122
|
+ }
|
|
|
|
123
|
+ App.Customer.KeywordTips(prarms).then(res=>{
|
|
121
|
if(this.inputVal.length<1){
|
124
|
if(this.inputVal.length<1){
|
|
122
|
return this.setData({
|
125
|
return this.setData({
|
|
123
|
suggestion: []
|
126
|
suggestion: []
|
|
@@ -183,42 +186,11 @@ Page({ |
|
@@ -183,42 +186,11 @@ Page({ |
|
183
|
})
|
186
|
})
|
|
184
|
},
|
187
|
},
|
|
185
|
location:'',
|
188
|
location:'',
|
|
186
|
- getPos(){
|
|
|
|
187
|
- this._getPos().then(res => {
|
|
|
|
188
|
- console.log('wx.getLocation.then', res);
|
|
|
|
189
|
- this.location=res
|
|
|
|
190
|
- this.getCity()
|
|
|
|
191
|
- this.GetRecommendSellerLists()
|
|
|
|
192
|
- }).catch((e) => {
|
|
|
|
193
|
- console.log('wx.getLocation.catch', e);
|
|
|
|
194
|
- if ('getLocation:fail auth deny' == e.errMsg || 'getLocation:fail:auth denied' == e.errMsg) {
|
|
|
|
195
|
- this.selectComponent('#showModal').options({
|
|
|
|
196
|
- header: '定位失败',
|
|
|
|
197
|
- body: '需要地理位置授权'
|
|
|
|
198
|
- }).show();
|
|
|
|
199
|
- } else {
|
|
|
|
200
|
- setTimeout(() => {
|
|
|
|
201
|
- this.getPos()
|
|
|
|
202
|
- }, 500)
|
|
|
|
203
|
- }
|
|
|
|
204
|
-
|
|
|
|
205
|
- })
|
|
|
|
206
|
- },
|
|
|
|
207
|
- _getPos(){
|
|
|
|
208
|
- return new Promise((success, fail) => {
|
|
|
|
209
|
- wx.getLocation({
|
|
|
|
210
|
- type: 'gcj02',
|
|
|
|
211
|
- success: (res) => {
|
|
|
|
212
|
- success(res)
|
|
|
|
213
|
- },
|
|
|
|
214
|
- fail: (res) => {
|
|
|
|
215
|
- fail(res)
|
|
|
|
216
|
- },
|
|
|
|
217
|
- complete: (res) => {
|
|
|
|
218
|
- console.log('wx.getLocation', res)
|
|
|
|
219
|
- }
|
|
|
|
220
|
- });
|
|
|
|
221
|
- })
|
189
|
+ onpos(e){
|
|
|
|
190
|
+ console.log(e);
|
|
|
|
191
|
+ this.location=e.detail
|
|
|
|
192
|
+ this.GetRecommendSellerLists()
|
|
|
|
193
|
+ this.getCity()
|
|
222
|
},
|
194
|
},
|
|
223
|
getCity(){
|
195
|
getCity(){
|
|
224
|
qqmapsdk.reverseGeocoder({
|
196
|
qqmapsdk.reverseGeocoder({
|
|
@@ -284,12 +256,11 @@ Page({ |
|
@@ -284,12 +256,11 @@ Page({ |
|
284
|
})
|
256
|
})
|
|
285
|
},
|
257
|
},
|
|
286
|
GetRecommendSellerLists(){
|
258
|
GetRecommendSellerLists(){
|
|
|
|
259
|
+ if(!this.location.latitude) return;
|
|
287
|
let param={}
|
260
|
let param={}
|
|
288
|
- if(this.location){
|
|
|
|
289
|
- param={
|
|
|
|
290
|
- lat:this.location.latitude,
|
|
|
|
291
|
- lng:this.location.longitude
|
|
|
|
292
|
- }
|
261
|
+ param={
|
|
|
|
262
|
+ lat:this.location.latitude,
|
|
|
|
263
|
+ lng:this.location.longitude
|
|
293
|
}
|
264
|
}
|
|
294
|
App.Customer.GetRecommendSellerLists(param).then(res=>{
|
265
|
App.Customer.GetRecommendSellerLists(param).then(res=>{
|
|
295
|
this.setData({
|
266
|
this.setData({
|