|
...
|
...
|
@@ -23,6 +23,7 @@ Page({ |
|
|
|
*/
|
|
|
|
onLoad: function (options) {
|
|
|
|
this.getHistory();
|
|
|
|
this.getPos()
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -122,7 +123,8 @@ Page({ |
|
|
|
qqmapsdk.getSuggestion({
|
|
|
|
//获取输入框值并设置keyword参数
|
|
|
|
keyword: e.detail.value, //用户输入的关键词,可设置固定值,如keyword:'KFC'
|
|
|
|
//region:'北京', //设置城市名,限制关键词所示的地域范围,非必填参数
|
|
|
|
region:this.location.city||'', //设置城市名,限制关键词所示的地域范围,非必填参数
|
|
|
|
//region_fix:1,//锁定在本市
|
|
|
|
success: function (res) {//搜索成功后的回调
|
|
|
|
console.log(res);
|
|
|
|
var sug = [];
|
|
...
|
...
|
@@ -161,6 +163,7 @@ Page({ |
|
|
|
}
|
|
|
|
qqmapsdk.search({
|
|
|
|
keyword: this.inputVal, //搜索关键词
|
|
|
|
region:this.location.city||'', //设置城市名,限制关键词所示的地域范围,非必填参数
|
|
|
|
page_size:20,
|
|
|
|
location:location,
|
|
|
|
success: function (res) { //搜索成功后的回调
|
|
...
|
...
|
@@ -188,4 +191,52 @@ Page({ |
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
location:'',
|
|
|
|
getPos(){
|
|
|
|
this._getPos().then(res => {
|
|
|
|
console.log('wx.getLocation.then', res);
|
|
|
|
this.location=res
|
|
|
|
this.getCity()
|
|
|
|
}).catch((e) => {
|
|
|
|
console.log('wx.getLocation.catch', e);
|
|
|
|
if ('getLocation:fail auth deny' == e.errMsg || 'getLocation:fail:auth denied' == e.errMsg) {
|
|
|
|
this.selectComponent('#showModal').options({
|
|
|
|
header: '定位失败',
|
|
|
|
body: '需要地理位置授权'
|
|
|
|
}).show();
|
|
|
|
} else {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.getPos()
|
|
|
|
}, 500)
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
},
|
|
|
|
_getPos(){
|
|
|
|
return new Promise((success, fail) => {
|
|
|
|
wx.getLocation({
|
|
|
|
type: 'gcj02',
|
|
|
|
success: (res) => {
|
|
|
|
success(res)
|
|
|
|
},
|
|
|
|
fail: (res) => {
|
|
|
|
fail(res)
|
|
|
|
},
|
|
|
|
complete: (res) => {
|
|
|
|
console.log('wx.getLocation', res)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getCity(){
|
|
|
|
qqmapsdk.reverseGeocoder({
|
|
|
|
location:this.location,
|
|
|
|
success:(res)=>{
|
|
|
|
this.location['city']='';
|
|
|
|
if(res.status==0){
|
|
|
|
this.location['city']=res.result.ad_info.city
|
|
|
|
}
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|