|
|
@ -26,63 +26,26 @@ function calculateDisplayPrice(price) { |
|
|
return String(price); |
|
|
return String(price); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 格式化分享标题 - 按优先级: 地区、规格、数量、蛋黄颜色、蛋壳颜色
|
|
|
// 格式化分享标题 - 只显示货源描述
|
|
|
function formatShareTitle(goodsDetail) { |
|
|
function formatShareTitle(goodsDetail) { |
|
|
console.log('===== formatShareTitle 开始 ====='); |
|
|
console.log('===== formatShareTitle 开始 ====='); |
|
|
console.log('goodsDetail:', JSON.stringify(goodsDetail, null, 2)); |
|
|
console.log('goodsDetail:', JSON.stringify(goodsDetail, null, 2)); |
|
|
|
|
|
|
|
|
const titleParts = []; |
|
|
// 优先使用货源描述
|
|
|
|
|
|
const description = (goodsDetail.description || '').trim(); |
|
|
// 1. 地区 (region)
|
|
|
console.log('description:', description); |
|
|
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); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 5. 蛋壳颜色 (category)
|
|
|
if (description) { |
|
|
const category = (goodsDetail.category || '').trim(); |
|
|
console.log('最终标题:', description); |
|
|
console.log('category:', category); |
|
|
console.log('===== formatShareTitle 结束 ====='); |
|
|
if (category) { |
|
|
return description; |
|
|
titleParts.push(category); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 过滤空值后组合标题
|
|
|
// 如果没有货源描述,返回默认标题
|
|
|
const validParts = titleParts.filter(part => part && part.length > 0); |
|
|
const defaultTitle = goodsDetail.name ? `优质鸡蛋 - ${goodsDetail.name}` : '优质鸡蛋货源'; |
|
|
const result = validParts.join(' '); |
|
|
console.log('最终标题:', defaultTitle); |
|
|
|
|
|
|
|
|
console.log('titleParts:', titleParts); |
|
|
|
|
|
console.log('validParts:', validParts); |
|
|
|
|
|
console.log('最终标题:', result); |
|
|
|
|
|
console.log('===== formatShareTitle 结束 ====='); |
|
|
console.log('===== formatShareTitle 结束 ====='); |
|
|
|
|
|
return defaultTitle; |
|
|
if (validParts.length > 0) { |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 如果没有匹配的数据,返回默认标题
|
|
|
|
|
|
return goodsDetail.name ? `优质鸡蛋 - ${goodsDetail.name}` : '优质鸡蛋货源'; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 构建商品分享消息内容
|
|
|
// 构建商品分享消息内容
|
|
|
|