cm-product.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view class="cm-product" @click.stop="detail">
  3. <view class="recommend" v-if="data.recommend === '1'"></view>
  4. <!-- 封面 -->
  5. <image class="cover" :src="data.mainImage"></image>
  6. <view class="content">
  7. <!-- 标题名称 -->
  8. <view class="title">{{ data.name }}</view>
  9. <!-- 标签 -->
  10. <view class="tags">
  11. <!-- 拼团价 活动价 限时特价 券后价 -->
  12. <!-- 该商品参与了商城活动 -->
  13. <template v-if="isActivityProduct">
  14. <view class="tag pt" v-if="data.collageStatus > 0">拼团价</view>
  15. <view class="tag hd" v-else-if="data.activeStatus > 0">活动价</view>
  16. <view class="tag other" v-else-if="data.discountStatus > 0">限时特价</view>
  17. </template>
  18. <!-- 该商品未参与商城活动 -->
  19. <template v-else>
  20. <view class="tag other" v-if="data.couponStatus > 1">{{ data.couponInfo }}</view>
  21. <view class="tag other" v-else-if="data.couponStatus > 0">券后价</view>
  22. </template>
  23. </view>
  24. <!-- 底部 -->
  25. <view class="footer">
  26. <!-- 价格 -->
  27. <view class="price">
  28. <view class="delete">
  29. <text v-if="data.normalPrice">¥{{ data.normalPrice | priceFormat }}</text>
  30. </view>
  31. <view>¥{{ showPrice | priceFormat }}</view>
  32. </view>
  33. <!-- 加入购物车 -->
  34. <view
  35. class="add-cart iconfont icon-gouwuche"
  36. @click.stop="addCart"
  37. v-if="data.collageStatus !== 1"
  38. ></view>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. name: 'cm-product',
  46. props: {
  47. data: {
  48. type: Object,
  49. default: () => {}
  50. }
  51. },
  52. computed: {
  53. isActivityProduct() {
  54. return this.data.collageStatus > 0 || this.data.activeStatus > 0 || this.data.discountStatus > 0
  55. },
  56. showPrice() {
  57. return this.data.couponStatus === 1 && !this.isActivityProduct ? this.data.couponPrice : this.data.price
  58. }
  59. },
  60. methods: {
  61. // 跳转商品详情
  62. detail() {
  63. this.$router.navigateTo(`goods/goods-detail?productId=${this.data.productId}&jumpState=1`)
  64. },
  65. // 加入购物车
  66. addCart() {
  67. this.$store.dispatch('cart/addToCart', { skuId: this.data.skuId })
  68. }
  69. }
  70. }
  71. </script>
  72. <style lang="scss" scoped>
  73. $width: 224rpx;
  74. $height: 430rpx;
  75. $radius: 16rpx;
  76. $grid: 16rpx;
  77. .cm-product {
  78. position: relative;
  79. width: $width;
  80. height: $height;
  81. background: #fff;
  82. border-radius: $radius;
  83. overflow: hidden;
  84. .recommend {
  85. position: absolute;
  86. top: 0;
  87. left: 34rpx;
  88. width: 68rpx;
  89. height: 55rpx;
  90. background: url(https://static.caimei365.com/app/mini-hehe/icon/recommend.png) no-repeat center;
  91. background-size: 68rpx 55rpx;
  92. }
  93. .cover {
  94. width: $width;
  95. height: $width;
  96. }
  97. .title,
  98. .tags,
  99. .footer {
  100. padding: 0 $grid;
  101. margin: 8rpx 0;
  102. }
  103. .title {
  104. height: 70rpx;
  105. font-size: 26rpx;
  106. line-height: 35rpx;
  107. text-align: justify;
  108. word-break: break-all;
  109. color: #333333;
  110. @include ellipsis(2);
  111. }
  112. .tags {
  113. @extend .cm-flex-center;
  114. justify-content: flex-start;
  115. height: 24rpx;
  116. }
  117. .footer {
  118. position: relative;
  119. .add-cart {
  120. position: absolute;
  121. bottom: 0;
  122. right: $grid;
  123. display: flex;
  124. justify-content: center;
  125. align-items: center;
  126. width: 44rpx;
  127. height: 44rpx;
  128. background: #ff457b;
  129. color: #fff;
  130. border-radius: 50%;
  131. }
  132. .price {
  133. height: 66rpx;
  134. box-sizing: border-box;
  135. padding-right: $grid;
  136. font-size: 26rpx;
  137. font-weight: 700;
  138. color: #f83c6c;
  139. .delete {
  140. height: 26rpx;
  141. margin-top: 4rpx;
  142. font-size: 20rpx;
  143. color: #999999;
  144. text-decoration: line-through;
  145. font-weight: normal;
  146. }
  147. }
  148. }
  149. }
  150. </style>