goods-price.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view class="goods-price" v-if="productData">
  3. <view class="row">
  4. <view class="price">
  5. <text class="amount">{{ productData.price | priceFormat }}</text>
  6. <text class="delete">{{ productData.normalPrice | priceFormat }}</text>
  7. </view>
  8. <view class="price-tags">
  9. <template v-if="priceType !== 'normal'">
  10. <view class="tag-pt" v-if="priceType === 'group'">拼团价</view>
  11. <view class="tag-hd" v-else-if="priceType === 'activity'">活动价</view>
  12. <view class="tag-xs" v-else>限时特价</view>
  13. </template>
  14. </view>
  15. </view>
  16. <view class="row" v-if="hasCouponPrice">
  17. <!-- 券后价 -->
  18. <view class="tag-qh">券后价¥{{ productData.couponPrice | priceFormat }}</view>
  19. </view>
  20. <!-- 限时特价结束时间 -->
  21. <view class="countdown-box" v-if="priceType === 'time-limit'">
  22. <view class="tip">距离结束</view>
  23. <view class="time">
  24. <!-- 时 -->
  25. <text class="hh">72</text>
  26. :
  27. <!-- 分 -->
  28. <text class="mm">48</text>
  29. :
  30. <!-- 秒 -->
  31. <text class="ss">33</text>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. name: 'goods-price',
  39. props: {
  40. productData: {
  41. type: Object,
  42. default: () => null
  43. }
  44. },
  45. computed: {
  46. /* 商品价格类型 normal: 普通价 | group: 拼团价 | activity: 活动价 | time-limit: 限时特价 | */
  47. priceType() {
  48. let type
  49. if (this.productData.activeStatus > 0) {
  50. type = 'activity'
  51. } else if (this.productData.collageStatus > 0) {
  52. type = 'group'
  53. } else if (this.productData.discountStatus > 0) {
  54. type = 'time-limit'
  55. } else {
  56. type = 'normal'
  57. }
  58. return type
  59. },
  60. // 有可使用优惠券
  61. hasCouponPrice() {
  62. return this.couponStatus > 0
  63. }
  64. }
  65. }
  66. </script>
  67. <style lang="scss" scoped>
  68. .goods-price {
  69. position: relative;
  70. padding: 24rpx;
  71. background-color: #fff;
  72. .row {
  73. @extend .cm-flex-center;
  74. justify-content: flex-start;
  75. &:nth-child(2) {
  76. margin-top: 4rpx;
  77. }
  78. }
  79. .price {
  80. .amount {
  81. font-size: 48rpx;
  82. font-weight: bold;
  83. color: #ff457b;
  84. &::before {
  85. content: '¥';
  86. font-size: 24rpx;
  87. vertical-align: 2rpx;
  88. }
  89. }
  90. .delete {
  91. margin-left: 16rpx;
  92. font-size: 26rpx;
  93. font-weight: 400;
  94. color: #999999;
  95. text-decoration: line-through;
  96. &::before {
  97. content: '¥';
  98. }
  99. }
  100. }
  101. .price-tags {
  102. margin-left: 24rpx;
  103. @extend .cm-flex-center;
  104. justify-content: flex-start;
  105. margin-top: 10rpx;
  106. .tag-pt {
  107. @extend .cm-flex-center;
  108. height: 32rpx;
  109. padding: 0 8rpx;
  110. background: linear-gradient(90deg, #6431f2 0%, #b03bb8 49%, #ff457b 100%);
  111. border-radius: 4rpx;
  112. font-size: 22rpx;
  113. color: #fff;
  114. }
  115. .tag-hd,
  116. .tag-xs {
  117. @extend .cm-flex-center;
  118. display: block;
  119. height: 30rpx;
  120. padding: 0 8rpx;
  121. background: #fff3f7;
  122. border: 1rpx solid #ff457b;
  123. border-radius: 4rpx;
  124. font-size: 22rpx;
  125. color: #ff457b;
  126. }
  127. }
  128. .tag-qh {
  129. @extend .cm-flex-center;
  130. height: 40rpx;
  131. background: #ff457b;
  132. border-radius: 25rpx;
  133. padding: 0 15rpx;
  134. font-size: 24rpx;
  135. font-weight: bold;
  136. color: #ffffff;
  137. }
  138. }
  139. .countdown-box {
  140. position: absolute;
  141. top: 50%;
  142. right: 24rpx;
  143. transform: translateY(-50%);
  144. @extend .cm-flex-center;
  145. flex-direction: column;
  146. width: 160rpx;
  147. .tip {
  148. font-size: 24rpx;
  149. color: #ff457b;
  150. }
  151. .time {
  152. margin-top: 20rpx;
  153. width: 160rpx;
  154. @extend .cm-flex-between;
  155. font-size: 24rpx;
  156. font-weight: bold;
  157. color: #333333;
  158. text {
  159. @extend .cm-flex-center;
  160. width: 40rpx;
  161. height: 40rpx;
  162. background: #333;
  163. border-radius: 4rpx;
  164. color: #ffffff;
  165. }
  166. }
  167. }
  168. </style>