cm-cart-product.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view class="cart-product">
  3. <image class="cover" :src="productInfo.productImage" mode="widthFix"></image>
  4. <view class="content">
  5. <view class="name">{{ productInfo.name }}</view>
  6. <template v-if="isExpired">
  7. <view class="tip">商品已下架</view>
  8. </template>
  9. <template v-else>
  10. <view class="unit">规格:{{ productInfo.productUnit }}</view>
  11. <template>
  12. <view class="tags">
  13. <!-- 拼团价 活动价 限时特价 券后价 -->
  14. <view class="tag cx" v-if="userId === productInfo.heUserId">促销</view>
  15. <view class="tag cx" v-else>自营</view>
  16. <view class="tag pt" v-if="productInfo.collageStatus > 0">拼团价</view>
  17. <view class="tag hd" v-else-if="productInfo.activeStatus > 0">活动价</view>
  18. <view class="tag other" v-else-if="productInfo.discountStatus > 0">限时特价</view>
  19. </view>
  20. <template v-if="emptyStock">
  21. <view class="empty-stock">
  22. <view class="tip">重新选择商品规格</view>
  23. <view class="btn" @click="$emit('unitChange', productInfo)">重选</view>
  24. </view>
  25. </template>
  26. <template v-else>
  27. <view class="price">
  28. <text>¥{{ productInfo.price | priceFormat }}</text>
  29. <text class="delete" v-if="productInfo.normalPrice">
  30. ¥{{ productInfo.normalPrice | priceFormat }}
  31. </text>
  32. </view>
  33. <cm-number-box class="numberbox" v-model="productInfo.num" @change="change"></cm-number-box>
  34. </template>
  35. </template>
  36. </template>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. name: 'cm-cart-product',
  43. props: {
  44. isExpired: {
  45. type: Boolean,
  46. default: false
  47. },
  48. emptyStock: {
  49. type: Boolean,
  50. default: false
  51. },
  52. productInfo: {
  53. type: Object,
  54. default: () => {}
  55. },
  56. tagsList: {
  57. type: Array,
  58. default: () => []
  59. }
  60. },
  61. computed: {
  62. userId() {
  63. return this.$store.getters.userId
  64. },
  65. limitedNum() {
  66. if (this.productInfo.collageStatus > 0) {
  67. return this.productInfo.collageProduct.limitedNum || this.productInfo.stock
  68. } else {
  69. return this.productInfo.stock
  70. }
  71. }
  72. },
  73. methods: {
  74. change(value) {
  75. this.$emit('countChange', {
  76. cartId: this.productInfo.cartId,
  77. count: value
  78. })
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .cart-product {
  85. @extend .cm-flex-between;
  86. .cover {
  87. width: 180rpx;
  88. height: 180rpx;
  89. box-sizing: border-box;
  90. border: 1rpx dashed #e1e1e1;
  91. }
  92. .content {
  93. position: relative;
  94. display: flex;
  95. flex-direction: column;
  96. justify-content: center;
  97. flex: 1;
  98. margin-left: 16rpx;
  99. }
  100. .name {
  101. @include ellipsis(2);
  102. max-width: 440rpx;
  103. min-height: 68rpx;
  104. font-size: 26rpx;
  105. color: #333333;
  106. }
  107. .tip {
  108. margin-top: 80rpx;
  109. font-size: 26rpx;
  110. color: #f83c6c;
  111. }
  112. .empty-stock {
  113. display: flex;
  114. align-items: center;
  115. .tip {
  116. margin-top: 0;
  117. font-size: 28rpx;
  118. color: #666666;
  119. }
  120. .btn {
  121. font-size: 24rpx;
  122. color: #ff457b;
  123. border: 1rpx solid #ff457b;
  124. margin-left: 16rpx;
  125. box-sizing: border-box;
  126. line-height: 30rpx;
  127. padding: 0 12rpx;
  128. border-radius: 15rpx;
  129. }
  130. }
  131. .unit {
  132. min-height: 28rpx;
  133. font-size: 20rpx;
  134. color: #999999;
  135. }
  136. .tags {
  137. min-height: 30rpx;
  138. }
  139. .price {
  140. font-size: 26rpx;
  141. font-weight: 600;
  142. color: #f83c6c;
  143. .delete {
  144. font-size: 22rpx;
  145. color: #999999;
  146. font-weight: normal;
  147. text-decoration: line-through;
  148. margin-left: 8rpx;
  149. }
  150. }
  151. .numberbox {
  152. position: absolute;
  153. right: 0;
  154. bottom: 0;
  155. }
  156. }
  157. </style>