From 3e11a6519b7a5362e6ece03f9f4a6292ee8d1be7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E9=A3=9E=E6=B4=8B?= <15778543+xufeiyang6017@user.noreply.gitee.com> Date: Mon, 29 Dec 2025 14:39:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=86=E7=B1=BB=E7=AD=9B?= =?UTF-8?q?=E9=80=89=E9=97=AE=E9=A2=98=EF=BC=8C=E6=95=B0=E6=8D=AE=E5=BD=92?= =?UTF-8?q?=E5=B1=9E=E5=BD=93=E5=89=8D=E9=80=89=E4=B8=AD=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pages/index/index.js b/pages/index/index.js index 6744fe7..9715702 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -530,14 +530,15 @@ Page({ // 按品种分类存储商品数据 const categorizedGoods = this.data.categorizedGoods || {}; const categories = this.data.categories; + const selectedCategory = this.data.selectedCategory; - // 重置所有分类的商品列表 categories.forEach(cat => { if (cat === '全部') { categorizedGoods[cat] = updatedGoods; + } else if (cat === selectedCategory) { + categorizedGoods[cat] = updatedGoods.filter(item => item.isAd || !item.category || item.category === cat); } else { - const categoryGoods = updatedGoods.filter(item => item.isAd || item.category === cat); - categorizedGoods[cat] = categoryGoods; + categorizedGoods[cat] = []; } }); @@ -545,7 +546,11 @@ Page({ const filteredByRegion = this.applyRegionFilter(updatedGoods); categories.forEach(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'] = []; + } } });