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({ ...@@ -64,19 +64,25 @@ wxService.page({
}, },
init() { init() {
wxService.getC1().then((c1) => { let cityData = city.default;
console.log('C1',c1) let province = []
return wxService.Promise.all([wxService.Promise.resolve(c1), wxService.getC2ByC1('北京'), wxService.getC3ByC2('北京北京市')]) let cityList = []
}).then(res => { let district = []
console.log(res) cityData.forEach((item)=>{
const citys = res.map(item => { province.push(item.value)
return [...item] })
cityData[0].children.forEach((cityItem) => {
cityList.push(cityItem.value)
cityItem.children.forEach((districtItem)=>{
district.push(districtItem.value)
}) })
this.setData({
citys
}) })
console.log('000000000------', citys)
this.setData({
citys: [province, cityList, district]
}) })
console.log('++++', this.data.citys)
}, },
// 通过地址id查询 // 通过地址id查询
...@@ -100,18 +106,18 @@ wxService.page({ ...@@ -100,18 +106,18 @@ wxService.page({
isSelect: data.type, isSelect: data.type,
cityView: data.province + ' ' + data.city + ' ' + data.district cityView: data.province + ' ' + data.city + ' ' + data.district
}) })
wxService.getC1().then((c1) => { // wxService.getC1().then((c1) => {
return wxService.Promise.all([wxService.Promise.resolve(c1), wxService.getC2ByC1('北京'), wxService.getC3ByC2('北京北京市')]) // return wxService.Promise.all([wxService.Promise.resolve(c1), wxService.getC2ByC1('北京'), wxService.getC3ByC2('北京北京市')])
}).then(res => { // }).then(res => {
const citys = res.map(item => { // const citys = res.map(item => {
return [...item] // return [...item]
}) // })
this.setData({ // this.setData({
citys // citys
}) // })
}) // })
} }
}).finally(() => { }).finally(() => {
}) })
...@@ -120,7 +126,6 @@ wxService.page({ ...@@ -120,7 +126,6 @@ wxService.page({
bindMultiPickerChange(e) { bindMultiPickerChange(e) {
const citys = this.data.citys const citys = this.data.citys
const multiIndex = e.detail.value const multiIndex = e.detail.value
console.log(citys)
if (citys) { if (citys) {
const cityView = [citys[0][multiIndex[0]], citys[1][multiIndex[1]], citys[2][multiIndex[2]]].join(' ') const cityView = [citys[0][multiIndex[0]], citys[1][multiIndex[1]], citys[2][multiIndex[2]]].join(' ')
...@@ -136,35 +141,48 @@ wxService.page({ ...@@ -136,35 +141,48 @@ wxService.page({
}, },
bindMultiPickerColumnChange(e) { bindMultiPickerColumnChange(e) {
console.log(e) console.log('0000',e)
const detail = e.detail const detail = e.detail
const index = detail.value const index = detail.value
let cityName = '' let cityName = ''
let cityData = city.default
let province = []
let cityList = []
let district = []
switch (detail.column) { switch (detail.column) {
case 0: case 0:
cityName = this.data.citys[0][index] cityName = this.data.citys[0][index]
this.data.selectCityName[0] = cityName this.data.selectCityName[0] = cityName
wxService.getC2ByC1(cityName) cityData.forEach((item)=>{
.then(item => { if(item.value == cityName){
let c2 = [...item] item.children.forEach((cityItem)=>{
this.data.selectCityName[1] = c2[0] cityList.push(cityItem.value)
return wxService.Promise.all([wxService.Promise.resolve(item), wxService.getC3ByC2(this.data.selectCityName.join(''))]) cityItem.children.forEach((districtItem) => {
}).then((res) => { district.push(districtItem.value)
this.setData({ })
'citys[1]': [...res[0]],
'citys[2]': [...res[1]]
}) })
}
})
this.setData({
'citys[1]': cityList,
'citys[2]': district
}) })
break break
case 1: case 1:
cityName = this.data.citys[1][index] cityName = this.data.citys[1][index]
this.data.selectCityName[1] = cityName this.data.selectCityName[1] = cityName
wxService.getC3ByC2(this.data.selectCityName.join('')) cityData.forEach((item) => {
.then(item => { item.children.forEach((cityItem) => {
this.setData({ if (cityName == cityItem.value) {
'citys[2]': [...item] cityItem.children.forEach((districtItem) => {
district.push(districtItem.value)
})
}
}) })
}) })
this.setData({
'citys[2]': [...district]
})
break break
default: default:
break break
......
// pages/confirmOrder/confirmOrder.js // pages/confirmOrder/confirmOrder.js
const wxService = require('../../utils/wxService') const wxService = require('../../utils/wxService')
const app = getApp() const app = getApp()
const city = require('../../utils/city')
const utils = require('../../utils/util') const utils = require('../../utils/util')
wxService.page({ wxService.page({
...@@ -168,7 +169,9 @@ wxService.page({ ...@@ -168,7 +169,9 @@ wxService.page({
userId: memberId, userId: memberId,
name: e.detail.value.name, name: e.detail.value.name,
phone: e.detail.value.phone, 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, address: e.detail.value.address,
type: this.data.isSelect ? 1 : 0 type: this.data.isSelect ? 1 : 0
} }
...@@ -196,15 +199,22 @@ wxService.page({ ...@@ -196,15 +199,22 @@ wxService.page({
}, },
initCitys() { initCitys() {
wxService.getC1().then((c1) => { let cityData = city.default;
return wxService.Promise.all([wxService.Promise.resolve(c1), wxService.getC2ByC1('北京'), wxService.getC3ByC2('北京北京市')]) let province = []
}).then(res => { let cityList = []
const citys = res.map(item => { let district = []
return [...item] 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
}) })
this.setData({
citys: [province, cityList, district]
}) })
}, },
bindMultiPickerChange(e) { bindMultiPickerChange(e) {
...@@ -212,49 +222,64 @@ wxService.page({ ...@@ -212,49 +222,64 @@ wxService.page({
const multiIndex = e.detail.value const multiIndex = e.detail.value
if (citys) { if (citys) {
const cityView = [citys[0][multiIndex[0]], citys[1][multiIndex[1]], citys[2][multiIndex[2]]].join(' ') const cityView = [citys[0][multiIndex[0]], citys[1][multiIndex[1]], citys[2][multiIndex[2]]].join(' ')
this.setData({ this.setData({
multiIndex, multiIndex,
cityView cityView,
}, () => { 'params.province': citys[0][multiIndex[0]],
console.log('================0', this.data.cityView, this.data.multiIndex) 'params.city': citys[1][multiIndex[1]],
'params.district': citys[2][multiIndex[2]]
}) })
} }
}, },
bindMultiPickerColumnChange(e) { bindMultiPickerColumnChange(e) {
console.log('0000', e)
const detail = e.detail const detail = e.detail
const index = detail.value const index = detail.value
let cityName = '' let cityName = ''
let cityData = city.default
let province = []
let cityList = []
let district = []
switch (detail.column) { switch (detail.column) {
case 0: case 0:
cityName = this.data.citys[0][index] cityName = this.data.citys[0][index]
this.data.selectCityName[0] = cityName this.data.selectCityName[0] = cityName
wxService.getC2ByC1(cityName) cityData.forEach((item) => {
.then(item => { if (item.value == cityName) {
let c2 = [...item] item.children.forEach((cityItem) => {
this.data.selectCityName[1] = c2[0] cityList.push(cityItem.value)
return wxService.Promise.all([wxService.Promise.resolve(item), wxService.getC3ByC2(this.data.selectCityName.join(''))]) cityItem.children.forEach((districtItem) => {
}).then((res) => { district.push(districtItem.value)
this.setData({ })
'citys[1]': [...res[0]],
'citys[2]': [...res[1]]
}) })
}
})
this.setData({
'citys[1]': cityList,
'citys[2]': district
}) })
break break
case 1: case 1:
cityName = this.data.citys[1][index] cityName = this.data.citys[1][index]
this.data.selectCityName[1] = cityName this.data.selectCityName[1] = cityName
wxService.getC3ByC2(this.data.selectCityName.join('')) cityData.forEach((item) => {
.then(item => { item.children.forEach((cityItem) => {
this.setData({ if (cityName == cityItem.value) {
'citys[2]': [...item] cityItem.children.forEach((districtItem) => {
district.push(districtItem.value)
}) })
}
})
})
this.setData({
'citys[2]': [...district]
}) })
break break
default: default:
break break
} }
}, },
handelChangeSelectVip() { handelChangeSelectVip() {
this.setData({ this.setData({
isSelect: !this.data.isSelect isSelect: !this.data.isSelect
...@@ -408,6 +433,7 @@ wxService.page({ ...@@ -408,6 +433,7 @@ wxService.page({
_defalutAddress = hasDefalut _defalutAddress = hasDefalut
} else { } else {
data.forEach(item => { data.forEach(item => {
item.fullArea = item.province + ' ' + item.city + ' ' + item.district
if (item.type == 1) { if (item.type == 1) {
_defalutAddress = item _defalutAddress = item
} }
......
...@@ -26,7 +26,7 @@ wxService.page({ ...@@ -26,7 +26,7 @@ wxService.page({
handelCheckShopAddress(e) { handelCheckShopAddress(e) {
const index = e.currentTarget.dataset.index const index = e.currentTarget.dataset.index
const item = this.data.addressList[index] const item = this.data.addressList[index]
item.fullArea = item.province + ' ' + item.city + ' ' + item.district
wx.setStorageSync('_defalutAddress', item) wx.setStorageSync('_defalutAddress', item)
let pages = getCurrentPages(); let pages = getCurrentPages();
let beforePage = pages[pages.length - 2]; let beforePage = pages[pages.length - 2];
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<view class="name"> <view class="name">
{{item.name}} {{item.phone}} {{item.name}} {{item.phone}}
</view> </view>
<view class="address-detail">{{item.fullArea}} {{item.address}}</view> <view class="address-detail">{{item.province}} {{item.city}} {{item.district}} {{item.address}}</view>
<view <view
class="default-address" class="default-address"
bindtap="settingDefalutAddress" 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 { ...@@ -917,12 +917,11 @@ class WXService extends Http {
} }
getCitysEnterty() { getCitysEnterty() {
const citys = citysData const citys = citysData.default
console.log('8888', citys) console.log('8888', citys)
let list = {} let list = {}
if (this.citysEntertys) { if (this.citysEntertys) {
list = this.citysEntertys list = this.citysEntertys
console.log('list',list)
} else { } else {
for (const key in citys) { for (const key in citys) {
if (citys.hasOwnProperty(key)) { 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