|
|
@ -530,14 +530,15 @@ Page({ |
|
|
// 按品种分类存储商品数据
|
|
|
// 按品种分类存储商品数据
|
|
|
const categorizedGoods = this.data.categorizedGoods || {}; |
|
|
const categorizedGoods = this.data.categorizedGoods || {}; |
|
|
const categories = this.data.categories; |
|
|
const categories = this.data.categories; |
|
|
|
|
|
const selectedCategory = this.data.selectedCategory; |
|
|
|
|
|
|
|
|
// 重置所有分类的商品列表
|
|
|
|
|
|
categories.forEach(cat => { |
|
|
categories.forEach(cat => { |
|
|
if (cat === '全部') { |
|
|
if (cat === '全部') { |
|
|
categorizedGoods[cat] = updatedGoods; |
|
|
categorizedGoods[cat] = updatedGoods; |
|
|
|
|
|
} else if (cat === selectedCategory) { |
|
|
|
|
|
categorizedGoods[cat] = updatedGoods.filter(item => item.isAd || !item.category || item.category === cat); |
|
|
} else { |
|
|
} else { |
|
|
const categoryGoods = updatedGoods.filter(item => item.isAd || item.category === cat); |
|
|
categorizedGoods[cat] = []; |
|
|
categorizedGoods[cat] = categoryGoods; |
|
|
|
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
@ -545,7 +546,11 @@ Page({ |
|
|
const filteredByRegion = this.applyRegionFilter(updatedGoods); |
|
|
const filteredByRegion = this.applyRegionFilter(updatedGoods); |
|
|
categories.forEach(cat => { |
|
|
categories.forEach(cat => { |
|
|
if (cat !== '全部') { |
|
|
if (cat !== '全部') { |
|
|
categorizedGoods[cat + '_filtered'] = filteredByRegion.filter(item => item.isAd || item.category === cat); |
|
|
if (cat === selectedCategory) { |
|
|
|
|
|
categorizedGoods[cat + '_filtered'] = filteredByRegion.filter(item => item.isAd || !item.category || item.category === cat); |
|
|
|
|
|
} else { |
|
|
|
|
|
categorizedGoods[cat + '_filtered'] = []; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|