Fix(商品详情):[#2297]无效的规格,仍然可以点击,并且未显示价格,库存显示undefined

This commit is contained in:
lifizer
2024-09-23 11:52:13 +08:00
parent 8bf30f6989
commit aa68c01ace
+18 -11
View File
@@ -42,10 +42,7 @@
<view class="titlev12-dark-text f12-font-32">购买数量</view>
<view class="carnum acea-row row-left">
<view style="border-radius: 40rpx 0rpx 0rpx 40rpx" class="cart-btn item reduce v12-font-36 v12-font-bold v12-white-text v12-dark1 v12-dark1-border" :class="cartNum <= 1 ? 'on' : ''" @click="CartNumDes">-</view>
<view class="item v12-font-36 v12-font-bold v12-dark-text
cart-btn">{{ cartNum }}</view>
<view class="item v12-font-36 v12-font-bold v12-dark-text cart-btn">{{ cartNum }}</view>
<view
style="border-radius:0 40rpx 40rpx 0"
class="item plus v12-font-bold v12-white-text v12-primary v12-primary-border v12-font-36 cart-btn"
@@ -68,7 +65,11 @@ export default {
props: {
attr: {
type: Object,
default: () => {}
default: () => {
return {
productAttr: []
}
}
},
// 使用字符串再转成对象的原因是,当key='2.5g'时,会变成key='2',导致数据丢失
productValueStr: {
@@ -102,12 +103,18 @@ export default {
this.$emit("changeFun", { action: "ChangeCartNum", value: 1 })
},
getAttrItemData(attr) {
let result = {}
this.productValueArr.map(item => {
if (item.attrItemkey === attr) {
result = item
}
})
let result = {
stock: 0
}
if (this.attr.productAttr.length === 1) {
this.productValueArr.map(item => {
if (item.attrItemkey === attr) {
result = item
}
})
} else {
result.stock = 1
}
return result
},
tapAttr: function(indexw, indexn, itemn) {