|
|
|
// pages/reserve/search.js
|
|
|
|
// pages/reserve/search.js\
|
|
|
|
const map_key='SDEBZ-I74W4-QLGUX-XXYXU-HIR23-3QFBJ'
|
|
|
|
// 引入SDK核心类
|
|
|
|
var QQMapWX = require('../../utils/qqmap-wx-jssdk');
|
|
|
|
// 实例化API核心类
|
|
|
|
var qqmapsdk = new QQMapWX({
|
|
|
|
key: 'SDEBZ-I74W4-QLGUX-XXYXU-HIR23-3QFBJ' // 必填
|
|
|
|
key:map_key // 必填
|
|
|
|
});
|
|
|
|
import util from '../../utils/util';
|
|
|
|
import App from '../../utils/api';
|
|
|
|
const {regeneratorRuntime} = global
|
|
|
|
const search_history_cache_key='SEARCH_HISTORY_CACHE_KEY';
|
|
|
|
Page({
|
|
...
|
...
|
@@ -82,7 +84,7 @@ Page({ |
|
|
|
var id = e.currentTarget.id;
|
|
|
|
for (var i = 0; i < this.data.suggestion.length; i++) {
|
|
|
|
if (i == id) {
|
|
|
|
console.log(this.data.suggestion[i])
|
|
|
|
console.log('backfill,this.data.suggestion[i]:',this.data.suggestion[i])
|
|
|
|
this.setHistory(this.data.suggestion[i])
|
|
|
|
let pages = getCurrentPages();
|
|
|
|
let p = pages[pages.length - 2];
|
|
...
|
...
|
@@ -156,49 +158,41 @@ Page({ |
|
|
|
});
|
|
|
|
},
|
|
|
|
nearby_search: function () {
|
|
|
|
var _this = this;
|
|
|
|
// 调用接口
|
|
|
|
let location='';
|
|
|
|
if(this.data.suggestion.length>0){
|
|
|
|
location=this.data.suggestion[0]
|
|
|
|
}
|
|
|
|
qqmapsdk.search({
|
|
|
|
keyword: this.inputVal, //搜索关键词
|
|
|
|
region:this.location.city||'', //设置城市名,限制关键词所示的地域范围,非必填参数
|
|
|
|
App.Customer.SearchMap({
|
|
|
|
//boundary:'region('+this.location.city+',1)',
|
|
|
|
boundary:'nearby('+this.location.latitude+','+this.location.longitude+',1000,1)',
|
|
|
|
keyword:this.inputVal,
|
|
|
|
page_size:20,
|
|
|
|
location:location,
|
|
|
|
//filter:'category<>美食',
|
|
|
|
success: function (res) { //搜索成功后的回调
|
|
|
|
var mks = []
|
|
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
|
|
mks.push({ // 获取返回结果,放到mks数组中
|
|
|
|
title: res.data[i].title,
|
|
|
|
id: res.data[i].id,
|
|
|
|
addr: res.data[i].address,
|
|
|
|
city: res.data[i].city,
|
|
|
|
district: res.data[i].district,
|
|
|
|
latitude: res.data[i].location.lat,
|
|
|
|
longitude: res.data[i].location.lng,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
_this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示
|
|
|
|
suggestion:mks,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
fail: function (res) {
|
|
|
|
console.log(res);
|
|
|
|
},
|
|
|
|
complete: function (res) {
|
|
|
|
console.log('nearby_search',res);
|
|
|
|
page_index:1,
|
|
|
|
orderby:'_distance',
|
|
|
|
key:map_key,
|
|
|
|
}).then(res=>{
|
|
|
|
console.log('App.Customer.SearchMap',res)
|
|
|
|
res.data=res.data.data
|
|
|
|
var mks = []
|
|
|
|
for (var i = 0; i < res.data.length; i++) {
|
|
|
|
mks.push({ // 获取返回结果,放到mks数组中
|
|
|
|
title: res.data[i].title,
|
|
|
|
id: res.data[i].id,
|
|
|
|
addr: res.data[i].address,
|
|
|
|
city: res.data[i].city,
|
|
|
|
district: res.data[i].district,
|
|
|
|
latitude: res.data[i].location.lat,
|
|
|
|
longitude: res.data[i].location.lng,
|
|
|
|
type:res.data[i].type,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示
|
|
|
|
suggestion:mks,
|
|
|
|
});
|
|
|
|
})
|
|
|
|
},
|
|
|
|
location:'',
|
|
|
|
getPos(){
|
|
|
|
this._getPos().then(res => {
|
|
|
|
console.log('wx.getLocation.then', res);
|
|
|
|
this.location=res
|
|
|
|
this.getCity()
|
|
|
|
//this.getCity()
|
|
|
|
}).catch((e) => {
|
|
|
|
console.log('wx.getLocation.catch', e);
|
|
|
|
if ('getLocation:fail auth deny' == e.errMsg || 'getLocation:fail:auth denied' == e.errMsg) {
|
...
|
...
|
|