Files
product-uniapp/components/ClassifyCard.vue
T
2025-12-12 18:34:44 +08:00

112 lines
2.3 KiB
Vue

<template>
<view class="card">
<view class="card-left" @click="$emit('view', item)">
<image class="card-img" :src="thumb" mode="aspectFit"></image>
</view>
<view class="card-right">
<view class="card-title line2" @click="$emit('view', item)">{{ item.content}}</view>
<view class="sku" @click="$emit('view', item)">{{ item.sku.model }}</view>
<view class="meta" @click="$emit('view', item)">
<text class="tag">#{{ item.age}}</text>
</view>
<view class="price-row">
<view @click="$emit('view', item)">
<text class="price">¥{{ item.price}}</text>
<text class="origin">¥{{ item.sku.price }}</text>
</view>
<uni-icons @click="$emit('start', item)" :type="item.is_favorite ? 'star-filled' : 'star'" :color="item.is_favorite ? '#05b3a8' : '#333'" size="18"></uni-icons>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'ClassifyCard',
props: {
item: {
type: Object,
required: true,
default: () => ({})
}
},
computed: {
thumb() {
const img = this.item.media?.[0]?.url_pull || this.item.cover || this.item.image?.[0]?.url_pull
return img || '/static/image/cp.png'
}
}
}
</script>
<style lang="scss" scoped>
.card {
display: flex;
gap: 16rpx;
padding: 16rpx;
background: #fff;
margin-bottom: 20rpx;
border-radius: 20rpx;
}
.card-left {
width: 180rpx;
position: relative;
}
.card-img {
width: 180rpx;
height: 180rpx;
background: #f5f5f5;
border-radius: 12rpx;
}
.card-right {
flex: 1;
display: flex;
flex-direction: column;
gap: 10rpx;
}
.card-title {
font-size: 26rpx;
color: #111;
line-height: 1.5;
}
.line2 {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.sku {
font-size: 22rpx;
color: #999;
}
.price-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10rpx;
}
.price {
font-size: 38rpx;
color: #00bfb2;
font-weight: 700;
margin-right: 10rpx;
}
.origin {
font-size: 22rpx;
color: #ccc;
text-decoration: line-through;
}
.meta {
display: flex;
gap: 10rpx;
}
.tag {
font-size: 22rpx;
color: #3BC6BD;
padding: 4rpx 28rpx;
background: rgb(59 198 189 / 0.1);
border-radius: 6rpx;
}
</style>