|
|
@ -339,7 +339,7 @@ function formatDateTime(dateString) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 处理净重、件数、规格和价格数据,将逗号分隔的字符串转换为一一对应的数组
|
|
|
// 处理净重、件数、规格和价格数据,将逗号分隔的字符串转换为一一对应的数组
|
|
|
function processWeightAndQuantityData(weightSpecString, quantityString, specString, priceString, specStatusString) { |
|
|
function processWeightAndQuantityData(weightSpecString, quantityString, specString, priceString, specStatusString, specPriceChanges = {}) { |
|
|
console.log('===== 处理净重、件数、规格和价格数据 ====='); |
|
|
console.log('===== 处理净重、件数、规格和价格数据 ====='); |
|
|
console.log('输入参数:'); |
|
|
console.log('输入参数:'); |
|
|
console.log('- weightSpecString:', weightSpecString, '(类型:', typeof weightSpecString, ')'); |
|
|
console.log('- weightSpecString:', weightSpecString, '(类型:', typeof weightSpecString, ')'); |
|
|
@ -450,13 +450,23 @@ function processWeightAndQuantityData(weightSpecString, quantityString, specStri |
|
|
|
|
|
|
|
|
console.log(`第${i}组数据处理结果: weightSpecDisplay=${weightSpecDisplay}, quantity=${quantity}, price=${price}, specStatus=${specStatus}, display=${display}`); |
|
|
console.log(`第${i}组数据处理结果: weightSpecDisplay=${weightSpecDisplay}, quantity=${quantity}, price=${price}, specStatus=${specStatus}, display=${display}`); |
|
|
|
|
|
|
|
|
|
|
|
// 检查该规格是否有价格变化
|
|
|
|
|
|
let priceChangeDirection = null; |
|
|
|
|
|
for (const spec in specPriceChanges) { |
|
|
|
|
|
if (weightSpecDisplay.includes(spec)) { |
|
|
|
|
|
priceChangeDirection = specPriceChanges[spec]; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
result.push({ |
|
|
result.push({ |
|
|
weightSpec: weightSpecDisplay, |
|
|
weightSpec: weightSpecDisplay, |
|
|
quantity: quantity, |
|
|
quantity: quantity, |
|
|
price: price, |
|
|
price: price, |
|
|
specStatus: specStatus, |
|
|
specStatus: specStatus, |
|
|
display: display, |
|
|
display: display, |
|
|
isOffShelf: specStatus === '1' |
|
|
isOffShelf: specStatus === '1', |
|
|
|
|
|
priceChangeDirection: priceChangeDirection |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -1286,6 +1296,64 @@ Page({ |
|
|
// 处理grossWeight为null或无效的情况,返回空字符串以支持文字输入
|
|
|
// 处理grossWeight为null或无效的情况,返回空字符串以支持文字输入
|
|
|
const grossWeightValue = product.grossWeight !== null && product.grossWeight !== undefined ? product.grossWeight : ''; |
|
|
const grossWeightValue = product.grossWeight !== null && product.grossWeight !== undefined ? product.grossWeight : ''; |
|
|
|
|
|
|
|
|
|
|
|
// 处理价格波动,计算价格变化的方向
|
|
|
|
|
|
const calculatePriceChangeDirection = (productLog) => { |
|
|
|
|
|
if (!productLog || !Array.isArray(productLog) || productLog.length === 0) { |
|
|
|
|
|
return {}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 按规格分组日志
|
|
|
|
|
|
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); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 检查每个规格的价格变化
|
|
|
|
|
|
const specPriceChanges = {}; |
|
|
|
|
|
for (const spec in specLogs) { |
|
|
|
|
|
const logs = specLogs[spec]; |
|
|
|
|
|
if (logs.length >= 2) { |
|
|
|
|
|
// 提取最近两次的价格
|
|
|
|
|
|
const latestLog = logs[logs.length - 1]; |
|
|
|
|
|
const previousLog = logs[logs.length - 2]; |
|
|
|
|
|
|
|
|
|
|
|
// 提取价格
|
|
|
|
|
|
const latestPriceMatch = latestLog.match(/修改为了(.*?)元/); |
|
|
|
|
|
const previousPriceMatch = previousLog.match(/修改为了(.*?)元/); |
|
|
|
|
|
|
|
|
|
|
|
if (latestPriceMatch && previousPriceMatch) { |
|
|
|
|
|
const latestPrice = parseFloat(latestPriceMatch[1]); |
|
|
|
|
|
const previousPrice = parseFloat(previousPriceMatch[1]); |
|
|
|
|
|
|
|
|
|
|
|
if (!isNaN(latestPrice) && !isNaN(previousPrice)) { |
|
|
|
|
|
if (latestPrice > previousPrice) { |
|
|
|
|
|
specPriceChanges[spec] = 'up'; // 价格上升
|
|
|
|
|
|
} else if (latestPrice < previousPrice) { |
|
|
|
|
|
specPriceChanges[spec] = 'down'; // 价格下降
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return specPriceChanges; // 返回每个规格的价格变化方向
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 检查所有可能的产品日志字段名
|
|
|
|
|
|
const productLog = product.product_log || product.productLog || []; |
|
|
|
|
|
// 计算每个规格的价格变化方向
|
|
|
|
|
|
const specPriceChanges = calculatePriceChangeDirection(productLog); |
|
|
|
|
|
|
|
|
// 处理净重、件数据和规格数据,获取一一对应的显示数组
|
|
|
// 处理净重、件数据和规格数据,获取一一对应的显示数组
|
|
|
// 注意:数据库中的规格字段包含净重信息,我们需要与件数数据正确匹配
|
|
|
// 注意:数据库中的规格字段包含净重信息,我们需要与件数数据正确匹配
|
|
|
// 修复:根据用户反馈,数据库中的规格字段内容为:净重46-47,净重44-43,净重47-48
|
|
|
// 修复:根据用户反馈,数据库中的规格字段内容为:净重46-47,净重44-43,净重47-48
|
|
|
@ -1415,7 +1483,7 @@ Page({ |
|
|
if (product.spec_status) { |
|
|
if (product.spec_status) { |
|
|
specStatusString = String(product.spec_status); |
|
|
specStatusString = String(product.spec_status); |
|
|
} |
|
|
} |
|
|
weightQuantityData = processWeightAndQuantityData(weightSpecString, quantityString, '', priceString, specStatusString); |
|
|
weightQuantityData = processWeightAndQuantityData(weightSpecString, quantityString, '', priceString, specStatusString, specPriceChanges); |
|
|
|
|
|
|
|
|
console.log('× 非售空分支结果:', weightQuantityData); |
|
|
console.log('× 非售空分支结果:', weightQuantityData); |
|
|
} |
|
|
} |
|
|
@ -1539,7 +1607,9 @@ Page({ |
|
|
imageUrls: imageUrls || [], |
|
|
imageUrls: imageUrls || [], |
|
|
mediaItems: mediaItems, |
|
|
mediaItems: mediaItems, |
|
|
// 确保region使用提取后的省份信息,放在最后覆盖所有展开操作
|
|
|
// 确保region使用提取后的省份信息,放在最后覆盖所有展开操作
|
|
|
region: region |
|
|
region: region, |
|
|
|
|
|
// 添加价格波动信息
|
|
|
|
|
|
specPriceChanges: specPriceChanges |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// 调试:打印formattedGoods的imageUrls和mediaItems
|
|
|
// 调试:打印formattedGoods的imageUrls和mediaItems
|
|
|
|