Commit 2841c39b by 陈超

T

parent 6445b3a2
......@@ -178,10 +178,14 @@
if(p.children.length == 0) {
that.getCity(p.id, r => {
p.children = r.map(r => { return { text: r.title, id: r.area_id, children: [] } })
that.onCityChange(picker, p.children[0])
let c = p.children[0]
that.selected[1] = c.text
that.onCityChange(picker, c)
})
} else {
that.selected[1] = p.children[0].text
picker.setColumnValues(1, p.children)
that.onCityChange(picker, p.children[0])
}
},
//当选择市变化
......@@ -190,10 +194,12 @@
if(c.children.length == 0) {
that.getArea(c.id, r => {
c.children = r.map(r => { return { text: r.title, id: r.area_id } })
that.selected[2] = c.children[0].text
picker.setColumnValues(2, c.children)
that.columns = [].concat(that.columns)
})
} else {
that.selected[2] = c.children[0].text
picker.setColumnValues(2, c.children)
}
},
......@@ -202,7 +208,9 @@
that.showPicker = true
if(that.columns[0].children.length == 0) {
that.$nextTick(() => {
that.onProvinceChange(that.$refs.picker, that.columns[0])
let p = that.columns[0]
that.selected[0] = p.text
that.onProvinceChange(that.$refs.picker, p)
})
}
},
......@@ -213,7 +221,32 @@
},
onAreaChange: function(picker, values) {
let that = this
let found = that.columns.filter( r => { return r.text == values[0] })
let p = undefined
if(found.length > 0) {
p = found[0]
if(p.text != that.selected[0]) {
that.onProvinceChange(p)
return
}
} else {
that.onProvinceChange(that.columns[0])
return
}
let c = undefined
found = p.children.filter( r => { return r.text == values[1] })
if(found.length > 0) {
c = found[0]
if(c.text != that.selected[1]) {
that.onCityChange(c)
return
}
} else {
that.onCityChange(p.children[0])
return
}
that.selected[2] = values[2]
},
saveAddress: function() {
......
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