|
|
|
@ -678,39 +678,47 @@ Page({ |
|
|
|
const formattedSpec = this.formatSpecification(product.specification || product.spec || '', product.yolk || ''); |
|
|
|
|
|
|
|
return { |
|
|
|
...product, |
|
|
|
id: productId, // 统一使用id字段
|
|
|
|
productId: productId, // 同时保留productId字段
|
|
|
|
category: product.category || '', |
|
|
|
fullRegion: product.region || '', |
|
|
|
region: product.region ? this.extractProvince(product.region) : '', |
|
|
|
grossWeight: product.grossWeight || product.weight || '', |
|
|
|
displayGrossWeight: product.grossWeight || product.weight || '', |
|
|
|
status: product.status, |
|
|
|
createdAt: product.created_at || product.createTime || null, |
|
|
|
reservedCount: product.reservedCount || product.selected || 0, |
|
|
|
reservedCountDisplay: product.reservedCount || product.selected || 0, |
|
|
|
sales: product.sales || product.reservedCount || Math.floor(Math.random() * 1000) + 100, |
|
|
|
product_contact: product.product_contact || '', |
|
|
|
contact_phone: product.contact_phone || '', |
|
|
|
supplyStatus: product.supplyStatus || '', |
|
|
|
sourceType: product.sourceType || '', |
|
|
|
negotiateStatus: '可议价', |
|
|
|
isReserved: false, |
|
|
|
isFavorite: false, |
|
|
|
currentImageIndex: 0, |
|
|
|
imageUrls: formattedImageUrls, |
|
|
|
// 添加预处理后的媒体数据,包含类型信息
|
|
|
|
mediaItems: mediaItems, |
|
|
|
totalStock: displayStock, // 使用优化后的库存显示值
|
|
|
|
originalTotalStock: totalStock, // 保留原始计算值用于调试
|
|
|
|
displaySpecification: formattedSpec.displaySpec, // 格式化后的规格
|
|
|
|
displayYolk: formattedSpec.displayYolk // 格式化后的蛋黄
|
|
|
|
} |
|
|
|
...product, |
|
|
|
id: productId, // 统一使用id字段
|
|
|
|
productId: productId, // 同时保留productId字段
|
|
|
|
category: product.category || '', |
|
|
|
fullRegion: product.region || '', |
|
|
|
region: product.region ? this.extractProvince(product.region) : '', |
|
|
|
grossWeight: product.grossWeight || product.weight || '', |
|
|
|
displayGrossWeight: product.grossWeight || product.weight || '', |
|
|
|
status: product.status, |
|
|
|
createdAt: product.created_at || product.createTime || null, |
|
|
|
reservedCount: product.reservedCount || product.selected || 0, |
|
|
|
reservedCountDisplay: product.reservedCount || product.selected || 0, |
|
|
|
sales: product.sales || product.reservedCount || Math.floor(Math.random() * 1000) + 100, |
|
|
|
product_contact: product.product_contact || '', |
|
|
|
contact_phone: product.contact_phone || '', |
|
|
|
supplyStatus: product.supplyStatus || '', |
|
|
|
sourceType: product.sourceType || '', |
|
|
|
negotiateStatus: '可议价', |
|
|
|
isReserved: false, |
|
|
|
isFavorite: false, |
|
|
|
currentImageIndex: 0, |
|
|
|
imageUrls: formattedImageUrls, |
|
|
|
// 添加预处理后的媒体数据,包含类型信息
|
|
|
|
mediaItems: mediaItems, |
|
|
|
totalStock: displayStock, // 使用优化后的库存显示值
|
|
|
|
originalTotalStock: totalStock, // 保留原始计算值用于调试
|
|
|
|
displaySpecification: formattedSpec.displaySpec, // 格式化后的规格
|
|
|
|
displayYolk: formattedSpec.displayYolk, // 格式化后的蛋黄
|
|
|
|
price: product.price !== undefined ? product.price : '' // 确保price字段存在
|
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
// 过滤隐藏状态的商品
|
|
|
|
newGoods = newGoods.filter(item => (item.status || '').toLowerCase() !== 'hidden') |
|
|
|
// 过滤隐藏状态的商品,并确保商品对象有效
|
|
|
|
newGoods = newGoods.filter(item => { |
|
|
|
// 过滤隐藏状态的商品
|
|
|
|
if ((item.status || '').toLowerCase() === 'hidden') { |
|
|
|
return false; |
|
|
|
} |
|
|
|
// 确保商品对象有必要的字段
|
|
|
|
return item && item.id && item.name; |
|
|
|
}); |
|
|
|
|
|
|
|
// 先对新商品进行内部查重
|
|
|
|
const uniqueNewGoodsMap = new Map(); |
|
|
|
@ -877,11 +885,20 @@ Page({ |
|
|
|
totalStock: displayStock, // 使用优化后的库存显示值
|
|
|
|
originalTotalStock: totalStock, // 保留原始计算值用于调试
|
|
|
|
displaySpecification: formattedSpec.displaySpec, // 格式化后的规格
|
|
|
|
displayYolk: formattedSpec.displayYolk // 格式化后的蛋黄
|
|
|
|
displayYolk: formattedSpec.displayYolk, // 格式化后的蛋黄
|
|
|
|
price: product.price !== undefined ? product.price : '' // 确保price字段存在
|
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
newGoods = newGoods.filter(item => (item.status || '').toLowerCase() !== 'hidden') |
|
|
|
// 过滤隐藏状态的商品,并确保商品对象有效
|
|
|
|
newGoods = newGoods.filter(item => { |
|
|
|
// 过滤隐藏状态的商品
|
|
|
|
if ((item.status || '').toLowerCase() === 'hidden') { |
|
|
|
return false; |
|
|
|
} |
|
|
|
// 确保商品对象有必要的字段
|
|
|
|
return item && item.id && item.name; |
|
|
|
}); |
|
|
|
|
|
|
|
// 对新商品进行内部查重
|
|
|
|
const newGoodsMap = new Map(); |
|
|
|
@ -1272,7 +1289,8 @@ Page({ |
|
|
|
currentImageIndex: 0, |
|
|
|
imageUrls: formattedImageUrls, |
|
|
|
totalStock: displayStock, // 使用优化后的库存显示值
|
|
|
|
originalTotalStock: totalStock // 保留原始计算值用于调试
|
|
|
|
originalTotalStock: totalStock, // 保留原始计算值用于调试
|
|
|
|
price: product.price !== undefined ? product.price : '' // 确保price字段存在
|
|
|
|
}; |
|
|
|
|
|
|
|
goodsMap.set(productId, processedProduct); |
|
|
|
@ -1282,15 +1300,21 @@ Page({ |
|
|
|
// 转换为数组
|
|
|
|
const processedGoods = Array.from(goodsMap.values()); |
|
|
|
|
|
|
|
// 确保商品对象有效
|
|
|
|
const validGoods = processedGoods.filter(item => { |
|
|
|
// 确保商品对象有必要的字段
|
|
|
|
return item && item.id && item.name; |
|
|
|
}); |
|
|
|
|
|
|
|
// 更新收藏状态
|
|
|
|
this.updateGoodsFavoriteStatus(processedGoods, false); |
|
|
|
this.updateGoodsFavoriteStatus(validGoods, false); |
|
|
|
|
|
|
|
// 应用筛选条件
|
|
|
|
const filteredGoods = this.applyFilters(processedGoods, true); |
|
|
|
const filteredGoods = this.applyFilters(validGoods, true); |
|
|
|
const groupedGoods = this.groupGoodsForStaggeredLayout(filteredGoods); |
|
|
|
|
|
|
|
this.setData({ |
|
|
|
goods: processedGoods, |
|
|
|
goods: validGoods, |
|
|
|
filteredGoods: filteredGoods, |
|
|
|
groupedGoods: groupedGoods, |
|
|
|
loadingMore: false, |
|
|
|
@ -1352,14 +1376,14 @@ Page({ |
|
|
|
|
|
|
|
console.log('applyFilters - 开始过滤,原始商品数量:', goods.length, '关键词:', this.data.searchKeyword); |
|
|
|
|
|
|
|
// 移除所有不必要的过滤条件,确保所有published和sold_out状态的商品都能显示
|
|
|
|
// 过滤商品:广告位不受影响,只显示有价格的商品
|
|
|
|
filtered = filtered.filter(item => { |
|
|
|
// 广告位不受影响
|
|
|
|
if (item.isAd) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
// 所有published和sold_out状态的商品都保留
|
|
|
|
return true; |
|
|
|
// 只显示有价格的商品
|
|
|
|
return item.price && item.price !== ''; |
|
|
|
}); |
|
|
|
|
|
|
|
if (this.data.selectedCategory !== '全部') { |
|
|
|
|