Commit e83a06ed by 赵雅纹

Merge branch 'fixbug-ZYW' into 'dev_7.1.0'

地址库变更

See merge request !159
parents 813d7b57 84e14c8c
......@@ -64,19 +64,25 @@ wxService.page({
},
init() {
wxService.getC1().then((c1) => {
console.log('C1',c1)
return wxService.Promise.all([wxService.Promise.resolve(c1), wxService.getC2ByC1('北京'), wxService.getC3ByC2('北京北京市')])
}).then(res => {
console.log(res)
const citys = res.map(item => {
return [...item]
})
this.setData({
citys
})
console.log('000000000------', citys)
let cityData = city.default;
let province = []
let cityList = []
let district = []
cityData.forEach((item)=>{
province.push(item.value)
})
cityData[0].children.forEach((cityItem) => {
cityList.push(cityItem.value)
cityItem.children.forEach((districtItem)=>{
district.push(districtItem.value)
})
})
this.setData({
citys: [province, cityList, district]
})
console.log('++++', this.data.citys)
},
// 通过地址id查询
......@@ -100,18 +106,18 @@ wxService.page({
isSelect: data.type,
cityView: data.province + ' ' + data.city + ' ' + data.district
})
wxService.getC1().then((c1) => {
return wxService.Promise.all([wxService.Promise.resolve(c1), wxService.getC2ByC1('北京'), wxService.getC3ByC2('北京北京市')])
}).then(res => {
// wxService.getC1().then((c1) => {
// return wxService.Promise.all([wxService.Promise.resolve(c1), wxService.getC2ByC1('北京'), wxService.getC3ByC2('北京北京市')])
// }).then(res => {
const citys = res.map(item => {
return [...item]
})
this.setData({
citys
})
// const citys = res.map(item => {
// return [...item]
// })
// this.setData({
// citys
// })
})
// })
}
}).finally(() => {
})
......@@ -120,7 +126,6 @@ wxService.page({
bindMultiPickerChange(e) {
const citys = this.data.citys
const multiIndex = e.detail.value
console.log(citys)
if (citys) {
const cityView = [citys[0][multiIndex[0]], citys[1][multiIndex[1]], citys[2][multiIndex[2]]].join(' ')
......@@ -136,35 +141,48 @@ wxService.page({
},
bindMultiPickerColumnChange(e) {
console.log(e)
console.log('0000',e)
const detail = e.detail
const index = detail.value
let cityName = ''
let cityData = city.default
let province = []
let cityList = []
let district = []
switch (detail.column) {
case 0:
cityName = this.data.citys[0][index]
this.data.selectCityName[0] = cityName
wxService.getC2ByC1(cityName)
.then(item => {
let c2 = [...item]
this.data.selectCityName[1] = c2[0]
return wxService.Promise.all([wxService.Promise.resolve(item), wxService.getC3ByC2(this.data.selectCityName.join(''))])
}).then((res) => {
this.setData({
'citys[1]': [...res[0]],
'citys[2]': [...res[1]]
cityData.forEach((item)=>{
if(item.value == cityName){
item.children.forEach((cityItem)=>{
cityList.push(cityItem.value)
cityItem.children.forEach((districtItem) => {
district.push(districtItem.value)
})
})
})
}
})
this.setData({
'citys[1]': cityList,
'citys[2]': district
})
break
case 1:
cityName = this.data.citys[1][index]
this.data.selectCityName[1] = cityName
wxService.getC3ByC2(this.data.selectCityName.join(''))
.then(item => {
this.setData({
'citys[2]': [...item]
cityData.forEach((item) => {
item.children.forEach((cityItem) => {
if (cityName == cityItem.value) {
cityItem.children.forEach((districtItem) => {
district.push(districtItem.value)
})
}
})
})
this.setData({
'citys[2]': [...district]
})
break
default:
break
......
// pages/confirmOrder/confirmOrder.js
const wxService = require('../../utils/wxService')
const app = getApp()
const city = require('../../utils/city')
const utils = require('../../utils/util')
wxService.page({
......@@ -168,7 +169,9 @@ wxService.page({
userId: memberId,
name: e.detail.value.name,
phone: e.detail.value.phone,
fullArea: this.data.cityView,
province: this.data.params.province,
city: this.data.params.city,
district: this.data.params.district,
address: e.detail.value.address,
type: this.data.isSelect ? 1 : 0
}
......@@ -196,65 +199,87 @@ wxService.page({
},
initCitys() {
wxService.getC1().then((c1) => {
return wxService.Promise.all([wxService.Promise.resolve(c1), wxService.getC2ByC1('北京'), wxService.getC3ByC2('北京北京市')])
}).then(res => {
const citys = res.map(item => {
return [...item]
})
this.setData({
citys
let cityData = city.default;
let province = []
let cityList = []
let district = []
cityData.forEach((item) => {
province.push(item.value)
})
cityData[0].children.forEach((cityItem) => {
cityList.push(cityItem.value)
cityItem.children.forEach((districtItem) => {
district.push(districtItem.value)
})
})
this.setData({
citys: [province, cityList, district]
})
},
bindMultiPickerChange(e) {
const citys = this.data.citys
const multiIndex = e.detail.value
if (citys) {
const cityView = [citys[0][multiIndex[0]], citys[1][multiIndex[1]], citys[2][multiIndex[2]]].join(' ')
this.setData({
multiIndex,
cityView
}, () => {
console.log('================0', this.data.cityView, this.data.multiIndex)
cityView,
'params.province': citys[0][multiIndex[0]],
'params.city': citys[1][multiIndex[1]],
'params.district': citys[2][multiIndex[2]]
})
}
},
bindMultiPickerColumnChange(e) {
console.log('0000', e)
const detail = e.detail
const index = detail.value
let cityName = ''
let cityData = city.default
let province = []
let cityList = []
let district = []
switch (detail.column) {
case 0:
cityName = this.data.citys[0][index]
this.data.selectCityName[0] = cityName
wxService.getC2ByC1(cityName)
.then(item => {
let c2 = [...item]
this.data.selectCityName[1] = c2[0]
return wxService.Promise.all([wxService.Promise.resolve(item), wxService.getC3ByC2(this.data.selectCityName.join(''))])
}).then((res) => {
this.setData({
'citys[1]': [...res[0]],
'citys[2]': [...res[1]]
cityData.forEach((item) => {
if (item.value == cityName) {
item.children.forEach((cityItem) => {
cityList.push(cityItem.value)
cityItem.children.forEach((districtItem) => {
district.push(districtItem.value)
})
})
})
}
})
this.setData({
'citys[1]': cityList,
'citys[2]': district
})
break
case 1:
cityName = this.data.citys[1][index]
this.data.selectCityName[1] = cityName
wxService.getC3ByC2(this.data.selectCityName.join(''))
.then(item => {
this.setData({
'citys[2]': [...item]
})
cityData.forEach((item) => {
item.children.forEach((cityItem) => {
if (cityName == cityItem.value) {
cityItem.children.forEach((districtItem) => {
district.push(districtItem.value)
})
}
})
})
this.setData({
'citys[2]': [...district]
})
break
default:
break
}
},
handelChangeSelectVip() {
this.setData({
isSelect: !this.data.isSelect
......@@ -408,6 +433,7 @@ wxService.page({
_defalutAddress = hasDefalut
} else {
data.forEach(item => {
item.fullArea = item.province + ' ' + item.city + ' ' + item.district
if (item.type == 1) {
_defalutAddress = item
}
......@@ -429,10 +455,10 @@ wxService.page({
}
}
}).finally(() => {
})
})
},
//获取微信地址
chooseWxAddress() {
chooseWxAddress() {
const { memberId } = wx.getStorageSync('_baseUserInfo')
wx.chooseAddress({
success: (res) => {
......
......@@ -26,7 +26,7 @@ wxService.page({
handelCheckShopAddress(e) {
const index = e.currentTarget.dataset.index
const item = this.data.addressList[index]
item.fullArea = item.province + ' ' + item.city + ' ' + item.district
wx.setStorageSync('_defalutAddress', item)
let pages = getCurrentPages();
let beforePage = pages[pages.length - 2];
......
......@@ -22,7 +22,7 @@
<view class="name">
{{item.name}} {{item.phone}}
</view>
<view class="address-detail">{{item.fullArea}} {{item.address}}</view>
<view class="address-detail">{{item.province}} {{item.city}} {{item.district}} {{item.address}}</view>
<view
class="default-address"
bindtap="settingDefalutAddress"
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -917,12 +917,11 @@ class WXService extends Http {
}
getCitysEnterty() {
const citys = citysData
const citys = citysData.default
console.log('8888', citys)
let list = {}
if (this.citysEntertys) {
list = this.citysEntertys
console.log('list',list)
} else {
for (const key in citys) {
if (citys.hasOwnProperty(key)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment