You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.5 KiB

8 years ago
const address = require('../../utils/address.js')
8 years ago
const district = require('../../utils/address_data.js')
8 years ago
Page({
8 years ago
data: {
detailAddress: '',
receiverName:'',
receiverMobile:'',
8 years ago
arrayProvince: [],
indexProvince: 0,
arrayCity: [],
indexCity: 0,
arrayCounty: [],
indexCounty: 0
8 years ago
},
8 years ago
bindChangeProvince: function(e) {
var p = this.data.arrayProvince[e.detail.value]
var arrayCity = district.cities(p)
var c = arrayCity[0]
8 years ago
this.setData({
8 years ago
indexProvince: e.detail.value,
arrayCity: arrayCity,
arrayCounty:district.counties(p,c)
8 years ago
})
wx.setStorageSync('currentDistrict', [this.data.indexProvince, this.data.indexCity, this.data.indexCounty])
8 years ago
},
bindChangeCity: function(e) {
var p = this.data.arrayProvince[this.data.indexProvince]
var c = this.data.arrayCity[e.detail.value]
8 years ago
this.setData({
indexCity: e.detail.value,
arrayCounty: district.counties(p,c)
8 years ago
})
wx.setStorageSync('currentDistrict', [this.data.indexProvince, this.data.indexCity, this.data.indexCounty])
8 years ago
},
bindChangeCounty: function(e) {
var county = this.data.arrayCounty[this.data.indexCounty]
this.setData({
indexCounty: e.detail.value
8 years ago
})
wx.setStorageSync('currentDistrict', [this.data.indexProvince, this.data.indexCity, this.data.indexCounty])
8 years ago
},
8 years ago
formSubmit: function(e) {
this.setData({'detailAddress': e.detail.value.input})
wx.setStorage({key:'detailAddress', data: e.detail.value.inputDetail})
wx.setStorage({key:'receiverName', data: e.detail.value.inputName})
wx.setStorage({key:'receiverMobile', data: e.detail.value.inputMobile})
8 years ago
wx.navigateBack()
8 years ago
},
formReset: function(e) {
8 years ago
console.log('form 发生了 reset 事件')
},
onLoad (params) {
this.setData({'detailAddress': wx.getStorageSync('detailAddress'),
'receiverName': wx.getStorageSync('receiverName'),
'receiverMobile': wx.getStorageSync('receiverMobile')})
var currentDistrict = wx.getStorageSync('currentDistrict') || [0, 0, 0]
var arrayProvince = district.provinces()
this.setData({
indexProvince: currentDistrict[0],
indexCity: currentDistrict[1],
indexCounty: currentDistrict[2],
arrayProvince: arrayProvince
})
var arrayCity = district.cities(arrayProvince[currentDistrict[0]])
this.setData({arrayCity: arrayCity})
var arrayCounty = district.counties(arrayProvince[currentDistrict[0]], arrayCity[currentDistrict[1]])
this.setData({arrayCounty: arrayCounty})
8 years ago
}
})