地址减少call API 的次数。。修复一个只选择province是会出现的bug:form submit 没有设置storage

wechat_user_type
Ge Hao 8 years ago
parent da77b81403
commit 0b4542aa14
  1. 10
      pages/address/address.js
  2. 33
      pages/cart/cart.js

@ -17,9 +17,9 @@ Page({
var that = this
var p = this.data.arrayProvince[e.detail.value]
district.cities(p, function(arrayCity){
that.setData({arrayCity: arrayCity})
that.setData({arrayCity: arrayCity, indexCity: 0})
district.counties(p, arrayCity[0], function(arrayCounty){
that.setData({arrayCounty: arrayCounty})
that.setData({arrayCounty: arrayCounty, indexCounty: 0})
})
})
@ -32,7 +32,7 @@ Page({
var p = this.data.arrayProvince[this.data.indexProvince]
var c = this.data.arrayCity[e.detail.value]
district.counties(p, c, function(arrayCounty){
that.setData({arrayCounty: arrayCounty})
that.setData({arrayCounty: arrayCounty, indexCounty: 0})
})
this.setData({indexCity: e.detail.value})
wx.setStorageSync('currentDistrict', [this.data.indexProvince, this.data.indexCity, this.data.indexCounty])
@ -61,6 +61,10 @@ Page({
}
wx.setStorage({key:'receiverName', data: receiverName})
wx.setStorage({key:'receiverMobile', data: receiverMobile})
wx.setStorageSync('currentDistrict', [this.data.indexProvince, this.data.indexCity, this.data.indexCounty])
var pages = getCurrentPages()
var cartPage = pages[pages.length - 2]
cartPage.setData({refreshAddress: true})
wx.navigateBack()
},

@ -5,6 +5,7 @@ var app = getApp()
Page({
data: {
refreshAddress: true,
wantToDeleteItem: '',
address: null,
cartItems: [],
@ -19,31 +20,35 @@ Page({
onShow: function (params) {
var that = this
// 判断要显示什么类型的价格
if (app.globalData.currentCustomer) {
var accountType = app.globalData.currentCustomer.account_type
this.setData({accountType: accountType})
}
var cartItems = wx.getStorageSync("cartItems")
this.setData({cartItems: cartItems || []})
this.changeCartAmount()
var detailAddress = wx.getStorageSync('detailAddress')
var receiverName = wx.getStorageSync('receiverName')
var receiverMobile = wx.getStorageSync('receiverMobile')
var address = {detail_address: detailAddress, customer_name: receiverName, customer_mobile: receiverMobile}
var districtIndex = wx.getStorageSync('currentDistrict') || [1,0,0]
address.province = district.provinces()[districtIndex[0]]
that.setData({address: address})
district.cities(address.province, function(arrayCity){
address.city = arrayCity[districtIndex[1]]
that.setData({address: address})
district.counties(address.province, address.city, function(arrayCounty){
address.county = arrayCounty[districtIndex[2]]
if (this.data.refreshAddress) {
var detailAddress = wx.getStorageSync('detailAddress')
var receiverName = wx.getStorageSync('receiverName')
var receiverMobile = wx.getStorageSync('receiverMobile')
var address = {detail_address: detailAddress, customer_name: receiverName, customer_mobile: receiverMobile}
var districtIndex = wx.getStorageSync('currentDistrict') || [1,0,0]
address.province = district.provinces()[districtIndex[0]]
that.setData({address: address, refreshAddress: false})
district.cities(address.province, function(arrayCity){
address.city = arrayCity[districtIndex[1]]
that.setData({address: address})
district.counties(address.province, address.city, function(arrayCounty){
address.county = arrayCounty[districtIndex[2]]
that.setData({address: address})
})
})
})
}
},
bindSelectCoupon: function() {

Loading…
Cancel
Save