diff --git a/pages/goods-detail/goods-detail.js b/pages/goods-detail/goods-detail.js index 3d92fff..1316ecb 100644 --- a/pages/goods-detail/goods-detail.js +++ b/pages/goods-detail/goods-detail.js @@ -11,36 +11,32 @@ function getSourceTypeColor(sourceType) { return colorMap[sourceType] || '#4d9dff'; } -// 格式化分享标题 - 按优先级: 规格、地区、数量(鸡场直销-三方货源)、蛋黄颜色、蛋壳颜色 +// 格式化分享标题 - 按优先级: 地区、规格、数量、蛋黄颜色、蛋壳颜色 function formatShareTitle(goodsDetail) { console.log('===== formatShareTitle 开始 ====='); console.log('goodsDetail:', JSON.stringify(goodsDetail, null, 2)); const titleParts = []; - // 1. 规格 (specification/spec) - const specification = (goodsDetail.specification || goodsDetail.spec || goodsDetail.specs || '').trim(); - console.log('specification:', specification); - if (specification) { - titleParts.push(specification); - } - - // 2. 地区 (region) + // 1. 地区 (region) const region = (goodsDetail.region || '').trim(); console.log('region:', region); if (region) { titleParts.push(region); } - // 3. 数量 + (鸡场直销-三方货源) + // 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(); - const sourceType = (goodsDetail.sourceType || '').trim(); - console.log('quantity:', quantity, 'sourceType:', sourceType); + console.log('quantity:', quantity); if (quantity) { - const sourceLabel = sourceType ? `(${sourceType})` : ''; - titleParts.push(`${quantity}件${sourceLabel}`); - } else if (sourceType) { - titleParts.push(`(${sourceType})`); + titleParts.push(`${quantity}件`); } // 4. 蛋黄颜色 (yolk) @@ -50,18 +46,11 @@ function formatShareTitle(goodsDetail) { titleParts.push(yolk); } - // 5. 蛋壳颜色 (eggshell) - 使用品种(breed)作为备选 - const eggshell = (goodsDetail.eggshell || goodsDetail.shell || goodsDetail.breed || '').trim(); - console.log('eggshell:', eggshell); - if (eggshell) { - titleParts.push(eggshell); - } - - // 6. 货源描述 (description) - const description = (goodsDetail.description || goodsDetail.shareTitle || '').trim(); - console.log('description:', description); - if (description) { - titleParts.push(description); + // 5. 蛋壳颜色 (category) + const category = (goodsDetail.category || '').trim(); + console.log('category:', category); + if (category) { + titleParts.push(category); } // 过滤空值后组合标题