|
|
@ -840,53 +840,63 @@ Page({ |
|
|
const reservedGoodsIds = wx.getStorageSync('reservedGoodsIds') || [] |
|
|
const reservedGoodsIds = wx.getStorageSync('reservedGoodsIds') || [] |
|
|
|
|
|
|
|
|
// 将服务器返回的商品数据转换为本地需要的格式
|
|
|
// 将服务器返回的商品数据转换为本地需要的格式
|
|
|
const newGoods = pagedProducts.map(product => { |
|
|
const newGoods = pagedProducts.map(product => { |
|
|
// 处理grossWeight为null或无效的情况,返回空字符串以支持文字输入
|
|
|
// 处理grossWeight为null或无效的情况,返回空字符串以支持文字输入
|
|
|
const grossWeightValue = product.grossWeight !== null && product.grossWeight !== undefined ? product.grossWeight : ''; |
|
|
const grossWeightValue = product.grossWeight !== null && product.grossWeight !== undefined ? product.grossWeight : ''; |
|
|
|
|
|
|
|
|
// 确保商品ID的一致性
|
|
|
// 确保商品ID的一致性
|
|
|
const productIdStr = String(product.productId || product.id); |
|
|
const productIdStr = String(product.productId || product.id); |
|
|
|
|
|
|
|
|
// 增强的预约人数计算逻辑
|
|
|
// 增强的预约人数计算逻辑
|
|
|
const selectedValue = product.selected; |
|
|
const selectedValue = product.selected; |
|
|
const reservedCountValue = product.reservedCount; |
|
|
const reservedCountValue = product.reservedCount; |
|
|
const reservationCountValue = product.reservationCount; |
|
|
const reservationCountValue = product.reservationCount; |
|
|
|
|
|
|
|
|
const finalReservationCount = selectedValue !== undefined && selectedValue !== null ? selectedValue : |
|
|
const finalReservationCount = selectedValue !== undefined && selectedValue !== null ? selectedValue : |
|
|
(reservedCountValue !== undefined && reservedCountValue !== null ? reservedCountValue : |
|
|
(reservedCountValue !== undefined && reservedCountValue !== null ? reservedCountValue : |
|
|
(reservationCountValue || 0)); |
|
|
(reservationCountValue || 0)); |
|
|
|
|
|
|
|
|
return { |
|
|
// 转换supplyStatus字段值
|
|
|
id: productIdStr, |
|
|
let supplyStatusValue = product.supplyStatus || ''; |
|
|
productId: productIdStr, |
|
|
if (['平台货源', '三方认证'].includes(supplyStatusValue)) { |
|
|
name: product.productName, |
|
|
supplyStatusValue = '现货'; |
|
|
price: product.price, |
|
|
} else if (supplyStatusValue === '三方未认证') { |
|
|
minOrder: product.quantity, |
|
|
supplyStatusValue = '预售'; |
|
|
yolk: product.yolk, |
|
|
} |
|
|
spec: (product.spec && product.spec !== '无') ? product.spec : (product.specification && product.specification !== '无') ? product.specification : '', |
|
|
|
|
|
specification: (product.spec && product.spec !== '无') ? product.spec : (product.specification && product.specification !== '无') ? product.specification : '', |
|
|
return { |
|
|
region: product.region || '', // 【新增】添加地区字段
|
|
|
id: productIdStr, |
|
|
grossWeight: grossWeightValue, |
|
|
productId: productIdStr, |
|
|
displayGrossWeight: formatGrossWeight(grossWeightValue, product.weight), |
|
|
name: product.productName, |
|
|
seller: product.seller && (product.seller.name || product.seller.nickName) ? (product.seller.name || product.seller.nickName) : '未知卖家', |
|
|
price: product.price, |
|
|
status: product.status || 'published', |
|
|
minOrder: product.quantity, |
|
|
imageUrls: product.imageUrls || [], |
|
|
yolk: product.yolk, |
|
|
createdAt: product.created_at || product.createTime || null, |
|
|
spec: (product.spec && product.spec !== '无') ? product.spec : (product.specification && product.specification !== '无') ? product.specification : '', |
|
|
reservedCount: finalReservationCount, |
|
|
specification: (product.spec && product.spec !== '无') ? product.spec : (product.specification && product.specification !== '无') ? product.specification : '', |
|
|
product_contact: product.product_contact || '', // 【新增】添加联系人字段
|
|
|
region: product.region || '', // 【新增】添加地区字段
|
|
|
contact_phone: product.contact_phone || '', // 【新增】添加联系人电话字段
|
|
|
grossWeight: grossWeightValue, |
|
|
debugInfo: { |
|
|
displayGrossWeight: formatGrossWeight(grossWeightValue, product.weight), |
|
|
originalSelected: selectedValue, |
|
|
seller: product.seller && (product.seller.name || product.seller.nickName) ? (product.seller.name || product.seller.nickName) : '未知卖家', |
|
|
originalReservedCount: reservedCountValue, |
|
|
status: product.status || 'published', |
|
|
originalReservationCount: reservationCountValue |
|
|
imageUrls: product.imageUrls || [], |
|
|
}, |
|
|
createdAt: product.created_at || product.createTime || null, |
|
|
isReserved: reservedGoodsIds.some(id => |
|
|
reservedCount: finalReservationCount, |
|
|
String(id) === productIdStr || |
|
|
product_contact: product.product_contact || '', // 【新增】添加联系人字段
|
|
|
String(id) === String(product.id) |
|
|
contact_phone: product.contact_phone || '', // 【新增】添加联系人电话字段
|
|
|
), |
|
|
supplyStatus: supplyStatusValue, // 添加supplyStatus字段并进行转换
|
|
|
isFavorite: false, // 初始化收藏状态为false
|
|
|
sourceType: product.sourceType || '', // 新增sourceType字段
|
|
|
currentImageIndex: 0 |
|
|
debugInfo: { |
|
|
}; |
|
|
originalSelected: selectedValue, |
|
|
|
|
|
originalReservedCount: reservedCountValue, |
|
|
|
|
|
originalReservationCount: reservationCountValue |
|
|
|
|
|
}, |
|
|
|
|
|
isReserved: reservedGoodsIds.some(id => |
|
|
|
|
|
String(id) === productIdStr || |
|
|
|
|
|
String(id) === String(product.id) |
|
|
|
|
|
), |
|
|
|
|
|
isFavorite: false, // 初始化收藏状态为false
|
|
|
|
|
|
currentImageIndex: 0 |
|
|
|
|
|
}; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 过滤掉hidden状态的商品
|
|
|
// 过滤掉hidden状态的商品
|
|
|
|