diff --git a/fangija-zsyf/js/searchDistrict-app.js b/fangija-zsyf/js/searchDistrict-app.js index 3955432..1dfd4c9 100644 --- a/fangija-zsyf/js/searchDistrict-app.js +++ b/fangija-zsyf/js/searchDistrict-app.js @@ -77,11 +77,13 @@ function saveHistory(district) { break } } - $.cookie('history',JSON.stringify(newHistory) ,{ expires: 7}) + //$.cookie('history',JSON.stringify(newHistory) ,{ expires: 7}) + localStorage.setItem("history", JSON.stringify(newHistory)); } function recover() { - var history = $.cookie('history') + //var history = $.cookie('history') + var history = localStorage.getItem('history'); if(history == undefined || history == ''){ return new Array() } @@ -136,24 +138,27 @@ function addHotDistricts(cityParam){ 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(){ var history = recover() if(history.length>0){ - var histories = []; + histories = [] $(history).each(function(){ var map={city:this.city, region:this.district, name:this.name}; histories.push(map) }) - 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); - } - } - }) + historyVue.histories=histories; + }else{ $(".historyList #districtList").empty(); @@ -162,7 +167,8 @@ function addHistory(){ //点击清空 $("#clearSearchHistory").click(function(){ - $.cookie('history',JSON.stringify([]) ,{ expires: 7}); + //$.cookie('history',JSON.stringify([]) ,{ expires: 7}); + localStorage.removeItem('history') $("#districtList").empty(); $.popup(".popup-about02") });