fix(goods detail): fix stock display bug

master
waynaqua 3 years ago
parent fd25788f9a
commit 869d2ab942

@ -87,7 +87,10 @@ export default {
goods: {},
info: {},
name: '',
//
stockNum: 1,
//
totalStockNum: 0,
attributes: [],
comment: {},
description: '',
@ -111,6 +114,11 @@ export default {
this.info = goods.info
this.banner = goods.info.gallery
this.description = goods.info.detail
this.totalStockNum = goods.productList.reduce(function(o1, o2) {
// sum2
return ((o1.number || 0) + (o2.number || 0))
}, 0)
console.log('总库存:', this.totalStockNum)
this.skuAdapter()
this.isSkeletonShow = false
})
@ -119,7 +127,9 @@ export default {
const res = await getCommentTagNum({ goodsId: this.goodsId })
const res1 = await getCommentList({ tagType: 0, goodsId: this.goodsId })
const commentTagNum = res.map.commentTagNum
let goodsRate = Math.ceil(commentTagNum.goodsNum / commentTagNum.totalNum * 100)
let goodsRate = Math.ceil(
(commentTagNum.goodsNum / commentTagNum.totalNum) * 100
)
goodsRate = isNaN(goodsRate) ? 0 : goodsRate
this.comment = {
rate: goodsRate,
@ -139,7 +149,7 @@ export default {
const list = this.setSkuList()
const skuInfo = {
price: parseInt(this.goods.info.retailPrice), //
stock_num: 100, // TODO
stock_num: this.totalStockNum, //
collection_id: '', // skuIdcollection_idskuid
none_sku: false, //
hide_stock: false
@ -221,9 +231,8 @@ export default {
_.each(this.goods.productList, (v) => {
var skuListObj = {}
_.each(v.specifications, (specificationName, index) => {
skuListObj['s' + (~~index + 1)] = this.findSpecValueIdByName(
specificationName
)
skuListObj['s' + (~~index + 1)] =
this.findSpecValueIdByName(specificationName)
})
skuListObj.price = v.price * 100

Loading…
Cancel
Save