Files
frontend-app/components/shop/parity-product-item.vue
T
2026-07-25 09:12:36 +08:00

134 lines
2.7 KiB
Vue

<template>
<view class="parity-product-item" @click.stop="onClick">
<image class="top-img" :src="obj.url" mode="widthFix" lazy-load />
<view class="shop-bottom-panel">
<text class="title text-30 text-zu text-overflow">
{{ obj.title }}
</text>
<!-- 有优惠券 -->
<view class="flex-r-lr price-line coupon-line" v-if="obj.buyDeductionValue">
<view class="text-28 text-zi text-bold">
<view class="text-28 text-bold">{{ obj.buyDeductionValue }}数字积分</view>
<view class="text-24">+{{ obj.price }}元</view>
</view>
<text class="text-20 sold">兑换</text>
</view>
<!-- 无优惠券 -->
<view class="flex-r-lr price-line" v-else>
<text class="text-28 text-zi text-bold">¥{{ obj.price }}</text>
<text class="text-24 sold">全网销量{{ limit999(obj.sales) }}件</text>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'ParityProductItem',
props: {
obj: {
type: Object,
default: () => ({})
}
},
methods: {
limit999(n) {
const num = Number(n);
if (isNaN(num) || num < 10000) {
return n != null && n !== '' ? String(n) : '0';
}
return `${Math.floor(num / 10000)}万+`;
},
onClick() {
this.$emit('ok', this.obj.id);
}
}
};
</script>
<style lang="scss" scoped>
.parity-product-item {
width: 332rpx;
background: #fff;
border-radius: 12rpx;
overflow: hidden;
margin-bottom: 0;
/* 瀑布流父层控制间距,这里清零 */
}
.top-img {
width: 332rpx;
display: block;
border-radius: 12rpx 12rpx 0 0;
}
.shop-bottom-panel {
padding: 12rpx 16rpx 16rpx;
}
.title {
line-height: 40rpx;
max-width: 300rpx;
}
.price-line {
margin-top: 10rpx;
}
.sold {
color: #999;
}
/* 通用工具类(如已全局引入可删除) */
.text-overflow {
display: block;
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.text-30 {
font-size: 30rpx;
}
.text-28 {
font-size: 28rpx;
}
.text-24 {
font-size: 24rpx;
}
.text-zu {
color: #333;
}
.text-zi {
color: #7A35F6;
}
.text-bold {
font-weight: bold;
}
.flex-r-lr {
display: flex;
justify-content: space-between;
align-items: center;
}
.coupon-line {
.sold {
width: 98rpx;
height: 64rpx;
background: linear-gradient(270deg, #B164FB 0%, #7934F6 100%);
border-radius: 8rpx;
font-size: 30rpx;
color: #FFFFFF;
display: flex;
align-items: center;
justify-content: center;
}
}
</style>