|
|
|
@ -705,12 +705,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 => { |
|
|
|
// 过滤隐藏状态的商品
|
|
|
|
newGoods = newGoods.filter(item => (item.status || '').toLowerCase() !== 'hidden') |
|
|
|
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 !== '全部') { |
|
|
|
|