|
|
|
@ -42,23 +42,38 @@ |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
created(){ |
|
|
|
|
getRegional().then(res=>{ |
|
|
|
|
this.CHINA_REGIONS = res.return_data; |
|
|
|
|
// getRegional().then(res=>{ |
|
|
|
|
// this.CHINA_REGIONS = res.return_data; |
|
|
|
|
|
|
|
|
|
this.CHINA_REGIONS.map(item=>{ |
|
|
|
|
if(!item.childs){ |
|
|
|
|
item.childs = []; |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
// this.CHINA_REGIONS.map(item=>{ |
|
|
|
|
// if(!item.childs){ |
|
|
|
|
// item.childs = []; |
|
|
|
|
// } |
|
|
|
|
// }) |
|
|
|
|
|
|
|
|
|
this.cityArr =this.CHINA_REGIONS[0].childs; |
|
|
|
|
this.districtArr = this.CHINA_REGIONS[0].childs[0].childs; |
|
|
|
|
// console.log(res.return_data,11) |
|
|
|
|
}) |
|
|
|
|
// this.cityArr =this.CHINA_REGIONS[0].childs; |
|
|
|
|
// this.districtArr = this.CHINA_REGIONS[0].childs[0].childs; |
|
|
|
|
// // console.log(res.return_data,11) |
|
|
|
|
// }) |
|
|
|
|
}, |
|
|
|
|
watch:{ |
|
|
|
|
defaultRegion:{ |
|
|
|
|
handler(region,oldRegion){ |
|
|
|
|
async handler(region,oldRegion){ |
|
|
|
|
|
|
|
|
|
await getRegional().then(res=>{ |
|
|
|
|
this.CHINA_REGIONS = res.return_data; |
|
|
|
|
this.CHINA_REGIONS.map(item=>{ |
|
|
|
|
if(!item.childs){ |
|
|
|
|
item.childs = []; |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
this.cityArr =this.CHINA_REGIONS[0].childs; |
|
|
|
|
this.districtArr = this.CHINA_REGIONS[0].childs[0].childs; |
|
|
|
|
// console.log(res.return_data,11) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(Array.isArray(region)){ |
|
|
|
|
// 避免传的是字面量的时候重复触发 |
|
|
|
|
oldRegion = oldRegion || [] |
|
|
|
@ -135,8 +150,9 @@ |
|
|
|
|
let children = this.CHINA_REGIONS |
|
|
|
|
for(let i=0;i<3;i++){ |
|
|
|
|
for(let j=0;j<children.length;j++){ |
|
|
|
|
let condition = isCode?children[j].code==region.slice(0,(i+1)*2):children[j].name.includes(region[i]); |
|
|
|
|
if(condition){ |
|
|
|
|
let condition = isCode?String(children[j].code).slice(0,(i+1)*2)==region.slice(0,(i+1)*2):children[j].name.includes(region[i]); |
|
|
|
|
// console.log(String(children[j].code).slice(0,(i+1)*2),region.slice(0,(i+1)*2)) |
|
|
|
|
if(condition){ |
|
|
|
|
// 匹配成功进行赋值 |
|
|
|
|
// console.log(i,j,children.length-1); |
|
|
|
|
children = children[j].childs; |
|
|
|
|