123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <template>
- <view class="cm-product" @click.stop="detail">
- <view class="recommend" v-if="data.recommend === '1'"></view>
- <!-- 封面 -->
- <image class="cover" :src="data.mainImage"></image>
- <view class="content">
- <!-- 标题名称 -->
- <view class="title">{{ data.name }}</view>
- <!-- 标签 -->
- <view class="tags">
- <!-- 拼团价 活动价 限时特价 券后价 -->
- <!-- 该商品参与了商城活动 -->
- <template v-if="isActivityProduct">
- <view class="tag pt" v-if="data.collageStatus > 0">拼团价</view>
- <view class="tag hd" v-else-if="data.activeStatus > 0">活动价</view>
- <view class="tag other" v-else-if="data.discountStatus > 0">限时特价</view>
- </template>
- <!-- 该商品未参与商城活动 -->
- <template v-else>
- <view class="tag other" v-if="data.couponStatus > 1">{{ data.couponInfo }}</view>
- <view class="tag other" v-else-if="data.couponStatus > 0">券后价</view>
- </template>
- </view>
- <!-- 底部 -->
- <view class="footer">
- <!-- 价格 -->
- <view class="price">
- <view class="delete">
- <text v-if="data.normalPrice">¥{{ data.normalPrice | priceFormat }}</text>
- </view>
- <view>¥{{ showPrice | priceFormat }}</view>
- </view>
- <!-- 加入购物车 -->
- <view
- class="add-cart iconfont icon-gouwuche"
- @click.stop="addCart"
- v-if="data.collageStatus !== 1"
- ></view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: 'cm-product',
- props: {
- data: {
- type: Object,
- default: () => {}
- }
- },
- computed: {
- isActivityProduct() {
- return this.data.collageStatus > 0 || this.data.activeStatus > 0 || this.data.discountStatus > 0
- },
- showPrice() {
- return this.data.couponStatus === 1 && !this.isActivityProduct ? this.data.couponPrice : this.data.price
- }
- },
- methods: {
- // 跳转商品详情
- detail() {
- this.$router.navigateTo(`goods/goods-detail?productId=${this.data.productId}&jumpState=1`)
- },
- // 加入购物车
- addCart() {
- this.$store.dispatch('cart/addToCart', { skuId: this.data.skuId })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- $width: 224rpx;
- $height: 430rpx;
- $radius: 16rpx;
- $grid: 16rpx;
- .cm-product {
- position: relative;
- width: $width;
- height: $height;
- background: #fff;
- border-radius: $radius;
- overflow: hidden;
- .recommend {
- position: absolute;
- top: 0;
- left: 34rpx;
- width: 68rpx;
- height: 55rpx;
- background: url(https://static.caimei365.com/app/mini-hehe/icon/recommend.png) no-repeat center;
- background-size: 68rpx 55rpx;
- }
- .cover {
- width: $width;
- height: $width;
- }
- .title,
- .tags,
- .footer {
- padding: 0 $grid;
- margin: 8rpx 0;
- }
- .title {
- height: 70rpx;
- font-size: 26rpx;
- line-height: 35rpx;
- text-align: justify;
- word-break: break-all;
- color: #333333;
- @include ellipsis(2);
- }
- .tags {
- @extend .cm-flex-center;
- justify-content: flex-start;
- height: 24rpx;
- }
- .footer {
- position: relative;
- .add-cart {
- position: absolute;
- bottom: 0;
- right: $grid;
- display: flex;
- justify-content: center;
- align-items: center;
- width: 44rpx;
- height: 44rpx;
- background: #ff457b;
- color: #fff;
- border-radius: 50%;
- }
- .price {
- height: 66rpx;
- box-sizing: border-box;
- padding-right: $grid;
- font-size: 26rpx;
- font-weight: 700;
- color: #f83c6c;
- .delete {
- height: 26rpx;
- margin-top: 4rpx;
- font-size: 20rpx;
- color: #999999;
- text-decoration: line-through;
- font-weight: normal;
- }
- }
- }
- }
- </style>
|