cm-product.vue 3.8 KB

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