优化修改收货地址的地区选择县时的逻辑
This commit is contained in:
parent
4169e76f53
commit
89d39117ba
@ -161,23 +161,24 @@ export default {
|
||||
console.log('省份没变,查市跟区', this.cityList)
|
||||
let newDist = this.cityList[sq];
|
||||
console.log('新的市信息', newDist);
|
||||
if (this.xsq.ad_code !== newDist.ad_code) {
|
||||
console.log('新市区跟旧市区不一直')
|
||||
if (!this.xsq || this.xsq.ad_code !== newDist.ad_code) {
|
||||
console.log('新市区跟旧市区不一致')
|
||||
this.xsq = newDist;
|
||||
this.confirmCity = newDist;
|
||||
this.getDistList(newDist, x);
|
||||
} else {
|
||||
console.log('新市区跟旧市区一直');
|
||||
console.log('新市区跟旧市区一致');
|
||||
this.confirmDist = this.defaultDist[x]
|
||||
}
|
||||
return
|
||||
}
|
||||
const res = await request(apiArr.getArea, 'POST', { parent_ad_code: this.confirmProv1.ad_code }, { silent: false });
|
||||
this.cityList = res.rows;
|
||||
let newDist;
|
||||
|
||||
this.defaultCity = res.rows;
|
||||
this.confirmCity = res.rows[0]; // 拿市的第一条区查区
|
||||
this.getDistList(newDist, x);
|
||||
this.xsq = res.rows[0]; // 初始化xsq为第一个城市
|
||||
this.getDistList(this.xsq, x);
|
||||
},
|
||||
// 获取 县/区 信息
|
||||
async getDistList(xsq, x) {
|
||||
@ -293,16 +294,18 @@ export default {
|
||||
bindChange(e) {
|
||||
console.log('[1231331], e', e);
|
||||
const { value } = e.detail;
|
||||
// // 每次切换时,根据当前点击的省过滤出所属市区,并且变化县/区
|
||||
let newCrty = this.provList[value[0]];
|
||||
console.log('新的省份信息', newCrty);
|
||||
console.log('旧的省信息', this.confirmProv1);
|
||||
|
||||
// 判断省份是否变化
|
||||
if (newCrty.ad_code === this.confirmProv1.ad_code) {
|
||||
console.log('省份信息没变');
|
||||
this.sf = false;
|
||||
} else {
|
||||
this.sf = true;
|
||||
}
|
||||
|
||||
console.log('this.cityListthis.cityList', this.cityList);
|
||||
this.confirmProv1 = newCrty
|
||||
this.getCityList(value[1], value[2])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user