|
|
@ -274,13 +274,25 @@ function checkLoginStatus() { |
|
|
return !!(openid && userId); |
|
|
return !!(openid && userId); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 处理净重、件数和规格数据,将逗号分隔的字符串转换为一一对应的数组
|
|
|
// 处理净重、件数、规格和价格数据,将逗号分隔的字符串转换为一一对应的数组
|
|
|
function processWeightAndQuantityData(weightSpecString, quantityString, specString) { |
|
|
function processWeightAndQuantityData(weightSpecString, quantityString, specString, priceString) { |
|
|
console.log('===== 处理净重、件数和规格数据 ====='); |
|
|
console.log('===== 处理净重、件数、规格和价格数据 ====='); |
|
|
console.log('输入参数:'); |
|
|
console.log('输入参数:'); |
|
|
console.log('- weightSpecString:', weightSpecString, '(类型:', typeof weightSpecString, ')'); |
|
|
console.log('- weightSpecString:', weightSpecString, '(类型:', typeof weightSpecString, ')'); |
|
|
console.log('- quantityString:', quantityString, '(类型:', typeof quantityString, ')'); |
|
|
console.log('- quantityString:', quantityString, '(类型:', typeof quantityString, ')'); |
|
|
console.log('- specString:', specString, '(类型:', typeof specString, ')'); |
|
|
console.log('- specString:', specString, '(类型:', typeof specString, ')'); |
|
|
|
|
|
console.log('- priceString:', priceString, '(类型:', typeof priceString, ')'); |
|
|
|
|
|
|
|
|
|
|
|
// 处理价格字符串
|
|
|
|
|
|
let priceArray = []; |
|
|
|
|
|
if (priceString && typeof priceString === 'string') { |
|
|
|
|
|
// 支持多种逗号分隔符:英文逗号、中文逗号、全角逗号
|
|
|
|
|
|
priceArray = priceString.split(/[,,、]/).map(item => item.trim()).filter(item => item); |
|
|
|
|
|
console.log('从字符串分割得到价格数组:', priceArray); |
|
|
|
|
|
} else if (priceString) { |
|
|
|
|
|
priceArray = [String(priceString)]; |
|
|
|
|
|
console.log('将价格转换为数组:', priceArray); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 如果没有数据,返回空数组
|
|
|
// 如果没有数据,返回空数组
|
|
|
if (!weightSpecString && !quantityString && !specString) { |
|
|
if (!weightSpecString && !quantityString && !specString) { |
|
|
@ -311,15 +323,16 @@ function processWeightAndQuantityData(weightSpecString, quantityString, specStri |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 获取最大长度,确保一一对应
|
|
|
// 获取最大长度,确保一一对应
|
|
|
const maxLength = Math.max(weightSpecArray.length, quantityArray.length); |
|
|
const maxLength = Math.max(weightSpecArray.length, quantityArray.length, priceArray.length); |
|
|
console.log('最大长度:', maxLength); |
|
|
console.log('最大长度:', maxLength); |
|
|
const result = []; |
|
|
const result = []; |
|
|
|
|
|
|
|
|
for (let i = 0; i < maxLength; i++) { |
|
|
for (let i = 0; i < maxLength; i++) { |
|
|
const weightSpec = weightSpecArray[i] || ''; |
|
|
const weightSpec = weightSpecArray[i] || ''; |
|
|
const quantity = quantityArray[i] || ''; |
|
|
const quantity = quantityArray[i] || ''; |
|
|
|
|
|
const price = priceArray[i] || ''; |
|
|
|
|
|
|
|
|
console.log(`处理第${i}组数据: weightSpec=${weightSpec}, quantity=${quantity}`); |
|
|
console.log(`处理第${i}组数据: weightSpec=${weightSpec}, quantity=${quantity}, price=${price}`); |
|
|
|
|
|
|
|
|
// 处理净重规格显示格式 - 根据内容类型添加相应前缀
|
|
|
// 处理净重规格显示格式 - 根据内容类型添加相应前缀
|
|
|
let weightSpecDisplay = ''; |
|
|
let weightSpecDisplay = ''; |
|
|
@ -336,14 +349,18 @@ function processWeightAndQuantityData(weightSpecString, quantityString, specStri |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 组合显示:格式为"净重信息————件数"
|
|
|
// 组合显示:格式为"净重信息————件数-价格"
|
|
|
let display = ''; |
|
|
let display = ''; |
|
|
if (weightSpecDisplay && quantity) { |
|
|
if (weightSpecDisplay && quantity) { |
|
|
// 检查是否为售空状态,如果是售空状态则显示"售空"
|
|
|
// 检查是否为售空状态,如果是售空状态则显示"售空"
|
|
|
if (weightSpecDisplay.includes('售空') || quantity === '售空') { |
|
|
if (weightSpecDisplay.includes('售空') || quantity === '售空') { |
|
|
display = `${weightSpecDisplay}————售空`; |
|
|
display = `${weightSpecDisplay}————售空`; |
|
|
} else { |
|
|
} else { |
|
|
display = `${weightSpecDisplay}————${quantity}件`; |
|
|
if (price) { |
|
|
|
|
|
display = `${weightSpecDisplay}【${quantity}件】${price}元`; |
|
|
|
|
|
} else { |
|
|
|
|
|
display = `${weightSpecDisplay}【${quantity}件】`; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} else if (weightSpecDisplay) { |
|
|
} else if (weightSpecDisplay) { |
|
|
display = weightSpecDisplay; |
|
|
display = weightSpecDisplay; |
|
|
@ -351,7 +368,7 @@ function processWeightAndQuantityData(weightSpecString, quantityString, specStri |
|
|
display = `${quantity}件`; |
|
|
display = `${quantity}件`; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
console.log(`第${i}组数据处理结果: weightSpecDisplay=${weightSpecDisplay}, quantity=${quantity}, display=${display}`); |
|
|
console.log(`第${i}组数据处理结果: weightSpecDisplay=${weightSpecDisplay}, quantity=${quantity}, price=${price}, display=${display}`); |
|
|
|
|
|
|
|
|
result.push({ |
|
|
result.push({ |
|
|
weightSpec: weightSpecDisplay, |
|
|
weightSpec: weightSpecDisplay, |
|
|
@ -803,9 +820,15 @@ Page({ |
|
|
} else { |
|
|
} else { |
|
|
// 非售空状态,使用processWeightAndQuantityData函数正确处理规格和件数信息
|
|
|
// 非售空状态,使用processWeightAndQuantityData函数正确处理规格和件数信息
|
|
|
console.log('× 非售空分支执行: 调用processWeightAndQuantityData处理'); |
|
|
console.log('× 非售空分支执行: 调用processWeightAndQuantityData处理'); |
|
|
|
|
|
// 获取价格信息
|
|
|
|
|
|
let priceString = ''; |
|
|
|
|
|
if (product.price) { |
|
|
|
|
|
priceString = String(product.price); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
console.log('输入参数: weightSpecString="', weightSpecString, '", quantityString="', quantityString, '"'); |
|
|
console.log('输入参数: weightSpecString="', weightSpecString, '", quantityString="', quantityString, '"'); |
|
|
|
|
|
|
|
|
weightQuantityData = processWeightAndQuantityData(weightSpecString, quantityString, ''); |
|
|
weightQuantityData = processWeightAndQuantityData(weightSpecString, quantityString, '', priceString); |
|
|
|
|
|
|
|
|
console.log('× 非售空分支结果:', weightQuantityData); |
|
|
console.log('× 非售空分支结果:', weightQuantityData); |
|
|
} |
|
|
} |
|
|
@ -2118,8 +2141,14 @@ Page({ |
|
|
quantityString = String(goods.quantity); |
|
|
quantityString = String(goods.quantity); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 处理价格数据
|
|
|
|
|
|
let priceString = ''; |
|
|
|
|
|
if (goods.price) { |
|
|
|
|
|
priceString = String(goods.price); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 调用processWeightAndQuantityData处理规格数据
|
|
|
// 调用processWeightAndQuantityData处理规格数据
|
|
|
const weightQuantityData = processWeightAndQuantityData(weightSpecString, quantityString, ''); |
|
|
const weightQuantityData = processWeightAndQuantityData(weightSpecString, quantityString, '', priceString); |
|
|
|
|
|
|
|
|
// 提取省份信息
|
|
|
// 提取省份信息
|
|
|
const province = extractProvince(goods.region || ''); |
|
|
const province = extractProvince(goods.region || ''); |
|
|
|