组件使用
<van-area title="标题" swipe-duration="200" :area-list="reachList" @confirm="cityConfirmFn"/>
原数据格式
reachList : { province_list: {}, city_list: {}, county_list: {}, }
数据生成
- 地区码为 6 位数字,前两位代表省份,中间两位代表城市,后两位代表区县,以 0 补足 6 位。
- 省:110000
let tempObj = {}
provinceData.map((d,index)=>{ tempObj[this.notWorthAddFn('1'+(index+1))] = d.Name })
this.reachList.province_list = tempObj
let tempObj = {}
cityData.map((d,index)=>{ tempObj[this.notWorthAddFn('1'+this.pIndex+(index<9? '0'+(index+1):(index+1)))] = d.Name })
this.reachList.city_list= tempObj
let tempObj = {}
countyData.map((d,index)=>{ tempObj[this.notWorthAddFn('1'+this.pIndex+(this.cIndex<10?'0'+this.cIndex:this.cIndex)+(index<9? '0'+(index+1):(index+1)))] = d.Name })
this.reachList.county_list= tempObj
notWorthAddFn(t){
let v = 6-t.length
if(t.length < 6){
for(let o=0;o<v;o++){t = t+'0'}
}
return t
},
cityConfirmFn(o){
this.purseOpt.r_prov = o[0].name
this.purseOpt.r_city = o[1].name
this.purseOpt.r_area = o[2].name
let cityStr = ''
o.map((d,di)=>{
cityStr = cityStr+(di=='0'?'':'-')+d.name
});
this.reachCity = cityStr;
this.reachCitySelSta = false
},