|
...
|
...
|
@@ -8,8 +8,6 @@ var qqmapsdk = new QQMapWX({ |
|
|
|
});
|
|
|
|
import util from '../../utils/util';
|
|
|
|
import App from '../../utils/api';
|
|
|
|
const {regeneratorRuntime} = global
|
|
|
|
const search_history_cache_key='SEARCH_HISTORY_CACHE_KEY';
|
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -60,26 +58,24 @@ Page({ |
|
|
|
},
|
|
|
|
getHistory(){
|
|
|
|
App.Customer.GetHistorySearch().then(res=>{
|
|
|
|
let mks=[]
|
|
|
|
res.data.forEach(h=>{
|
|
|
|
mks.push({ // 获取返回结果,放到mks数组中
|
|
|
|
title: h.name,
|
|
|
|
id: h.sid,
|
|
|
|
addr: '',
|
|
|
|
city: '',
|
|
|
|
district: 0,
|
|
|
|
latitude: h.latitude,
|
|
|
|
longitude: h.longitude,
|
|
|
|
type:h.type==1?-1:h.type,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
history:res.data
|
|
|
|
history:mks
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
setHistory(item){
|
|
|
|
let newca=[item];
|
|
|
|
let ca=this.data.history;
|
|
|
|
let maxL=20;
|
|
|
|
for(let i=0;i<ca.length;i++){
|
|
|
|
if(ca[i].id!=item.id){
|
|
|
|
newca.push(ca[i]);
|
|
|
|
}
|
|
|
|
if(newca.length>maxL) break;
|
|
|
|
}
|
|
|
|
util.cache(search_history_cache_key,newca);
|
|
|
|
this.setData({
|
|
|
|
history:newca,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
//在Page({})中使用下列代码
|
|
|
|
//数据回填方法
|
|
|
|
backfill: function (e) {
|
|
...
|
...
|
@@ -87,7 +83,6 @@ Page({ |
|
|
|
for (var i = 0; i < this.data.suggestion.length; i++) {
|
|
|
|
if (i == id) {
|
|
|
|
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];
|
|
|
|
p.setSuggestion(this.data.suggestion[i])
|
|
...
|
...
|
@@ -99,25 +94,6 @@ Page({ |
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
backHistoryFill: function (e) {
|
|
|
|
var i = util.attr(e,'index');
|
|
|
|
let item=this.data.history[i];
|
|
|
|
item.title=item.name
|
|
|
|
console.log(item)
|
|
|
|
if(item.type==1){
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
backfill: item.title
|
|
|
|
});
|
|
|
|
|
|
|
|
let pages = getCurrentPages();
|
|
|
|
let p = pages[pages.length - 2];
|
|
|
|
p.setSuggestion(item)
|
|
|
|
wx.navigateBack();
|
|
|
|
},
|
|
|
|
inputVal:'',
|
|
|
|
//触发关键词输入提示事件
|
|
|
|
getsuggest: function (e) {
|
|
...
|
...
|
@@ -283,4 +259,7 @@ Page({ |
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
historyEmpty(){
|
|
|
|
App.Customer.DelHistorySearch()
|
|
|
|
},
|
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|