|
|
|
|
|
|
|
|
cityCurrent: -1, |
|
|
cityCurrent: -1, |
|
|
districtCurrent: -1, |
|
|
districtCurrent: -1, |
|
|
params: {}, // 筛选条件 |
|
|
params: {}, // 筛选条件 |
|
|
obj: { |
|
|
|
|
|
provinceName: '湖南省', |
|
|
|
|
|
cityName: '株洲市', |
|
|
|
|
|
districtName: '芦淞区' |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
obj: {} |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* 生命周期函数--监听页面加载 |
|
|
* 生命周期函数--监听页面加载 |
|
|
*/ |
|
|
*/ |
|
|
onLoad: function (options) { |
|
|
onLoad: function (options) { |
|
|
this.getCityTreeList() |
|
|
|
|
|
|
|
|
// this.getCityTreeList() |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|
|
|
|
|
|
// 隐藏返回图标 |
|
|
// 隐藏返回图标 |
|
|
wx.hideHomeButton(); |
|
|
wx.hideHomeButton(); |
|
|
let positionParams = wx.getStorageSync('positionParams') |
|
|
let positionParams = wx.getStorageSync('positionParams') |
|
|
if(Object.keys(positionParams).length) { |
|
|
|
|
|
let params = this.data.params |
|
|
|
|
|
params.provinceCode = positionParams.provinceCode |
|
|
|
|
|
params.cityCode = positionParams.cityCode |
|
|
|
|
|
params.districtCode = positionParams.districtCode |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
params, |
|
|
|
|
|
provinceCurrent: positionParams.provinceCurrent, |
|
|
|
|
|
provinceOptions: positionParams.provinceOptions, |
|
|
|
|
|
cityCurrent: positionParams.cityCurrent, |
|
|
|
|
|
cityOptions: positionParams.cityOptions, |
|
|
|
|
|
districtCurrent: positionParams.districtCurrent, |
|
|
|
|
|
districtOptions: positionParams.districtOptions |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.getUserLocation() |
|
|
|
|
|
|
|
|
let options = this.data.provinceOptions |
|
|
|
|
|
if(options.length === 0) { |
|
|
|
|
|
let provinceOptions = wx.getStorageSync('provinceOptions') |
|
|
|
|
|
if(provinceOptions.length) { |
|
|
|
|
|
this.setData({provinceOptions}) |
|
|
|
|
|
if(Object.keys(positionParams).length) { |
|
|
|
|
|
let params = this.data.params |
|
|
|
|
|
params.provinceCode = positionParams.provinceCode |
|
|
|
|
|
params.cityCode = positionParams.cityCode |
|
|
|
|
|
params.districtCode = positionParams.districtCode |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
params, |
|
|
|
|
|
provinceCurrent: positionParams.provinceCurrent, |
|
|
|
|
|
cityCurrent: positionParams.cityCurrent, |
|
|
|
|
|
cityOptions: positionParams.cityOptions, |
|
|
|
|
|
districtCurrent: positionParams.districtCurrent, |
|
|
|
|
|
districtOptions: positionParams.districtOptions |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.getUserLocation() |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
this.getCityTreeList().then(res=> { |
|
|
|
|
|
if(Object.keys(positionParams).length) { |
|
|
|
|
|
let params = this.data.params |
|
|
|
|
|
params.provinceCode = positionParams.provinceCode |
|
|
|
|
|
params.cityCode = positionParams.cityCode |
|
|
|
|
|
params.districtCode = positionParams.districtCode |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
params, |
|
|
|
|
|
provinceCurrent: positionParams.provinceCurrent, |
|
|
|
|
|
cityCurrent: positionParams.cityCurrent, |
|
|
|
|
|
cityOptions: positionParams.cityOptions, |
|
|
|
|
|
districtCurrent: positionParams.districtCurrent, |
|
|
|
|
|
districtOptions: positionParams.districtOptions |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.getUserLocation() |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
/** |
|
|
/** |
|
|
|
|
|
|
|
|
let provinceOptions = this.data.provinceOptions |
|
|
let provinceOptions = this.data.provinceOptions |
|
|
let provinceCurrent, cityCurrent, districtCurrent, cityOptions, districtOptions |
|
|
let provinceCurrent, cityCurrent, districtCurrent, cityOptions, districtOptions |
|
|
let params = this.data.params |
|
|
let params = this.data.params |
|
|
|
|
|
params.provinceCode = obj.provinceCode |
|
|
|
|
|
params.cityCode = obj.cityCode |
|
|
|
|
|
params.districtCode = obj.districtCode |
|
|
if(provinceOptions.length) { |
|
|
if(provinceOptions.length) { |
|
|
provinceOptions.forEach((item,index)=> { |
|
|
provinceOptions.forEach((item,index)=> { |
|
|
if(item.citycode === obj.provinceCode) { |
|
|
if(item.citycode === obj.provinceCode) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 获取省市区 */ |
|
|
/* 获取省市区 */ |
|
|
getCityTreeList() { |
|
|
getCityTreeList() { |
|
|
getCityTree().then(res=> { |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
provinceOptions: res.data |
|
|
|
|
|
|
|
|
return new Promise((resolve)=> { |
|
|
|
|
|
getCityTree().then(res=> { |
|
|
|
|
|
wx.setStorage({ |
|
|
|
|
|
key: 'provinceOptions', |
|
|
|
|
|
data: res.data |
|
|
|
|
|
}) |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
provinceOptions: res.data |
|
|
|
|
|
}) |
|
|
|
|
|
resolve(res) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
key: 'location', |
|
|
key: 'location', |
|
|
data: res |
|
|
data: res |
|
|
}) |
|
|
}) |
|
|
let latLog = {} |
|
|
|
|
|
latLog.lat = res.latitude |
|
|
|
|
|
latLog.lng = res.longitude |
|
|
|
|
|
getCityNameCode(latLog).then(res=> { |
|
|
|
|
|
|
|
|
let latlng = {} |
|
|
|
|
|
latlng.lat = res.latitude |
|
|
|
|
|
latlng.lng = res.longitude |
|
|
|
|
|
getCityNameCode(latlng).then(res=> { |
|
|
let cityObj = res.data |
|
|
let cityObj = res.data |
|
|
this.setData({cityObj}) |
|
|
this.setData({cityObj}) |
|
|
this.getListByName(cityObj) |
|
|
this.getListByName(cityObj) |
|
|
|
|
|
|
|
|
positionParams.provinceCurrent = this.data.provinceCurrent |
|
|
positionParams.provinceCurrent = this.data.provinceCurrent |
|
|
positionParams.cityCurrent = this.data.cityCurrent |
|
|
positionParams.cityCurrent = this.data.cityCurrent |
|
|
positionParams.districtCurrent = this.data.districtCurrent |
|
|
positionParams.districtCurrent = this.data.districtCurrent |
|
|
positionParams.provinceOptions = this.data.provinceOptions |
|
|
|
|
|
positionParams.cityOptions = this.data.cityOptions |
|
|
positionParams.cityOptions = this.data.cityOptions |
|
|
positionParams.districtOptions = this.data.districtOptions |
|
|
positionParams.districtOptions = this.data.districtOptions |
|
|
wx.setStorage({ |
|
|
wx.setStorage({ |