cm-product.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. <!-- <view class="tag type1">自营</view> -->
  12. <view class="tag type3">拼团价</view>
  13. <view class="tag type2" v-if="data.activeStatus == 1">活动价</view>
  14. <view class="tag type2" v-if="data.couponsLogo">优惠券</view>
  15. </view>
  16. <!-- 底部 -->
  17. <view class="footer">
  18. <!-- 价格 -->
  19. <view class="price">
  20. <text>¥{{ data.price | formatPrice }}</text>
  21. <text class="delete">¥{{ data.price | formatPrice }}</text>
  22. </view>
  23. <!-- 加入购物车 -->
  24. <view class="add-cart iconfont icon-gouwuche" @click.stop="addCart"></view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. name: 'cm-product',
  32. props: {
  33. data: {
  34. type: Object,
  35. default: () => {}
  36. }
  37. },
  38. methods: {
  39. // 跳转商品详情
  40. detail() {
  41. uni.navigateTo({
  42. url: `/pages/goods/product-detail?productId=${this.data.productId}&jumpState=1`
  43. })
  44. },
  45. // 加入购物车
  46. addCart() {
  47. this.$store.dispatch('cart/addToCart', { productId: this.data.productId })
  48. }
  49. }
  50. }
  51. </script>
  52. <style lang="scss" scoped>
  53. $width: 339rpx;
  54. $height: 532rpx;
  55. $radius: 16rpx;
  56. $grid: 24rpx;
  57. .cm-product {
  58. position: relative;
  59. width: $width;
  60. height: $height;
  61. background: #fff;
  62. border-radius: $radius;
  63. overflow: hidden;
  64. .recommend {
  65. position: absolute;
  66. top: 0;
  67. left: 34rpx;
  68. width: 68rpx;
  69. height: 55rpx;
  70. background: url(https://static.caimei365.com/app/mini-hehe/icon/recommend.png) no-repeat center;
  71. background-size: 68rpx 55rpx;
  72. }
  73. .cover {
  74. width: $width;
  75. height: $width;
  76. }
  77. .title,
  78. .tags,
  79. .footer {
  80. padding: 0 $grid;
  81. margin: 12rpx 0;
  82. }
  83. .title {
  84. height: 70rpx;
  85. font-size: 26rpx;
  86. line-height: 35rpx;
  87. color: #333333;
  88. overflow: hidden;
  89. text-overflow: ellipsis;
  90. display: -webkit-box;
  91. -webkit-line-clamp: 2; // 这里控制几行显示省略号
  92. -webkit-box-orient: vertical;
  93. }
  94. .tags {
  95. display: flex;
  96. justify-content: flex-start;
  97. align-items: center;
  98. height: 24rpx;
  99. .tag {
  100. display: flex;
  101. justify-content: center;
  102. align-items: center;
  103. height: 30rpx;
  104. margin-right: 8rpx;
  105. font-size: 22rpx;
  106. &.type1 {
  107. width: 56rpx;
  108. background: #ff457b;
  109. border-radius: 4rpx;
  110. color: #ffffff;
  111. }
  112. &.type2 {
  113. width: 80rpx;
  114. background: url(https://static.caimei365.com/app/mini-hehe/icon/icon-active.png) top center no-repeat;
  115. background-size: 80rpx 30rpx;
  116. color: #f83c6c;
  117. }
  118. &.type3 {
  119. width: 80rpx;
  120. background: linear-gradient(270deg, #ff457b 0%, #b03bb8 51%, #6431f2 100%);
  121. color: #fff;
  122. border-radius: 4rpx;
  123. }
  124. }
  125. }
  126. .footer {
  127. position: relative;
  128. .add-cart {
  129. position: absolute;
  130. bottom: 0;
  131. right: $grid;
  132. display: flex;
  133. justify-content: center;
  134. align-items: center;
  135. width: 44rpx;
  136. height: 44rpx;
  137. background: #ff457b;
  138. color: #fff;
  139. border-radius: 50%;
  140. }
  141. .price {
  142. overflow: hidden;
  143. text-overflow: ellipsis;
  144. display: -webkit-box;
  145. -webkit-line-clamp: 1; // 这里控制几行显示省略号
  146. -webkit-box-orient: vertical;
  147. box-sizing: border-box;
  148. padding-right: $grid;
  149. font-size: 26rpx;
  150. font-weight: 600;
  151. color: #f83c6c;
  152. .delete{
  153. font-size: 20rpx;
  154. color: #999999;
  155. text-decoration: line-through;
  156. font-weight: normal;
  157. margin-left: 10rpx;
  158. }
  159. }
  160. }
  161. }
  162. </style>