Commit bb85723f by zhangxw

侧边栏切换门店分页 去重逻辑修复

1 parent a0154942
...@@ -140,9 +140,12 @@ Component({ ...@@ -140,9 +140,12 @@ Component({
scrollonReachBottom() { scrollonReachBottom() {
this.searchEvent() this.searchEvent()
}, },
unique(arr) { uniqueByProperty(arr, prop) {
const res = new Map() const map = new Map();
return arr.filter((a) => res.set(a.merchantId, 1)) arr.forEach(obj => {
map.set(obj[prop], obj);
});
return Array.from(map.values());
}, },
searchEvent(isReset = false) { searchEvent(isReset = false) {
let { searchValue, selectedMerchantId, searchSelectIndex, pageNum, nothing } = this.data let { searchValue, selectedMerchantId, searchSelectIndex, pageNum, nothing } = this.data
...@@ -169,7 +172,7 @@ Component({ ...@@ -169,7 +172,7 @@ Component({
tempList.push({merchantId: userInfo?.shopMerchantId, merchantName: userInfo?.shopMerchantName}); tempList.push({merchantId: userInfo?.shopMerchantId, merchantName: userInfo?.shopMerchantName});
} }
} }
tempList = this.unique(tempList) tempList = this.uniqueByProperty(tempList, 'merchantId')
tempList.forEach(v => v.actived = (userInfo?.shopMerchantId === v.merchantId) || (!userInfo?.shopMerchantId && !v.merchantId)) tempList.forEach(v => v.actived = (userInfo?.shopMerchantId === v.merchantId) || (!userInfo?.shopMerchantId && !v.merchantId))
this.setData({ this.setData({
storeRangeList: tempList, storeRangeList: tempList,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!