|
|
@ -117,23 +117,53 @@ Page({ |
|
|
|
} |
|
|
|
// 如果不是第一层级,要往下加children
|
|
|
|
let options1 = this.data.options1 |
|
|
|
this.recursionMethod(options1, this.data.pid, res.data) |
|
|
|
let arr = this.recursionMethod(options1, this.data.pid, res.data) |
|
|
|
this.setData({ |
|
|
|
options1: arr, |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
recursionMethod(arr, pid, children) { |
|
|
|
arr.forEach((item) => { |
|
|
|
if (item.id === pid) { |
|
|
|
item.children = children |
|
|
|
wx.hideLoading() |
|
|
|
} |
|
|
|
console.log('item.children', item.children) |
|
|
|
if (item.children) { |
|
|
|
console.log('掉children') |
|
|
|
this.recursionMethod(item.children, this.data.pid, children) |
|
|
|
} else { |
|
|
|
if (item.id === pid) { |
|
|
|
console.log('值相等') |
|
|
|
item.children = children |
|
|
|
wx.hideLoading() |
|
|
|
} |
|
|
|
} |
|
|
|
// if (item.id === pid) {
|
|
|
|
// console.log('值相等')
|
|
|
|
// item.children = children
|
|
|
|
// wx.hideLoading()
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// item.children = [
|
|
|
|
// {
|
|
|
|
// label: '11',
|
|
|
|
// value: '1111',
|
|
|
|
// id: '11111111111111111',
|
|
|
|
// },
|
|
|
|
// ]
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (item.children) {
|
|
|
|
// console.log('掉children')
|
|
|
|
// this.recursionMethod(item.children, this.data.pid, children)
|
|
|
|
// }
|
|
|
|
// if (item.id === pid) {
|
|
|
|
// console.log('值相等')
|
|
|
|
// item.children = children
|
|
|
|
// wx.hideLoading()
|
|
|
|
// }
|
|
|
|
}) |
|
|
|
this.setData({ |
|
|
|
options1: arr, |
|
|
|
}) |
|
|
|
console.log('options1---', this.data.options1) |
|
|
|
return arr |
|
|
|
}, |
|
|
|
// 动态加载级联选择器
|
|
|
|
onLoadOptions(e) { |
|
|
|