cm-cart-product.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. <view class="tags">
  12. <!-- 拼团价 活动价 限时特价 券后价 -->
  13. <view class="tag cx" v-if="userId === productInfo.heUserId">促销</view>
  14. <view class="tag cx" v-else>自营</view>
  15. <view class="tag pt" v-if="productInfo.collageStatus > 0">拼团价</view>
  16. <view class="tag hd" v-else-if="productInfo.activeStatus > 0">活动价</view>
  17. <view class="tag other" v-else-if="productInfo.discountStatus > 0">限时特价</view>
  18. <!-- <view class="tag other" v-else-if="productInfo.couponStatus > 1">{{ productInfo.couponInfo }}</view> -->
  19. <!-- <view class="tag other" v-else-if="productInfo.couponStatus > 0">券后价</view> -->
  20. </view>
  21. <view class="price">
  22. <text>¥{{ productInfo.price | priceFormat }}</text>
  23. <text class="delete" v-if="productInfo.normalPrice">
  24. ¥{{ productInfo.normalPrice | priceFormat }}
  25. </text>
  26. </view>
  27. <cm-number-box class="numberbox" v-model="productInfo.num" @change="change"></cm-number-box>
  28. <!-- <uni-number-box class="numberbox" v-model="productInfo.num" @change="change" :min="1"></uni-number-box> -->
  29. </template>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. name: 'cm-cart-product',
  36. props: {
  37. isExpired: {
  38. type: Boolean,
  39. default: false
  40. },
  41. productInfo: {
  42. type: Object,
  43. default: () => {}
  44. },
  45. tagsList: {
  46. type: Array,
  47. default: () => []
  48. }
  49. },
  50. computed: {
  51. userId() {
  52. return this.$store.getters.userId
  53. },
  54. limitedNum() {
  55. if (this.productInfo.collageStatus > 0) {
  56. return this.productInfo.collageProduct.limitedNum || this.productInfo.stock
  57. } else {
  58. return this.productInfo.stock
  59. }
  60. }
  61. },
  62. methods: {
  63. change(value) {
  64. this.$emit('countChange', {
  65. cartId: this.productInfo.cartId,
  66. count: value
  67. })
  68. }
  69. }
  70. }
  71. </script>
  72. <style lang="scss" scoped>
  73. .cart-product {
  74. @extend .cm-flex-between;
  75. .cover {
  76. width: 180rpx;
  77. height: 180rpx;
  78. box-sizing: border-box;
  79. border: 1rpx dashed #e1e1e1;
  80. }
  81. .content {
  82. position: relative;
  83. display: flex;
  84. flex-direction: column;
  85. justify-content: center;
  86. flex: 1;
  87. margin-left: 16rpx;
  88. }
  89. .name {
  90. @include ellipsis(2);
  91. max-width: 440rpx;
  92. min-height: 68rpx;
  93. font-size: 26rpx;
  94. color: #333333;
  95. }
  96. .tip {
  97. margin-top: 80rpx;
  98. font-size: 26rpx;
  99. color: #f83c6c;
  100. }
  101. .unit {
  102. min-height: 28rpx;
  103. font-size: 20rpx;
  104. color: #999999;
  105. }
  106. .tags {
  107. min-height: 30rpx;
  108. }
  109. .price {
  110. font-size: 26rpx;
  111. font-weight: 600;
  112. color: #f83c6c;
  113. .delete {
  114. font-size: 22rpx;
  115. color: #999999;
  116. font-weight: normal;
  117. text-decoration: line-through;
  118. margin-left: 8rpx;
  119. }
  120. }
  121. .numberbox {
  122. position: absolute;
  123. right: 0;
  124. bottom: 0;
  125. }
  126. }
  127. </style>