Jacob
2026-10-13 c0bd0b23ee40d6f3fea3a42c11c256622ab3e45a
pages/goods_details/index.vue
....@@ -191,7 +191,7 @@
191191 </view>
192192 <view>购物车</view>
193193 </view>
194
- <view class="bnt acea-row" v-if="productInfo.id && attr.productSelect && attr.productSelect.stock <= 0">
194
+ <view class="bnt acea-row" v-if="isStockEmpty">
195195 <form @submit="joinCart" report-submit="true"><button class="joinCart bnts" form-type="submit"
196196 :class="(seckillId || (zoneId && zoneType == 2) || (couponMoneyType && couponMoneyType > 0) || productInfo.isVisual || birthdayGift) ? 'disable' : ''">加入购物车</button>
197197 </form>
....@@ -208,7 +208,7 @@
208208 </view>
209209 </block>
210210 <view class="bnt bntVideo acea-row"
211
- v-if="productInfo.id && attr.productSelect && attr.productSelect.stock <= 0 && type === 'video'">
211
+ v-if="isStockEmpty && type === 'video'">
212212 <form report-submit="true"><button class="buy bnts bg-color-hui" form-type="submit">已售罄</button></form>
213213 </view>
214214 <view class="bnt bntVideo acea-row" v-if="attr.productSelect.stock > 0 && type === 'video'">
....@@ -475,7 +475,16 @@
475475 priceName: null,
476476 };
477477 },
478
- computed: mapGetters(['isLogin', 'uid', 'chatUrl']),
478
+ computed: {
479
+ ...mapGetters(['isLogin', 'uid', 'chatUrl']),
480
+ // 库存字段未加载(undefined/null)时不视为 0,避免详情接口返回前误显示已售罄
481
+ isStockEmpty() {
482
+ if (!this.productInfo.id) return false;
483
+ const stock = this.attr.productSelect && this.attr.productSelect.stock;
484
+ if (stock === undefined || stock === null || stock === '') return false;
485
+ return Number(stock) <= 0;
486
+ }
487
+ },
479488 watch: {
480489 isLogin: {
481490 handler: function (newV, oldV) {