|
|
|
@ -339,13 +339,14 @@ function formatDateTime(dateString) { |
|
|
|
} |
|
|
|
|
|
|
|
// 处理净重、件数、规格和价格数据,将逗号分隔的字符串转换为一一对应的数组
|
|
|
|
function processWeightAndQuantityData(weightSpecString, quantityString, specString, priceString) { |
|
|
|
function processWeightAndQuantityData(weightSpecString, quantityString, specString, priceString, specStatusString) { |
|
|
|
console.log('===== 处理净重、件数、规格和价格数据 ====='); |
|
|
|
console.log('输入参数:'); |
|
|
|
console.log('- weightSpecString:', weightSpecString, '(类型:', typeof weightSpecString, ')'); |
|
|
|
console.log('- quantityString:', quantityString, '(类型:', typeof quantityString, ')'); |
|
|
|
console.log('- specString:', specString, '(类型:', typeof specString, ')'); |
|
|
|
console.log('- priceString:', priceString, '(类型:', typeof priceString, ')'); |
|
|
|
console.log('- specStatusString:', specStatusString, '(类型:', typeof specStatusString, ')'); |
|
|
|
|
|
|
|
// 处理价格字符串
|
|
|
|
let priceArray = []; |
|
|
|
@ -358,6 +359,17 @@ function processWeightAndQuantityData(weightSpecString, quantityString, specStri |
|
|
|
console.log('将价格转换为数组:', priceArray); |
|
|
|
} |
|
|
|
|
|
|
|
// 处理规格状态字符串
|
|
|
|
let specStatusArray = []; |
|
|
|
if (specStatusString && typeof specStatusString === 'string') { |
|
|
|
// 支持多种逗号分隔符:英文逗号、中文逗号、全角逗号
|
|
|
|
specStatusArray = specStatusString.split(/[,,、]/).map(item => item.trim()).filter(item => item); |
|
|
|
console.log('从字符串分割得到规格状态数组:', specStatusArray); |
|
|
|
} else if (specStatusString) { |
|
|
|
specStatusArray = [String(specStatusString)]; |
|
|
|
console.log('将规格状态转换为数组:', specStatusArray); |
|
|
|
} |
|
|
|
|
|
|
|
// 如果没有数据,返回空数组
|
|
|
|
if (!weightSpecString && !quantityString && !specString) { |
|
|
|
console.log('没有数据,返回空数组'); |
|
|
|
@ -387,7 +399,7 @@ function processWeightAndQuantityData(weightSpecString, quantityString, specStri |
|
|
|
} |
|
|
|
|
|
|
|
// 获取最大长度,确保一一对应
|
|
|
|
const maxLength = Math.max(weightSpecArray.length, quantityArray.length, priceArray.length); |
|
|
|
const maxLength = Math.max(weightSpecArray.length, quantityArray.length, priceArray.length, specStatusArray.length); |
|
|
|
console.log('最大长度:', maxLength); |
|
|
|
const result = []; |
|
|
|
|
|
|
|
@ -395,8 +407,9 @@ function processWeightAndQuantityData(weightSpecString, quantityString, specStri |
|
|
|
const weightSpec = weightSpecArray[i] || ''; |
|
|
|
const quantity = quantityArray[i] || ''; |
|
|
|
const price = priceArray[i] || ''; |
|
|
|
const specStatus = specStatusArray[i] || '0'; |
|
|
|
|
|
|
|
console.log(`处理第${i}组数据: weightSpec=${weightSpec}, quantity=${quantity}, price=${price}`); |
|
|
|
console.log(`处理第${i}组数据: weightSpec=${weightSpec}, quantity=${quantity}, price=${price}, specStatus=${specStatus}`); |
|
|
|
|
|
|
|
// 处理净重规格显示格式 - 根据内容类型添加相应前缀
|
|
|
|
let weightSpecDisplay = ''; |
|
|
|
@ -432,12 +445,18 @@ function processWeightAndQuantityData(weightSpecString, quantityString, specStri |
|
|
|
display = `${quantity}件`; |
|
|
|
} |
|
|
|
|
|
|
|
console.log(`第${i}组数据处理结果: weightSpecDisplay=${weightSpecDisplay}, quantity=${quantity}, price=${price}, display=${display}`); |
|
|
|
// 检查规格状态,如果为1则显示已下架
|
|
|
|
if (specStatus === '1') { |
|
|
|
display = `${display}---已下架`; |
|
|
|
} |
|
|
|
|
|
|
|
console.log(`第${i}组数据处理结果: weightSpecDisplay=${weightSpecDisplay}, quantity=${quantity}, price=${price}, specStatus=${specStatus}, display=${display}`); |
|
|
|
|
|
|
|
result.push({ |
|
|
|
weightSpec: weightSpecDisplay, |
|
|
|
quantity: quantity, |
|
|
|
price: price, |
|
|
|
specStatus: specStatus, |
|
|
|
display: display |
|
|
|
}); |
|
|
|
} |
|
|
|
@ -1315,7 +1334,12 @@ Page({ |
|
|
|
|
|
|
|
console.log('输入参数: weightSpecString="', weightSpecString, '", quantityString="', quantityString, '"'); |
|
|
|
|
|
|
|
weightQuantityData = processWeightAndQuantityData(weightSpecString, quantityString, '', priceString); |
|
|
|
// 获取规格状态信息
|
|
|
|
let specStatusString = ''; |
|
|
|
if (product.spec_status) { |
|
|
|
specStatusString = String(product.spec_status); |
|
|
|
} |
|
|
|
weightQuantityData = processWeightAndQuantityData(weightSpecString, quantityString, '', priceString, specStatusString); |
|
|
|
|
|
|
|
console.log('× 非售空分支结果:', weightQuantityData); |
|
|
|
} |
|
|
|
@ -2943,8 +2967,13 @@ Page({ |
|
|
|
priceString = String(goods.price); |
|
|
|
} |
|
|
|
|
|
|
|
// 获取规格状态信息
|
|
|
|
let specStatusString = ''; |
|
|
|
if (goods.spec_status) { |
|
|
|
specStatusString = String(goods.spec_status); |
|
|
|
} |
|
|
|
// 调用processWeightAndQuantityData处理规格数据
|
|
|
|
const weightQuantityData = processWeightAndQuantityData(weightSpecString, quantityString, '', priceString); |
|
|
|
const weightQuantityData = processWeightAndQuantityData(weightSpecString, quantityString, '', priceString, specStatusString); |
|
|
|
|
|
|
|
// 提取省份信息
|
|
|
|
const province = extractProvince(goods.region || ''); |
|
|
|
@ -3179,8 +3208,14 @@ Page({ |
|
|
|
priceString = String(product.price); |
|
|
|
} |
|
|
|
|
|
|
|
// 获取规格状态信息
|
|
|
|
let specStatusString = ''; |
|
|
|
if (product.spec_status) { |
|
|
|
specStatusString = String(product.spec_status); |
|
|
|
} |
|
|
|
|
|
|
|
// 处理数据
|
|
|
|
const weightQuantityData = processWeightAndQuantityData(weightSpecString, quantityString, '', priceString); |
|
|
|
const weightQuantityData = processWeightAndQuantityData(weightSpecString, quantityString, '', priceString, specStatusString); |
|
|
|
|
|
|
|
// 格式化日期
|
|
|
|
const updatedAt = product.updated_at || product.updatedAt; |
|
|
|
@ -3251,8 +3286,14 @@ Page({ |
|
|
|
priceString = String(product.price); |
|
|
|
} |
|
|
|
|
|
|
|
// 获取规格状态信息
|
|
|
|
let specStatusString = ''; |
|
|
|
if (product.spec_status) { |
|
|
|
specStatusString = String(product.spec_status); |
|
|
|
} |
|
|
|
|
|
|
|
// 处理数据
|
|
|
|
const weightQuantityData = processWeightAndQuantityData(weightSpecString, quantityString, '', priceString); |
|
|
|
const weightQuantityData = processWeightAndQuantityData(weightSpecString, quantityString, '', priceString, specStatusString); |
|
|
|
|
|
|
|
// 格式化日期
|
|
|
|
const updatedAt = product.updated_at || product.updatedAt; |
|
|
|
|