Commit 0ff2cb5a by 陈超

T

parent 889a4d9b
...@@ -175,8 +175,11 @@ ...@@ -175,8 +175,11 @@
let that = this let that = this
that.showPicker = true that.showPicker = true
if(that.selected.length == 0) { if(that.selected.length == 0) {
let p = that.columns[0]
if(p.children.length == 0) {
that.loading = true that.loading = true
that.getCity(that.columns[0].id) that.getCity(p.id)
}
} }
}, },
onAreaConfirm: function(r, values) { onAreaConfirm: function(r, values) {
...@@ -194,15 +197,44 @@ ...@@ -194,15 +197,44 @@
//Helper //Helper
getCity: function(id) { getCity: function(id) {
let that = this
$.ajax({ $.ajax({
type:'POST', type:'POST',
url:"{:U('home/User/getAreaList')}", url:"{:U('home/User/getAreaList')}",
data: { id: id }, data: { id: id },
dataType:'json', dataType:'json',
success:function(res){ success:function(res){
console.log(res) that.loading = false
if(res.status == 1) {
let found = that.columns.filter(r => { return r.id == id })
if(found.length > 0) {
let province = found[0]
province.children = res.data.map( r => { text: r.title, id: r.area_id, children: [] })
if(province.children.length > 0) {
that.getArea(province, province.children[0].id)
} }
}); }
}
}
})
},
getArea: function(p, id) {
let that = this
$.ajax({
type:'POST',
url:"{:U('home/User/getAreaList')}",
data:{ id: id },
dataType:'json',
success:function(res){
if(res.status == 1) {
let found = p.children.filter( r => { return r.id == id })
if(found.length > 0) {
let city = found[0]
city.children = res.data.map( r => { text: r.title, id: r.area_id })
}
}
}
})
} }
} }
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment