From b7f4955edcd2f307e1fbc0de5d35663f875dfa01 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, 12 Jan 2026 15:02:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E5=93=81=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E4=BB=B7=E6=A0=BC=E5=AF=B9=E6=AF=94=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=9F=BA=E4=BA=8Ecategory?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E7=9A=84=E7=9B=B8=E5=90=8C=E7=A7=8D=E7=B1=BB?= =?UTF-8?q?=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/goods-detail/goods-detail.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pages/goods-detail/goods-detail.js b/pages/goods-detail/goods-detail.js index 2d20818..78c0828 100644 --- a/pages/goods-detail/goods-detail.js +++ b/pages/goods-detail/goods-detail.js @@ -2493,6 +2493,9 @@ Page({ // 提取当前商品的净重规格(如"净重41-42") const currentWeightSpecs = currentSpecifications.map(item => item.weightSpec.trim()) .filter(spec => spec && (spec.includes('净重') || spec.includes('毛重'))); + // 提取当前商品的种类(category) + const currentCategory = currentGoods.category || ''; + console.log('当前商品的种类:', currentCategory); // 调用API获取首页商品列表 API.getProducts() @@ -2547,7 +2550,12 @@ Page({ formattedDate: formattedDate // 添加格式化的日期字段 }; }).filter(goods => { - // 只有当当前商品有明确的规格时才进行筛选 + // 1. 先过滤相同种类(category)的商品 + if (currentCategory && goods.category !== currentCategory) { + return false; + } + + // 2. 只有当当前商品有明确的规格时才进行筛选 if (currentWeightSpecs.length === 0) { return true; }