mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2025-12-17 16:35:53 +08:00
perf: ⚡ 优化地区选择器代码
This commit is contained in:
@@ -75,13 +75,21 @@ export default {
|
|||||||
if (res.result.length && val.id !== 0) {
|
if (res.result.length && val.id !== 0) {
|
||||||
this.chiosend[index] = val
|
this.chiosend[index] = val
|
||||||
}
|
}
|
||||||
|
else if(!res.result.length){
|
||||||
|
this.chiosend[index] = val
|
||||||
|
}
|
||||||
this.data[level] = res.result;
|
this.data[level] = res.result;
|
||||||
if (level == 'city') {
|
if (level == 'city') {
|
||||||
this.data.area = []
|
this.data.area = []
|
||||||
this.data.street = []
|
this.data.street = []
|
||||||
|
this.chiosend.splice(1, 3, "","","");
|
||||||
}
|
}
|
||||||
if (level == 'area') {
|
if (level == 'area') {
|
||||||
this.data.street = []
|
this.data.street = []
|
||||||
|
this.chiosend.splice(2, 2, "","");
|
||||||
|
}
|
||||||
|
if (level == 'street') {
|
||||||
|
this.chiosend.splice(3, 1, "");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,16 +72,24 @@ export default {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
API_Setup.getChildRegion(val.id).then((res) => {
|
API_Setup.getChildRegion(val.id).then((res) => {
|
||||||
if ( val.id !== 0) {
|
if (res.result.length && val.id !== 0) {
|
||||||
|
this.chiosend[index] = val
|
||||||
|
}
|
||||||
|
else if(!res.result.length){
|
||||||
this.chiosend[index] = val
|
this.chiosend[index] = val
|
||||||
}
|
}
|
||||||
this.data[level] = res.result;
|
this.data[level] = res.result;
|
||||||
if (level == 'city') {
|
if (level == 'city') {
|
||||||
this.data.area = []
|
this.data.area = []
|
||||||
this.data.street = []
|
this.data.street = []
|
||||||
|
this.chiosend.splice(1, 3, "","","");
|
||||||
}
|
}
|
||||||
if (level == 'area') {
|
if (level == 'area') {
|
||||||
this.data.street = []
|
this.data.street = []
|
||||||
|
this.chiosend.splice(2, 2, "","");
|
||||||
|
}
|
||||||
|
if (level == 'street') {
|
||||||
|
this.chiosend.splice(3, 1, "");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,13 +75,21 @@ export default {
|
|||||||
if (res.result.length && val.id !== 0) {
|
if (res.result.length && val.id !== 0) {
|
||||||
this.chiosend[index] = val
|
this.chiosend[index] = val
|
||||||
}
|
}
|
||||||
|
else if(!res.result.length){
|
||||||
|
this.chiosend[index] = val
|
||||||
|
}
|
||||||
this.data[level] = res.result;
|
this.data[level] = res.result;
|
||||||
if (level == 'city') {
|
if (level == 'city') {
|
||||||
this.data.area = []
|
this.data.area = []
|
||||||
this.data.street = []
|
this.data.street = []
|
||||||
|
this.chiosend.splice(1, 3, "","","");
|
||||||
}
|
}
|
||||||
if (level == 'area') {
|
if (level == 'area') {
|
||||||
this.data.street = []
|
this.data.street = []
|
||||||
|
this.chiosend.splice(2, 2, "","");
|
||||||
|
}
|
||||||
|
if (level == 'street') {
|
||||||
|
this.chiosend.splice(3, 1, "");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user