|
|
|
@ -47,9 +47,6 @@ Page({ |
|
|
|
page: 1, |
|
|
|
pageSize: 8, |
|
|
|
|
|
|
|
// 库存总数
|
|
|
|
totalInventory: 0, |
|
|
|
|
|
|
|
// 商品数据缓存
|
|
|
|
goodsCache: [], |
|
|
|
categoryQueryCache: {}, |
|
|
|
@ -420,19 +417,6 @@ Page({ |
|
|
|
return ""; |
|
|
|
}, |
|
|
|
|
|
|
|
// 计算商品库存总数
|
|
|
|
calculateTotalInventory: function(goodsList) { |
|
|
|
let total = 0; |
|
|
|
goodsList.forEach(good => { |
|
|
|
if (good.minOrder && !isNaN(parseInt(good.minOrder))) { |
|
|
|
total += parseInt(good.minOrder); |
|
|
|
} else if (good.quantity && !isNaN(parseInt(good.quantity))) { |
|
|
|
total += parseInt(good.quantity); |
|
|
|
} |
|
|
|
}); |
|
|
|
return total; |
|
|
|
}, |
|
|
|
|
|
|
|
// 提取地区中的省份信息
|
|
|
|
extractProvince: function(region) { |
|
|
|
if (!region || typeof region !== 'string') { |
|
|
|
@ -466,6 +450,11 @@ Page({ |
|
|
|
// 确保商品ID的一致性
|
|
|
|
const productId = product.productId || product.id; |
|
|
|
|
|
|
|
// 计算库存总数
|
|
|
|
const minOrder = parseInt(product.minOrder) || 0; |
|
|
|
const quantity = parseInt(product.quantity) || 0; |
|
|
|
const totalStock = minOrder + quantity; |
|
|
|
|
|
|
|
return { |
|
|
|
...product, |
|
|
|
id: productId, // 统一使用id字段
|
|
|
|
@ -488,7 +477,8 @@ Page({ |
|
|
|
isReserved: false, |
|
|
|
isFavorite: false, |
|
|
|
currentImageIndex: 0, |
|
|
|
imageUrls: formattedImageUrls |
|
|
|
imageUrls: formattedImageUrls, |
|
|
|
totalStock: totalStock // 合并后的库存总数
|
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
@ -557,16 +547,12 @@ Page({ |
|
|
|
console.log('filteredGoods[1].category:', filteredGoods[1] ? filteredGoods[1].category : 'N/A') |
|
|
|
} |
|
|
|
|
|
|
|
// 计算库存总数
|
|
|
|
const totalInventory = this.calculateTotalInventory(updatedGoods); |
|
|
|
|
|
|
|
this.setData({ |
|
|
|
goods: updatedGoods, |
|
|
|
filteredGoods: filteredGoods, |
|
|
|
loadingMore: false, |
|
|
|
isLoading: false, |
|
|
|
page: this.data.page + 1, |
|
|
|
totalInventory: totalInventory |
|
|
|
page: this.data.page + 1 |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
@ -625,16 +611,12 @@ Page({ |
|
|
|
|
|
|
|
const filteredGoods = this.applyFilters(updatedGoods, false) |
|
|
|
|
|
|
|
// 计算库存总数
|
|
|
|
const totalInventory = this.calculateTotalInventory(updatedGoods); |
|
|
|
|
|
|
|
this.setData({ |
|
|
|
goods: updatedGoods, |
|
|
|
filteredGoods: filteredGoods, |
|
|
|
loadingMore: false, |
|
|
|
isLoading: false, |
|
|
|
page: this.data.page + 1, |
|
|
|
totalInventory: totalInventory |
|
|
|
page: this.data.page + 1 |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
|