| .. | .. |
|---|
| 191 | 191 | </view> |
|---|
| 192 | 192 | <view>购物车</view> |
|---|
| 193 | 193 | </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"> |
|---|
| 195 | 195 | <form @submit="joinCart" report-submit="true"><button class="joinCart bnts" form-type="submit" |
|---|
| 196 | 196 | :class="(seckillId || (zoneId && zoneType == 2) || (couponMoneyType && couponMoneyType > 0) || productInfo.isVisual || birthdayGift) ? 'disable' : ''">加入购物车</button> |
|---|
| 197 | 197 | </form> |
|---|
| .. | .. |
|---|
| 208 | 208 | </view> |
|---|
| 209 | 209 | </block> |
|---|
| 210 | 210 | <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'"> |
|---|
| 212 | 212 | <form report-submit="true"><button class="buy bnts bg-color-hui" form-type="submit">已售罄</button></form> |
|---|
| 213 | 213 | </view> |
|---|
| 214 | 214 | <view class="bnt bntVideo acea-row" v-if="attr.productSelect.stock > 0 && type === 'video'"> |
|---|
| .. | .. |
|---|
| 475 | 475 | priceName: null, |
|---|
| 476 | 476 | }; |
|---|
| 477 | 477 | }, |
|---|
| 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 | + }, |
|---|
| 479 | 488 | watch: { |
|---|
| 480 | 489 | isLogin: { |
|---|
| 481 | 490 | handler: function (newV, oldV) { |
|---|