|
|
@ -441,6 +441,45 @@ Page({ |
|
|
return region; |
|
|
return region; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 格式化商品规格显示 - 只显示前两个,后面加...
|
|
|
|
|
|
formatSpecification: function(spec, yolk) { |
|
|
|
|
|
if (!spec || spec === '无') { |
|
|
|
|
|
return { |
|
|
|
|
|
displaySpec: '无', |
|
|
|
|
|
displayYolk: yolk && yolk !== '无' ? yolk : '' |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 按常见的分隔符分割规格
|
|
|
|
|
|
const separators = [',', ',', '、', '|', ';', ';']; |
|
|
|
|
|
let parts = [spec]; |
|
|
|
|
|
|
|
|
|
|
|
for (let separator of separators) { |
|
|
|
|
|
if (spec.includes(separator)) { |
|
|
|
|
|
parts = spec.split(separator); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 清理空值并限制为前两个
|
|
|
|
|
|
const cleanParts = parts |
|
|
|
|
|
.map(part => part.trim()) |
|
|
|
|
|
.filter(part => part && part !== '无') |
|
|
|
|
|
.slice(0, 2); |
|
|
|
|
|
|
|
|
|
|
|
let displaySpec = cleanParts.join(' | '); |
|
|
|
|
|
|
|
|
|
|
|
// 如果原规格分割后超过两个部分,添加省略号
|
|
|
|
|
|
if (cleanParts.length < parts.filter(part => part.trim() && part.trim() !== '无').length) { |
|
|
|
|
|
displaySpec += '...'; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
|
displaySpec, |
|
|
|
|
|
displayYolk: yolk && yolk !== '无' ? yolk : '' |
|
|
|
|
|
}; |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
// 处理商品数据 - 淘宝风格
|
|
|
// 处理商品数据 - 淘宝风格
|
|
|
processGoodsData: function(products, isLoadMore = false) { |
|
|
processGoodsData: function(products, isLoadMore = false) { |
|
|
let newGoods = products.map(product => { |
|
|
let newGoods = products.map(product => { |
|
|
@ -495,6 +534,9 @@ Page({ |
|
|
displayStock: displayStock |
|
|
displayStock: displayStock |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 格式化规格显示
|
|
|
|
|
|
const formattedSpec = this.formatSpecification(product.specification || product.spec || '', product.yolk || ''); |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
|
...product, |
|
|
...product, |
|
|
id: productId, // 统一使用id字段
|
|
|
id: productId, // 统一使用id字段
|
|
|
@ -519,7 +561,9 @@ Page({ |
|
|
currentImageIndex: 0, |
|
|
currentImageIndex: 0, |
|
|
imageUrls: formattedImageUrls, |
|
|
imageUrls: formattedImageUrls, |
|
|
totalStock: displayStock, // 使用优化后的库存显示值
|
|
|
totalStock: displayStock, // 使用优化后的库存显示值
|
|
|
originalTotalStock: totalStock // 保留原始计算值用于调试
|
|
|
originalTotalStock: totalStock, // 保留原始计算值用于调试
|
|
|
|
|
|
displaySpecification: formattedSpec.displaySpec, // 格式化后的规格
|
|
|
|
|
|
displayYolk: formattedSpec.displayYolk // 格式化后的蛋黄
|
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|