Files

585 lines
11 KiB
Vue
Raw Normal View History

2023-10-11 11:27:47 +08:00
<template>
<view
2023-11-14 17:21:03 +08:00
:class="{ goods: true, 'goods-card': card, 'goods-list': list, 'goods-min': min, 'goods-fill': fill, 'goods-round': round }"
@tap="toDetail"
2023-10-11 11:27:47 +08:00
>
<view
2023-11-14 17:21:03 +08:00
class="goods-header"
2023-10-11 11:27:47 +08:00
>
<view class="goods-thumb">
<image
2023-11-14 17:21:03 +08:00
:src="data.image"
class="goods-thumb-img"
style="object-fit: cover"
2023-10-11 11:27:47 +08:00
/>
</view>
</view>
<view :class="['goods-content']">
<view
2023-11-14 17:21:03 +08:00
class="goods-storeName"
>{{ data.storeName }}
</view>
2023-10-11 11:27:47 +08:00
<view
2023-11-14 17:21:03 +08:00
class="goods-list-model"
v-if="selectModel"
2023-10-11 11:27:47 +08:00
>
<div
2023-11-14 17:21:03 +08:00
class="goods-list-model-border"
@tap.stop="handleOpenSelect"
2023-10-11 11:27:47 +08:00
>
<view class="goods-list-model-label">{{ data.attrInfo.sku }}</view>
<view class="goods-list-model-action icon">
<image src="@/static/images/down.png" />
</view>
</div>
</view>
<view
2023-11-14 17:21:03 +08:00
class="goods-list-model-info"
v-if="model"
2023-10-11 11:27:47 +08:00
>
<view class="goods-list-model-label">{{ data.attrInfo.sku }}</view>
<!-- <view class="goods-list-model-info-label">颜色</view>
<view class="goods-list-model-info-value">黑色</view>
<view class="goods-list-model-info-label">尺码</view>
<view class="goods-list-model-info-value">M</view> -->
</view>
<view class="goods-info">
<view class="goods-info-left">
<view
2023-11-14 17:21:03 +08:00
class="goods-desc"
v-if="groupNum"
>{{ data.groupNum }}人团
</view>
2023-10-11 11:27:47 +08:00
<view
2023-11-14 17:21:03 +08:00
class="goods-price-row"
v-if="primary"
2023-10-11 11:27:47 +08:00
>
<view class="goods-price goods-price-primary">
2023-11-14 17:21:03 +08:00
¥{{price || data.price }}
2023-10-11 11:27:47 +08:00
</view>
<view
2023-11-14 17:21:03 +08:00
class="goods-price goods-price-original"
v-if="original"
2023-10-11 11:27:47 +08:00
>
¥{{ data.original }}
</view>
</view>
<view
2023-11-14 17:21:03 +08:00
class="goods-price goods-price-default"
v-if="!primary"
>
<slot
name="price"
:row="data"
>
¥{{price || data.price }}
</slot>
</view>
2023-10-11 11:27:47 +08:00
</view>
<view class="goods-info-action">
<view class="goods-info-action-btn">
<slot name="action"></slot>
</view>
<view
2023-11-14 17:21:03 +08:00
v-if="stock"
class="goods-info-action-desc"
2023-10-11 11:27:47 +08:00
>
2023-11-14 17:21:03 +08:00
<text v-if="data.stock">仅剩{{ data.stock }}</text>
<text v-else>库存不足</text>
2023-10-11 11:27:47 +08:00
</view>
<view
2023-11-14 17:21:03 +08:00
class="buy-num"
v-if="purchase"
2023-10-11 11:27:47 +08:00
>
<view class="buy-num-info-desc">
2023-11-14 17:21:03 +08:00
x{{ purchase }}
2023-10-11 11:27:47 +08:00
</view>
</view>
</view>
</view>
<view v-if="buyProgress">
<view class="buy-progress">
<view class="buy-progress-info">
<view
2023-11-14 17:21:03 +08:00
class="buy-progress-info-desc"
v-if="quantity"
2023-10-11 11:27:47 +08:00
>
限量{{ data.quantity }}
</view>
<uv-line-progress
2023-11-14 17:21:03 +08:00
:percentage="50"
:showText="false"
2023-10-11 11:27:47 +08:00
/>
</view>
<view class="buy-progress-action">
<uv-button
2023-11-14 17:21:03 +08:00
round
block
type="primary"
2023-10-11 11:27:47 +08:00
>
立即抢购
</uv-button>
</view>
</view>
</view>
</view>
<good-attr-select
2023-11-14 17:21:03 +08:00
ref="selectAttrPanel"
:id="data.id"
@select="handleSelectAttr"
2023-10-11 11:27:47 +08:00
/>
</view>
</template>
<script setup>
import { ref } from 'vue'
2023-11-14 17:21:03 +08:00
import { useRouter } from "@/hooks/useRouter";
const props = defineProps(['data', 'min', 'groupNum', 'original', 'stock', 'primary', 'card', 'list', 'buyProgress', 'quantity', 'selectModel', 'model', 'purchase', 'link', 'fill', 'round','price'])
2023-10-11 11:27:47 +08:00
// 团购人数
const groupNum = ref(props.groupNum)
// 剩余数量
const stock = ref(props.stock)
// 使用主题颜色的价格
const primary = ref(props.primary !== undefined)
// 卡片模式
const card = ref(props.card !== undefined)
// 列表模式
const list = ref(props.list !== undefined)
// 限量多少件
const quantity = ref(props.quantity)
// 显示购买进度
const buyProgress = ref(props.buyProgress)
// 选择规格
const selectModel = ref(props.selectModel !== undefined)
// 显示规格
const model = ref(props.model !== undefined)
// 购买数量
const purchase = ref(props.purchase)
2023-11-14 17:21:03 +08:00
// 购买价格
const price = ref(props.price)
2023-10-11 11:27:47 +08:00
// 原价
const original = ref(props.original)
2023-11-14 17:21:03 +08:00
2023-10-11 11:27:47 +08:00
// 小尺寸
const min = ref(props.min)
const selectAttrPanel = ref(null)
const link = ref(props.link !== undefined)
const fill = ref(props.fill !== undefined)
const round = ref(props.round !== undefined)
2023-11-14 17:21:03 +08:00
const {push} = useRouter()
2023-10-11 11:27:47 +08:00
const toDetail = () => {
2023-11-14 17:21:03 +08:00
if (!link.value) {
return
}
push({url: '/pages/goodsDetail/goodsDetail'}, {data: {id: props.data.id}})
2023-10-11 11:27:47 +08:00
}
const handleOpenSelect = () => {
selectAttrPanel.value.open()
}
const handleSelectAttr = () => {
}
</script>
2023-11-14 17:21:03 +08:00
<style lang="scss">
2023-10-11 11:27:47 +08:00
.goods {
position: relative;
padding: 30rpx 0;
&-card {
display: flex;
flex-direction: column;
.goods {
&-content {
padding: 0 20rpx;
display: flex;
flex-direction: column;
}
&-info {
margin-top: 15rpx;
}
&-thumb {
margin-bottom: 15rpx;
width: 100%;
&-img {
2023-11-14 17:21:03 +08:00
width: 300rpx;
height: 300rpx;
2023-10-11 11:27:47 +08:00
display: block;
}
}
}
}
2023-11-14 17:21:03 +08:00
&-header {
}
2023-10-11 11:27:47 +08:00
&-thumb {
background: #FAFAFA;
}
2023-11-14 17:21:03 +08:00
&-content {
}
2023-10-11 11:27:47 +08:00
&-storeName {
line-height: 40rpx;
font-size: 28rpx;
font-weight: 500;
color: #333333;
2023-11-14 17:21:03 +08:00
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
2023-10-11 11:27:47 +08:00
}
&-price {
&-row {
display: flex;
align-items: center;
2023-11-14 17:21:03 +08:00
.goods-price {
}
2023-10-11 11:27:47 +08:00
}
&-primary {
line-height: 42rpx;
font-size: 30rpx;
color: #EE6D46;
}
&-default {
2023-11-14 17:21:03 +08:00
line-height: 42rpx;
font-size: 30rpx;
color: #EE6D46;
2023-10-11 11:27:47 +08:00
}
&-original {
margin-left: 9rpx;
line-height: 28rpx;
font-size: 20rpx;
color: #999999;
text-decoration: line-through;
}
}
&-desc {
line-height: 33rpx;
font-size: 24rpx;
color: #999999;
}
&-info {
display: flex;
align-items: flex-end;
justify-content: space-between;
2023-11-14 17:21:03 +08:00
&-left {
}
2023-10-11 11:27:47 +08:00
&-action {
2023-11-14 17:21:03 +08:00
&-btn {
}
2023-10-11 11:27:47 +08:00
&-desc {
line-height: 28rpx;
font-size: 20rpx;
color: #999999;
}
}
}
&-image {
2023-11-14 17:21:03 +08:00
&-img {
}
2023-10-11 11:27:47 +08:00
}
&-list {
display: flex;
flex-direction: row;
2023-11-14 17:21:03 +08:00
padding: 40rpx 34rpx 30rpx;
2023-10-11 11:27:47 +08:00
box-sizing: border-box;
width: 100%;
.goods {
&-thumb {
margin-bottom: 0;
2023-11-14 17:21:03 +08:00
width: 200rpx;
height: 200rpx;
2023-10-11 11:27:47 +08:00
&-img {
width: 100%;
height: 100%;
display: block;
}
}
&-content {
2023-11-14 17:21:03 +08:00
margin-left: 40rpx;
2023-10-11 11:27:47 +08:00
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
2023-11-14 17:21:03 +08:00
width: 0;
2023-10-11 11:27:47 +08:00
}
}
&-model {
display: flex;
margin-bottom: 28rpx;
&-border {
display: flex;
align-items: center;
height: 40rpx;
border: 1px solid #CCCCCC;
opacity: 1;
border-radius: 0rpx;
padding: 0 10rpx;
}
2023-11-14 17:21:03 +08:00
&-info {
}
2023-10-11 11:27:47 +08:00
&-label {
line-height: 38rpx;
font-size: 24rpx;
color: #999999;
margin-right: 10rpx;
}
&-value {
line-height: 38rpx;
font-size: 24rpx;
color: #333333;
margin-right: 10rpx;
}
&-action {
width: 11rpx;
height: 7rpx;
}
}
}
&-min {
.goods {
&-thumb {
margin-bottom: 0;
width: 150rpx;
height: 150rpx;
&-img {
width: 100%;
height: 100%;
display: block;
}
}
}
}
&-fill {
padding-top: 0;
}
&-round {
border-radius: 20rpx;
overflow: hidden;
}
// .goods {
// padding: 16rpx 14rpx;
// &-header {
// display: flex;
// align-items: flex-start;
// }
// &-thumb {
// width: 220rpx;
// height: 220rpx;
// &-img {
// width: 100%;
// height: 100%;
// display: block;
// }
// }
// &-content {
// margin-top: 24rpx;
// margin-left: 40rpx;
// flex: 1
// }
// &-storeName {
// line-height: 40rpx;
// font-size: 28rpx;
// font-weight: 500;
// color: #333333;
// margin-bottom: 35rpx;
// }
// &-info {
// display: flex;
// align-items: center;
// justify-content: space-between;
// &-left {
// display: flex;
// align-items: flex-end;
// }
// &-action {
// &-btn {}
// &-desc {
// color: #999999;
// font-size: 24rpx;
// line-height: 40rpx;
// }
// }
// }
// &-price {
// &-default {
// line-height: 28rpx;
// font-size: 20rpx;
// color: #999999;
// }
// &-primary {
// line-height: 42rpx;
// font-size: 30rpx;
// font-weight: 500;
// color: #EE6D46;
// margin-left: 5rpx;
// }
// }
// &-desc {
// color: #999999;
// font-size: 24rpx;
// line-height: 40rpx;
// }
&-model {
display: inline-flex;
align-items: center;
width: auto;
height: 40rpx;
border: 1px solid #CCCCCC;
opacity: 1;
border-radius: 0rpx;
padding: 0 10rpx;
margin-bottom: 28rpx;
&-label {
line-height: 38rpx;
font-size: 24rpx;
color: #999999;
}
&-value {
line-height: 38rpx;
font-size: 24rpx;
color: #333333;
margin-right: 10rpx;
}
&-action {
width: 11rpx;
height: 7rpx;
}
}
// &-model-info {
// display: inline-flex;
// align-items: center;
// width: auto;
// height: 40rpx;
// opacity: 1;
// border-radius: 0rpx;
// margin-bottom: 28rpx;
// &-label {
// line-height: 38rpx;
// font-size: 24rpx;
// color: #999999;
// }
// &-value {
// line-height: 38rpx;
// font-size: 24rpx;
// color: #333333;
// margin-right: 10rpx;
// }
// &-action {
// width: 11rpx;
// height: 7rpx;
// }
// }
// }
}
.buy-progress {
display: flex;
align-items: center;
justify-content: space-between;
&-info {
flex: 1;
&-desc {
color: #999999;
font-size: 24rpx;
line-height: 32rpx;
}
}
&-action {
margin-left: 17rpx;
}
}
.buy-num {
&-info-desc {
color: #999999;
font-size: 24rpx;
line-height: 32rpx;
}
}
</style>