|
|
|
@ -1,4 +1,3 @@ |
|
|
|
|
const address = require('../../utils/address.js') |
|
|
|
|
const district = require('../../utils/address_data.js') |
|
|
|
|
|
|
|
|
|
Page({ |
|
|
|
@ -15,25 +14,27 @@ Page({ |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
bindChangeProvince: function(e) { |
|
|
|
|
var that = this |
|
|
|
|
var p = this.data.arrayProvince[e.detail.value] |
|
|
|
|
var arrayCity = district.cities(p) |
|
|
|
|
var c = arrayCity[0] |
|
|
|
|
|
|
|
|
|
this.setData({ |
|
|
|
|
indexProvince: e.detail.value, |
|
|
|
|
arrayCity: arrayCity, |
|
|
|
|
arrayCounty: district.counties(p,c) |
|
|
|
|
district.cities(p, function(arrayCity){ |
|
|
|
|
that.setData({arrayCity: arrayCity}) |
|
|
|
|
district.counties(p, arrayCity[0], function(arrayCounty){ |
|
|
|
|
that.setData({arrayCounty: arrayCounty}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
this.setData({indexProvince: e.detail.value}) |
|
|
|
|
wx.setStorageSync('currentDistrict', [this.data.indexProvince, this.data.indexCity, this.data.indexCounty]) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
bindChangeCity: function(e) { |
|
|
|
|
var that = this |
|
|
|
|
var p = this.data.arrayProvince[this.data.indexProvince] |
|
|
|
|
var c = this.data.arrayCity[e.detail.value] |
|
|
|
|
this.setData({ |
|
|
|
|
indexCity: e.detail.value, |
|
|
|
|
arrayCounty: district.counties(p,c) |
|
|
|
|
district.counties(p, c, function(arrayCounty){ |
|
|
|
|
that.setData({arrayCounty: arrayCounty}) |
|
|
|
|
}) |
|
|
|
|
this.setData({indexCity: e.detail.value}) |
|
|
|
|
wx.setStorageSync('currentDistrict', [this.data.indexProvince, this.data.indexCity, this.data.indexCounty]) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -64,18 +65,21 @@ Page({ |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
onLoad (params) { |
|
|
|
|
var that = this |
|
|
|
|
var currentDistrict = wx.getStorageSync('currentDistrict') || [1, 0, 0] |
|
|
|
|
var arrayProvince = district.provinces() |
|
|
|
|
var arrayCity = district.cities(arrayProvince[currentDistrict[0]]) |
|
|
|
|
var arrayCounty = district.counties(arrayProvince[currentDistrict[0]], arrayCity[currentDistrict[1]]) |
|
|
|
|
district.cities(arrayProvince[currentDistrict[0]], function(arrayCity){ |
|
|
|
|
that.setData({arrayCity: arrayCity}) |
|
|
|
|
district.counties(arrayProvince[currentDistrict[0]], arrayCity[currentDistrict[1]], function(arrayCounty){ |
|
|
|
|
that.setData({arrayCounty: arrayCounty}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
this.setData({ |
|
|
|
|
indexProvince: currentDistrict[0], |
|
|
|
|
indexCity: currentDistrict[1], |
|
|
|
|
indexCounty: currentDistrict[2], |
|
|
|
|
arrayProvince: arrayProvince, |
|
|
|
|
arrayCity: arrayCity, |
|
|
|
|
arrayCounty: arrayCounty, |
|
|
|
|
detailAddress: wx.getStorageSync('detailAddress'), |
|
|
|
|
receiverName: wx.getStorageSync('receiverName'), |
|
|
|
|
receiverMobile: wx.getStorageSync('receiverMobile') |
|
|
|
|