|
|
|
@ -47,6 +47,9 @@ Page({ |
|
|
|
page: 1, |
|
|
|
pageSize: 8, |
|
|
|
|
|
|
|
// 库存总数
|
|
|
|
totalInventory: 0, |
|
|
|
|
|
|
|
// 商品数据缓存
|
|
|
|
goodsCache: [], |
|
|
|
categoryQueryCache: {}, |
|
|
|
@ -417,6 +420,19 @@ 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') { |
|
|
|
@ -541,12 +557,16 @@ 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 |
|
|
|
page: this.data.page + 1, |
|
|
|
totalInventory: totalInventory |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
@ -605,12 +625,16 @@ 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 |
|
|
|
page: this.data.page + 1, |
|
|
|
totalInventory: totalInventory |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
|