Jacob
2026-10-13 1d3f1ad9b368d1e15391e26d16497b8940cb5c74
components/productConSwiper/index.vue
....@@ -20,7 +20,7 @@
2020 <block v-for="(item,index) in imgUrls" :key='index'>
2121 <swiper-item>
2222 <image :src="item" class="slide-image" />
23
- <image v-if="!productSelect.stock||productSelect.stock<=0" style="position:absolute;left:0;top:0" class="slide-image" src="https://ossacmall.bluedeer.com.cn/app/static/images/noStock.png" mode="aspectFill"></image>
23
+ <image v-if="isSoldOut" style="position:absolute;left:0;top:0" class="slide-image" src="https://ossacmall.bluedeer.com.cn/app/static/images/noStock.png" mode="aspectFill"></image>
2424 </swiper-item>
2525 </block>
2626 </swiper>
....@@ -72,6 +72,16 @@
7272 type: 'image'
7373 };
7474 },
75
+ computed: {
76
+ // 库存字段未加载(undefined/null)时不视为 0,避免接口返回前误盖售罄水印
77
+ isSoldOut() {
78
+ const stock = this.productSelect && this.productSelect.stock;
79
+ if (stock === undefined || stock === null || stock === '') {
80
+ return false;
81
+ }
82
+ return Number(stock) <= 0;
83
+ }
84
+ },
7585 mounted() {
7686
7787 },