Browse Source

Merge pull request '调整分享标题字段顺序:地区、规格、数量、蛋黄颜色、蛋壳颜色' (#9) from hzj into Xfy

Reviewed-on: http://8.137.125.67:4000/SwtTt29/Mini-Program/pulls/9
pull/11/head
hzj 2 months ago
parent
commit
768f47161e
  1. 45
      pages/goods-detail/goods-detail.js

45
pages/goods-detail/goods-detail.js

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

Loading…
Cancel
Save