Feat(商品):1、库存为0时,加入购物车及立即购买变成灰色;2、库存为0时,相应规格右上角显示缺货标签,并且该缺货规格为灰色不可点击状态

This commit is contained in:
lifizer
2024-03-06 17:55:33 +08:00
parent 855ad17ed2
commit b92e043c77
4 changed files with 85 additions and 20 deletions
+21 -5
View File
@@ -20,12 +20,21 @@
<view class="title">{{ item.attrName }}</view>
<view class="listn acea-row row-middle">
<view
class="itemn"
:class="item.index == indexn ? 'on' : ''"
v-for="(itemn, indexn) in item.attrValue"
@click="tapAttr(indexw, indexn)"
:key="indexn"
>{{ itemn.attr }}</view>
:class="{
'on': item.index == indexn,
'disabled': productValue[itemn.attr].stock === 0
}"
class="itemn"
@click="tapAttr(indexw, indexn, itemn)"
>
{{ itemn.attr }}
<text
v-if="productValue[itemn.attr].stock === 0"
class="tag"
>缺货</text>
</view>
</view>
</view>
</view>
@@ -57,6 +66,10 @@ export default {
type: Object,
default: () => {}
},
productValue: {
type: Object,
default: () => {}
},
cartNum: {
type: Number,
default: () => 1
@@ -80,7 +93,10 @@ export default {
CartNumAdd: function() {
this.$emit("changeFun", { action: "ChangeCartNum", value: 1 });
},
tapAttr: function(indexw, indexn) {
tapAttr: function(indexw, indexn, itemn) {
if (this.productValue[itemn.attr].stock === 0) {
return
}
// 修改商品规格不生效的原因:
// H5端下面写法,attr更新,但是除H5外其他端不支持,
// 尽量避免下面的骚写法,不要在子组件内更新props