|
|
@ -150,23 +150,25 @@ |
|
|
|
this.$emit('getRegion',address) |
|
|
|
this.$emit('getRegion',address) |
|
|
|
}, |
|
|
|
}, |
|
|
|
handleDefaultRegion(region){ |
|
|
|
handleDefaultRegion(region){ |
|
|
|
// console.log(region) |
|
|
|
console.log(region,"region") |
|
|
|
const isCode = !Array.isArray(region) |
|
|
|
const isCode = !Array.isArray(region) |
|
|
|
this.isInitMultiArray = false; |
|
|
|
this.isInitMultiArray = false; |
|
|
|
let children = this.CHINA_REGIONS |
|
|
|
let children = this.CHINA_REGIONS; |
|
|
|
|
|
|
|
let num =0; |
|
|
|
for(let i=0;i<3;i++){ |
|
|
|
for(let i=0;i<3;i++){ |
|
|
|
for(let j=0;j<children.length;j++){ |
|
|
|
for(let j=0;j<children.length;j++){ |
|
|
|
let condition; |
|
|
|
let condition; |
|
|
|
if(i==2){ |
|
|
|
if(i==2){ |
|
|
|
condition = isCode?String(children[j].code).slice(0)==region.slice(0):children[j].name.includes(region[i]); |
|
|
|
condition = isCode?String(children[j].code).slice(0)==region.slice(0):children[j].name.includes(region[i]); |
|
|
|
// console.log(String(children[j].code).slice(0),region.slice(0)) |
|
|
|
console.log(String(children[j].code).slice(0),region.slice(0)) |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
condition = isCode?String(children[j].code).slice(0,(i+1)*2)==region.slice(0,(i+1)*2):children[j].name.includes(region[i]); |
|
|
|
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)) |
|
|
|
|
|
|
|
console.log(String(children[j].code).slice(0,(i+1)*2),region.slice(0,(i+1)*2)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(condition){ |
|
|
|
if(condition){ |
|
|
|
|
|
|
|
num++; |
|
|
|
// 匹配成功进行赋值 |
|
|
|
// 匹配成功进行赋值 |
|
|
|
// console.log(i,j,children.length-1); |
|
|
|
// console.log(i,j,children.length-1); |
|
|
|
// children = children[j].childs; |
|
|
|
// children = children[j].childs; |
|
|
@ -192,7 +194,7 @@ |
|
|
|
break; |
|
|
|
break; |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
// 首次匹配失败就用默认的初始化 |
|
|
|
// 首次匹配失败就用默认的初始化 |
|
|
|
// console.log(i,j,children.length-1); |
|
|
|
console.log(i,j,children.length-1,"匹配失败"); |
|
|
|
if(i==0 && j==(children.length-1)){ |
|
|
|
if(i==0 && j==(children.length-1)){ |
|
|
|
this.isInitMultiArray = true; |
|
|
|
this.isInitMultiArray = true; |
|
|
|
} |
|
|
|
} |
|
|
@ -201,9 +203,15 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(num == 3){ |
|
|
|
let address = [this.CHINA_REGIONS[this.multiIndex[0]],this.cityArr[this.multiIndex[1]],this.districtArr[this.multiIndex[2]]]; |
|
|
|
let address = [this.CHINA_REGIONS[this.multiIndex[0]],this.cityArr[this.multiIndex[1]],this.districtArr[this.multiIndex[2]]]; |
|
|
|
this.$emit('getRegion',address) |
|
|
|
this.$emit('getRegion',address) |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
this.$emit('failureRegion') |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|