fix(goods detail): fix stock display bug

master
waynaqua 3 years ago
parent fd25788f9a
commit 869d2ab942

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

Loading…
Cancel
Save