|
|
@ -1326,6 +1326,50 @@ Page({ |
|
|
// 格式化规格显示
|
|
|
// 格式化规格显示
|
|
|
const formattedSpec = this.formatSpecification(product.specification || product.spec || '', product.yolk || ''); |
|
|
const formattedSpec = this.formatSpecification(product.specification || product.spec || '', product.yolk || ''); |
|
|
|
|
|
|
|
|
|
|
|
// 处理价格波动
|
|
|
|
|
|
const processPriceChange = (productLog) => { |
|
|
|
|
|
if (!productLog || !Array.isArray(productLog) || productLog.length === 0) { |
|
|
|
|
|
return { |
|
|
|
|
|
hasPriceChange: false, |
|
|
|
|
|
priceChangeDirection: null |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 检查是否有同规格的第二次日志
|
|
|
|
|
|
const specLogs = {}; |
|
|
|
|
|
productLog.forEach(log => { |
|
|
|
|
|
if (typeof log === 'string') { |
|
|
|
|
|
// 提取规格信息
|
|
|
|
|
|
const specMatch = log.match(/将(.+?)规格的销售价格/); |
|
|
|
|
|
if (specMatch && specMatch[1]) { |
|
|
|
|
|
const spec = specMatch[1].trim(); |
|
|
|
|
|
if (!specLogs[spec]) { |
|
|
|
|
|
specLogs[spec] = []; |
|
|
|
|
|
} |
|
|
|
|
|
specLogs[spec].push(log); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 检查是否有规格有多次价格调整
|
|
|
|
|
|
let hasPriceChange = false; |
|
|
|
|
|
for (const spec in specLogs) { |
|
|
|
|
|
if (specLogs[spec].length >= 2) { |
|
|
|
|
|
hasPriceChange = true; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
|
hasPriceChange, |
|
|
|
|
|
priceChangeDirection: null // 默认为null,在商品详情页中计算具体方向
|
|
|
|
|
|
}; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 检查所有可能的产品日志字段名
|
|
|
|
|
|
const productLog = product.product_log || product.productLog || []; |
|
|
|
|
|
const priceChangeInfo = processPriceChange(productLog); |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
|
...product, |
|
|
...product, |
|
|
id: productId, // 统一使用id字段
|
|
|
id: productId, // 统一使用id字段
|
|
|
@ -1355,7 +1399,10 @@ Page({ |
|
|
originalTotalStock: totalStock, // 保留原始计算值用于调试
|
|
|
originalTotalStock: totalStock, // 保留原始计算值用于调试
|
|
|
displaySpecification: formattedSpec.displaySpec, // 格式化后的规格
|
|
|
displaySpecification: formattedSpec.displaySpec, // 格式化后的规格
|
|
|
displayYolk: formattedSpec.displayYolk, // 格式化后的蛋黄
|
|
|
displayYolk: formattedSpec.displayYolk, // 格式化后的蛋黄
|
|
|
price: product.price !== undefined ? product.price : '' // 确保price字段存在
|
|
|
price: product.price !== undefined ? product.price : '', // 确保price字段存在
|
|
|
|
|
|
// 添加价格波动信息
|
|
|
|
|
|
hasPriceChange: priceChangeInfo.hasPriceChange, |
|
|
|
|
|
priceChangeDirection: priceChangeInfo.priceChangeDirection |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|