| .. | .. |
|---|
| 20 | 20 | <block v-for="(item,index) in imgUrls" :key='index'> |
|---|
| 21 | 21 | <swiper-item> |
|---|
| 22 | 22 | <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> |
|---|
| 24 | 24 | </swiper-item> |
|---|
| 25 | 25 | </block> |
|---|
| 26 | 26 | </swiper> |
|---|
| .. | .. |
|---|
| 72 | 72 | type: 'image' |
|---|
| 73 | 73 | }; |
|---|
| 74 | 74 | }, |
|---|
| 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 | + }, |
|---|
| 75 | 85 | mounted() { |
|---|
| 76 | 86 | |
|---|
| 77 | 87 | }, |
|---|