aa
This commit is contained in:
@@ -77,11 +77,13 @@ function saveHistory(district) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$.cookie('history',JSON.stringify(newHistory) ,{ expires: 7})
|
//$.cookie('history',JSON.stringify(newHistory) ,{ expires: 7})
|
||||||
|
localStorage.setItem("history", JSON.stringify(newHistory));
|
||||||
}
|
}
|
||||||
|
|
||||||
function recover() {
|
function recover() {
|
||||||
var history = $.cookie('history')
|
//var history = $.cookie('history')
|
||||||
|
var history = localStorage.getItem('history');
|
||||||
if(history == undefined || history == ''){
|
if(history == undefined || history == ''){
|
||||||
return new Array()
|
return new Array()
|
||||||
}
|
}
|
||||||
@@ -136,24 +138,27 @@ function addHotDistricts(cityParam){
|
|||||||
console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
var histories = [];
|
||||||
|
var historyVue = new Vue({
|
||||||
|
el: '#districtList',
|
||||||
|
data: {
|
||||||
|
histories: histories
|
||||||
|
},methods: {
|
||||||
|
openHistoryDetail:function(index) {
|
||||||
|
clicked(BASE_PATH+'/district/details?city='+this.histories[index].city+'®ion='+this.histories[index].region+'&name='+this.histories[index].name,true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
function addHistory(){
|
function addHistory(){
|
||||||
var history = recover()
|
var history = recover()
|
||||||
if(history.length>0){
|
if(history.length>0){
|
||||||
var histories = [];
|
histories = []
|
||||||
$(history).each(function(){
|
$(history).each(function(){
|
||||||
var map={city:this.city, region:this.district, name:this.name};
|
var map={city:this.city, region:this.district, name:this.name};
|
||||||
histories.push(map)
|
histories.push(map)
|
||||||
})
|
})
|
||||||
new Vue({
|
historyVue.histories=histories;
|
||||||
el: '#districtList',
|
|
||||||
data: {
|
|
||||||
histories: histories
|
|
||||||
},methods: {
|
|
||||||
openHistoryDetail:function(index) {
|
|
||||||
clicked(BASE_PATH+'/district/details?city='+this.histories[index].city+'®ion='+this.histories[index].region+'&name='+this.histories[index].name,true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
$(".historyList #districtList").empty();
|
$(".historyList #districtList").empty();
|
||||||
@@ -162,7 +167,8 @@ function addHistory(){
|
|||||||
|
|
||||||
//点击清空
|
//点击清空
|
||||||
$("#clearSearchHistory").click(function(){
|
$("#clearSearchHistory").click(function(){
|
||||||
$.cookie('history',JSON.stringify([]) ,{ expires: 7});
|
//$.cookie('history',JSON.stringify([]) ,{ expires: 7});
|
||||||
|
localStorage.removeItem('history')
|
||||||
$("#districtList").empty();
|
$("#districtList").empty();
|
||||||
$.popup(".popup-about02")
|
$.popup(".popup-about02")
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user