Commit 213ecffc by 张立顺

feat 功能修复

1 parent f8d38454
...@@ -18,7 +18,7 @@ export const appId = 'wx570d9331f9ace0bd' ...@@ -18,7 +18,7 @@ export const appId = 'wx570d9331f9ace0bd'
* 4预发布 * 4预发布
* 5cdptest * 5cdptest
*/ */
let index = 1 let index = 2
const accountInfo = wx.getAccountInfoSync() const accountInfo = wx.getAccountInfoSync()
const systemInfo = wx.getSystemInfoSync() const systemInfo = wx.getSystemInfoSync()
const envName = accountInfo.miniProgram.envVersion const envName = accountInfo.miniProgram.envVersion
......
...@@ -183,49 +183,23 @@ Component({ ...@@ -183,49 +183,23 @@ Component({
this.getList(true) this.getList(true)
}, },
choose(e) { choose(e) {
let { item, index } = e.currentTarget.dataset let { index } = e.currentTarget.dataset
let { active } = item
let { storeRangeList } = this.data let { storeRangeList } = this.data
if (index > 0) { storeRangeList = (storeRangeList || []).map((val, i) => {
let target = `storeRangeList[${index}].active` val.active = i === index
this.setData( return val
{ })
[target]: !active, this.setData({ storeRangeList }, () => {
'storeRangeList[0].active': false this.setSelectedData()
}, })
() => {
this.setSelectedData()
}
)
} else {
if (!active) {
storeRangeList.map(val => {
return (val.active = false)
})
storeRangeList[0].active = true
}
this.setData({ storeRangeList }, () => {
this.setSelectedData()
})
}
}, },
setSelectedData() { setSelectedData() {
let { storeRangeList, selectedData } = this.data let { storeRangeList } = this.data
let arr = [] let selected = (storeRangeList || []).find(v => v.active && v.merchantId)
// 已选的未分页加载出的数据置为选中状态
let selectedArr = wx.$util.arrayUnique(
selectedData.concat(storeRangeList),
'merchantId'
)
selectedArr.forEach(val => {
if (val.active && val.merchantId) arr.push(val)
})
// if (!arr?.length) storeRangeList[0].active = true
this.setData({ this.setData({
selectedData: arr, // 选择全部清除已选的门店数据 selectedData: selected ? [selected] : [],
storeRangeList storeRangeList
}) })
console.log(selectedData, 'selectedData')
}, },
hidePopup() { hidePopup() {
this.triggerEvent('cancel') this.triggerEvent('cancel')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!