|
|
@ -195,7 +195,7 @@ function getUserPhoneNumber() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 处理净重件数对应数据,支持逗号分隔的价格与规格一一对应
|
|
|
// 处理净重件数对应数据,支持逗号分隔的价格与规格一一对应
|
|
|
function processWeightAndQuantityData(weightSpecString, quantityString, specString, price = '', costprice = '') { |
|
|
function processWeightAndQuantityData(weightSpecString, quantityString, specString, price = '', costprice = '', specStatusString = '') { |
|
|
console.log('===== 处理净重、件数和规格数据 ====='); |
|
|
console.log('===== 处理净重、件数和规格数据 ====='); |
|
|
console.log('输入参数:'); |
|
|
console.log('输入参数:'); |
|
|
console.log('- weightSpecString:', weightSpecString, '(类型:', typeof weightSpecString, ')'); |
|
|
console.log('- weightSpecString:', weightSpecString, '(类型:', typeof weightSpecString, ')'); |
|
|
@ -203,6 +203,7 @@ function processWeightAndQuantityData(weightSpecString, quantityString, specStri |
|
|
console.log('- specString:', specString, '(类型:', typeof specString, ')'); |
|
|
console.log('- specString:', specString, '(类型:', typeof specString, ')'); |
|
|
console.log('- price:', price, '(类型:', typeof price, ')'); |
|
|
console.log('- price:', price, '(类型:', typeof price, ')'); |
|
|
console.log('- costprice:', costprice, '(类型:', typeof costprice, ')'); |
|
|
console.log('- costprice:', costprice, '(类型:', typeof costprice, ')'); |
|
|
|
|
|
console.log('- specStatusString:', specStatusString, '(类型:', typeof specStatusString, ')'); |
|
|
|
|
|
|
|
|
// 如果没有数据,返回空数组
|
|
|
// 如果没有数据,返回空数组
|
|
|
if (!weightSpecString && !quantityString && !specString) { |
|
|
if (!weightSpecString && !quantityString && !specString) { |
|
|
@ -254,8 +255,16 @@ function processWeightAndQuantityData(weightSpecString, quantityString, specStri |
|
|
console.log('将采购价格转换为数组:', costpriceArray); |
|
|
console.log('将采购价格转换为数组:', costpriceArray); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 处理规格状态字符串,支持逗号分隔的多个状态
|
|
|
|
|
|
let specStatusArray = []; |
|
|
|
|
|
if (specStatusString && typeof specStatusString === 'string') { |
|
|
|
|
|
// 支持多种逗号分隔符:英文逗号、中文逗号、全角逗号
|
|
|
|
|
|
specStatusArray = specStatusString.split(/[,,、]/).map(item => item.trim()).filter(item => item); |
|
|
|
|
|
console.log('从字符串分割得到规格状态数组:', specStatusArray); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 获取最大长度,确保一一对应
|
|
|
// 获取最大长度,确保一一对应
|
|
|
const maxLength = Math.max(weightSpecArray.length, quantityArray.length, priceArray.length, costpriceArray.length); |
|
|
const maxLength = Math.max(weightSpecArray.length, quantityArray.length, priceArray.length, costpriceArray.length, specStatusArray.length); |
|
|
console.log('最大长度:', maxLength); |
|
|
console.log('最大长度:', maxLength); |
|
|
const result = []; |
|
|
const result = []; |
|
|
|
|
|
|
|
|
@ -264,8 +273,9 @@ function processWeightAndQuantityData(weightSpecString, quantityString, specStri |
|
|
const quantity = quantityArray[i] || ''; |
|
|
const quantity = quantityArray[i] || ''; |
|
|
const itemPrice = priceArray[i] || ''; |
|
|
const itemPrice = priceArray[i] || ''; |
|
|
const itemCostprice = costpriceArray[i] || ''; |
|
|
const itemCostprice = costpriceArray[i] || ''; |
|
|
|
|
|
const itemSpecStatus = specStatusArray[i] || '0'; // 默认规格状态为0
|
|
|
|
|
|
|
|
|
console.log(`处理第${i}组数据: weightSpec=${weightSpec}, quantity=${quantity}, price=${itemPrice}, costprice=${itemCostprice}`); |
|
|
console.log(`处理第${i}组数据: weightSpec=${weightSpec}, quantity=${quantity}, price=${itemPrice}, costprice=${itemCostprice}, specStatus=${itemSpecStatus}`); |
|
|
|
|
|
|
|
|
// 处理净重规格显示格式 - 根据内容类型添加相应前缀
|
|
|
// 处理净重规格显示格式 - 根据内容类型添加相应前缀
|
|
|
let weightSpecDisplay = ''; |
|
|
let weightSpecDisplay = ''; |
|
|
@ -297,9 +307,10 @@ function processWeightAndQuantityData(weightSpecString, quantityString, specStri |
|
|
weightSpec: weightSpecDisplay, |
|
|
weightSpec: weightSpecDisplay, |
|
|
quantity: quantityDisplay, |
|
|
quantity: quantityDisplay, |
|
|
price: itemPrice, |
|
|
price: itemPrice, |
|
|
costprice: itemCostprice |
|
|
costprice: itemCostprice, |
|
|
|
|
|
specStatus: itemSpecStatus |
|
|
}); |
|
|
}); |
|
|
console.log(`添加显示对象: weightSpec=${weightSpecDisplay}, quantity=${quantityDisplay}, price=${itemPrice}, costprice=${itemCostprice}`); |
|
|
console.log(`添加显示对象: weightSpec=${weightSpecDisplay}, quantity=${quantityDisplay}, price=${itemPrice}, costprice=${itemCostprice}, specStatus=${itemSpecStatus}`); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -525,6 +536,9 @@ Page({ |
|
|
console.log('product.specification:', product.specification); |
|
|
console.log('product.specification:', product.specification); |
|
|
console.log('product.quantity:', product.quantity); |
|
|
console.log('product.quantity:', product.quantity); |
|
|
console.log('product.minOrder:', product.minOrder); |
|
|
console.log('product.minOrder:', product.minOrder); |
|
|
|
|
|
// 添加spec_status字段调试
|
|
|
|
|
|
console.log('product.spec_status:', product.spec_status); |
|
|
|
|
|
console.log('是否包含spec_status字段:', 'spec_status' in product); |
|
|
|
|
|
|
|
|
if (product.spec && typeof product.spec === 'string' && (product.spec.includes('净重') || product.spec.includes('毛重'))) { |
|
|
if (product.spec && typeof product.spec === 'string' && (product.spec.includes('净重') || product.spec.includes('毛重'))) { |
|
|
// 如果规格字段包含净重或毛重信息,则使用该字段作为重量规格数据
|
|
|
// 如果规格字段包含净重或毛重信息,则使用该字段作为重量规格数据
|
|
|
@ -567,7 +581,7 @@ Page({ |
|
|
quantityString: quantityString |
|
|
quantityString: quantityString |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const weightQuantityData = processWeightAndQuantityData(weightSpecString, quantityString, '', product.price, product.costprice); |
|
|
const weightQuantityData = processWeightAndQuantityData(weightSpecString, quantityString, '', product.price, product.costprice, product.spec_status); |
|
|
|
|
|
|
|
|
console.log('=== 处理结果调试信息 ==='); |
|
|
console.log('=== 处理结果调试信息 ==='); |
|
|
console.log('weightSpecString:', weightSpecString); |
|
|
console.log('weightSpecString:', weightSpecString); |
|
|
|