From 90ddf1d798f31fc58fb03c7e71d332908ae79f0e Mon Sep 17 00:00:00 2001 From: Trae AI Date: Thu, 29 Jan 2026 16:11:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E4=BA=AB=E6=A0=87?= =?UTF-8?q?=E9=A2=98=E5=8F=AA=E6=98=BE=E7=A4=BA=E8=B4=A7=E6=BA=90=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/goods-detail/goods-detail.js | 61 ++++++------------------------ 1 file changed, 12 insertions(+), 49 deletions(-) diff --git a/pages/goods-detail/goods-detail.js b/pages/goods-detail/goods-detail.js index 2dd76ca..52cb74c 100644 --- a/pages/goods-detail/goods-detail.js +++ b/pages/goods-detail/goods-detail.js @@ -26,63 +26,26 @@ function calculateDisplayPrice(price) { return String(price); } -// 格式化分享标题 - 按优先级: 地区、规格、数量、蛋黄颜色、蛋壳颜色 +// 格式化分享标题 - 只显示货源描述 function formatShareTitle(goodsDetail) { console.log('===== formatShareTitle 开始 ====='); console.log('goodsDetail:', JSON.stringify(goodsDetail, null, 2)); - const titleParts = []; - - // 1. 地区 (region) - const region = (goodsDetail.region || '').trim(); - console.log('region:', region); - if (region) { - titleParts.push(region); - } - - // 2. 规格 (specification/spec) - const specification = (goodsDetail.specification || goodsDetail.spec || goodsDetail.specs || '').trim(); - console.log('specification:', specification); - if (specification) { - titleParts.push(specification); - } - - // 3. 数量 (quantity) - const quantity = (goodsDetail.quantity || '').trim(); - console.log('quantity:', quantity); - if (quantity) { - titleParts.push(`${quantity}件`); - } - - // 4. 蛋黄颜色 (yolk) - const yolk = (goodsDetail.yolk || '').trim(); - console.log('yolk:', yolk); - if (yolk) { - titleParts.push(yolk); - } + // 优先使用货源描述 + const description = (goodsDetail.description || '').trim(); + console.log('description:', description); - // 5. 蛋壳颜色 (category) - const category = (goodsDetail.category || '').trim(); - console.log('category:', category); - if (category) { - titleParts.push(category); + if (description) { + console.log('最终标题:', description); + console.log('===== formatShareTitle 结束 ====='); + return description; } - // 过滤空值后组合标题 - const validParts = titleParts.filter(part => part && part.length > 0); - const result = validParts.join(' '); - - console.log('titleParts:', titleParts); - console.log('validParts:', validParts); - console.log('最终标题:', result); + // 如果没有货源描述,返回默认标题 + const defaultTitle = goodsDetail.name ? `优质鸡蛋 - ${goodsDetail.name}` : '优质鸡蛋货源'; + console.log('最终标题:', defaultTitle); console.log('===== formatShareTitle 结束 ====='); - - if (validParts.length > 0) { - return result; - } - - // 如果没有匹配的数据,返回默认标题 - return goodsDetail.name ? `优质鸡蛋 - ${goodsDetail.name}` : '优质鸡蛋货源'; + return defaultTitle; } // 构建商品分享消息内容