|
|
|
@ -29,7 +29,7 @@ Page({ |
|
|
|
landInfo: null, |
|
|
|
visible: false, |
|
|
|
show: false, |
|
|
|
hotList: [], |
|
|
|
historyList: [], |
|
|
|
cityId: null, |
|
|
|
visible2: false |
|
|
|
}, |
|
|
|
@ -88,7 +88,7 @@ Page({ |
|
|
|
this.locationing() |
|
|
|
this.onResume() |
|
|
|
if (this.data.path) { |
|
|
|
wx.navigateTo({ url: this.data.path }) |
|
|
|
util.navigateTo(this.data.path) |
|
|
|
} |
|
|
|
getPopupInfo().then(result => { |
|
|
|
if (result.data) { |
|
|
|
@ -107,8 +107,10 @@ Page({ |
|
|
|
success: function (res) { |
|
|
|
app.nowLocation.cityName = res.result.address_component.city.replace('市', '') |
|
|
|
app.nowLocation.cityCode = res.result.ad_info.city_code |
|
|
|
app.nowCity = { cityName: app.nowLocation.cityName, cityCode: app.nowLocation.cityCode } |
|
|
|
that.setData({ cityName: app.nowLocation.cityName }) |
|
|
|
if(!app.nowCity){ |
|
|
|
app.nowCity = { cityName: app.nowLocation.cityName, cityCode: app.nowLocation.cityCode } |
|
|
|
that.setData({ cityName: app.nowLocation.cityName }) |
|
|
|
} |
|
|
|
that.located = true |
|
|
|
}, |
|
|
|
fail: function (res) { |
|
|
|
@ -266,13 +268,13 @@ Page({ |
|
|
|
util.navigateTarget(this.data.landInfo.ruleRedirectInfo) |
|
|
|
}, |
|
|
|
fetchRegionList: function () { |
|
|
|
var hotstring = storage.get('ztb-city-list') |
|
|
|
var hotList = [] |
|
|
|
var hotstring = storage.get('ztb-history-list') |
|
|
|
var historyList = [] |
|
|
|
if(!util.isEmpty(hotstring)){ |
|
|
|
hotList = JSON.parse(hotstring) |
|
|
|
historyList = JSON.parse(hotstring) |
|
|
|
} |
|
|
|
getFactoryCity().then(result => { |
|
|
|
this.setData({ cityList: result.data, hotList }) |
|
|
|
this.setData({ cityList: result.data, historyList }) |
|
|
|
}) |
|
|
|
}, |
|
|
|
clickCity: function(e){ |
|
|
|
@ -283,18 +285,26 @@ Page({ |
|
|
|
if(!util.isEmpty(e.currentTarget.dataset.index)){ |
|
|
|
var item = this.data.cityList[e.currentTarget.dataset.index] |
|
|
|
var flag = false |
|
|
|
for (let index = 0; index < this.data.cityList.length; index++) { |
|
|
|
if(this.data.cityList[index].cityId == item.cityId){ |
|
|
|
for (let index = 0; index < this.data.historyList.length; index++) { |
|
|
|
if(this.data.historyList[index].cityId == item.cityId){ |
|
|
|
flag = true |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
if(!flag){ |
|
|
|
hotList.push(item) |
|
|
|
storage.put('ztb-hot-list', JSON.stringify(hotList)) |
|
|
|
if(this.data.historyList.length >= 4){ |
|
|
|
this.data.historyList.splice(3, 1) |
|
|
|
} |
|
|
|
this.data.historyList.unshift(item) |
|
|
|
storage.put('ztb-history-list', JSON.stringify(this.data.historyList)) |
|
|
|
this.setData({ historyList: this.data.historyList }) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
clearHistory: function(){ |
|
|
|
storage.remove('ztb-history-list') |
|
|
|
this.setData({ historyList: [] }) |
|
|
|
}, |
|
|
|
onUnload: function(){ |
|
|
|
event.remove('EventMessage', this) |
|
|
|
}, |
|
|
|
|