feat: 添加已售罄标签
This commit is contained in:
@@ -16,6 +16,15 @@
|
||||
goodsImg3: props.type == 3,
|
||||
}"
|
||||
>
|
||||
<view
|
||||
v-if="isSoldOut"
|
||||
class="sold-out-tag"
|
||||
:class="{
|
||||
sold1: props.type == 1,
|
||||
sold2: props.type == 2,
|
||||
sold3: props.type == 3,
|
||||
}"
|
||||
>已售罄</view>
|
||||
<image
|
||||
class=""
|
||||
:src="props.data.picUrl ? sheep.$url.cdn(props.data.picUrl) : '/static/icon/null1.png'"
|
||||
@@ -66,13 +75,28 @@
|
||||
> -->
|
||||
</view>
|
||||
<!-- -->
|
||||
<uni-badge :text="props.data.cartCount" v-if="props.type == 2 && props.data.cartCount" absolute="rightTop" :customStyle="{background: '#FF0000'}">
|
||||
<view class="shopIcon" :class="{ 'shopIcon1': props.type == 2 }" @click.stop="onShopIconClick">
|
||||
<uni-badge
|
||||
v-if="!isSoldOut && props.type == 2 && props.data.cartCount"
|
||||
:text="props.data.cartCount"
|
||||
absolute="rightTop"
|
||||
:customStyle="{background: '#FF0000'}"
|
||||
>
|
||||
<view
|
||||
class="shopIcon"
|
||||
:class="{ 'shopIcon1': props.type == 2, 'shop-icon-soldout': isSoldOut }"
|
||||
@click.stop="onShopIconClick"
|
||||
>
|
||||
<image src="/static/index/shop.png" mode="scaleToFill" />
|
||||
</view>
|
||||
</uni-badge>
|
||||
<view class="shopIcon" :class="{ 'shopIcon1': props.type == 2 }" @click.stop="onShopIconClick" v-else>
|
||||
<image src="/static/index/shop.png" mode="scaleToFill" />
|
||||
<view
|
||||
class="shopIcon"
|
||||
:class="{ 'shopIcon1': props.type == 2, 'shop-icon-soldout': isSoldOut }"
|
||||
@click.stop="onShopIconClick"
|
||||
v-else
|
||||
>
|
||||
<image v-if="!isSoldOut" src="/static/index/shop.png" mode="scaleToFill" />
|
||||
<view v-else class="shop-soldout-tip">售罄</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -90,7 +114,7 @@
|
||||
|
||||
<script setup>
|
||||
import sheep from '@/sheep';
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { ref, reactive, watch, computed } from 'vue';
|
||||
import SpuApi from '@/sheep/api/product/spu';
|
||||
import { fen2yuan } from '@/sheep/hooks/useGoods';
|
||||
|
||||
@@ -123,6 +147,11 @@
|
||||
deep: true,
|
||||
},
|
||||
);
|
||||
|
||||
const isSoldOut = computed(() => {
|
||||
return Number(props.data.stock || 0) <= 0;
|
||||
});
|
||||
|
||||
let showSelectSku = ref(false);
|
||||
const goDetail = () => {
|
||||
sheep.$router.go('/pages/goods/info', { id: props.data.id });
|
||||
@@ -138,6 +167,7 @@
|
||||
});
|
||||
};
|
||||
const onShopIconClick = () => {
|
||||
if (isSoldOut.value) return;
|
||||
if (props.memberPreferred) {
|
||||
buyMemberGoods();
|
||||
return;
|
||||
@@ -216,6 +246,37 @@
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.sold-out-tag {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
z-index: 3;
|
||||
color: #ffffff;
|
||||
font-weight: 600;
|
||||
background: rgba(0, 0, 0, 0.58);
|
||||
border-radius: 0 0 0 8rpx;
|
||||
backdrop-filter: blur(2px);
|
||||
text-align: center;
|
||||
}
|
||||
.sold-out-tag.sold1 {
|
||||
width: 108rpx;
|
||||
height: 52rpx;
|
||||
line-height: 52rpx;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
.sold-out-tag.sold2 {
|
||||
width: 96rpx;
|
||||
height: 44rpx;
|
||||
line-height: 44rpx;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.sold-out-tag.sold3 {
|
||||
width: 76rpx;
|
||||
height: 36rpx;
|
||||
line-height: 36rpx;
|
||||
font-size: 18rpx;
|
||||
}
|
||||
|
||||
.goodItem {
|
||||
padding: 20rpx 24rpx;
|
||||
box-sizing: border-box;
|
||||
@@ -265,6 +326,22 @@
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
.shop-icon-soldout {
|
||||
background: #cccccc;
|
||||
filter: grayscale(100%);
|
||||
border-radius: 50%;
|
||||
cursor: not-allowed;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.shop-soldout-tip {
|
||||
font-size: 18rpx;
|
||||
color: #ffffff;
|
||||
font-weight: 600;
|
||||
text-align: center;
|
||||
line-height: 1.2;
|
||||
}
|
||||
}
|
||||
.shrink{
|
||||
border-radius: 10rpx;
|
||||
|
||||
Reference in New Issue
Block a user