cm-cart-product.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view class="cart-product">
  3. <image class="cover" :src="productInfo.mainImage" mode="widthFix"></image>
  4. <view class="content">
  5. <view class="name">{{ productInfo.productName }}</view>
  6. <template v-if="isExpired">
  7. <view class="tip">商品已下架</view>
  8. </template>
  9. <template v-else>
  10. <view class="unit">规格:{{ productInfo.unit }}</view>
  11. <view class="tags">
  12. <template v-if="tagsList.length > 0">
  13. <view class="tag other" v-for="(tag, index) in tagsList" :key="index">{{ tag }}</view>
  14. </template>
  15. <template v-if="productInfo.activeStatus">
  16. <view class="tag cx" v-if="userId === productInfo.heUserId">促销</view>
  17. <view class="tag cx" v-else>自营</view>
  18. <view class="tag hd" v-if="productInfo.ladderList.length > 0">活动价</view>
  19. </template>
  20. </view>
  21. <view class="price">¥{{ productInfo.price | priceFormat }}</view>
  22. <cm-number-box class="numberbox" v-model="productInfo.productCount" @change="change"></cm-number-box>
  23. </template>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. name: 'cm-cart-product',
  30. props: {
  31. isExpired: {
  32. type: Boolean,
  33. default: false
  34. },
  35. productInfo: {
  36. type: Object,
  37. default: () => {}
  38. },
  39. tagsList: {
  40. type: Array,
  41. default: () => []
  42. }
  43. },
  44. computed: {
  45. userId() {
  46. return this.$store.getters.userId
  47. }
  48. },
  49. methods: {
  50. change(value) {
  51. this.$emit('countChange', {
  52. cartId: this.productInfo.cartId,
  53. count: value
  54. })
  55. }
  56. }
  57. }
  58. </script>
  59. <style lang="scss" scoped>
  60. .cart-product {
  61. @extend .cm-flex-between;
  62. .cover {
  63. width: 180rpx;
  64. height: 180rpx;
  65. box-sizing: border-box;
  66. border: 1rpx dashed #e1e1e1;
  67. }
  68. .content {
  69. position: relative;
  70. display: flex;
  71. flex-direction: column;
  72. justify-content: center;
  73. flex: 1;
  74. margin-left: 16rpx;
  75. }
  76. .name {
  77. @include ellipsis(2);
  78. max-width: 440rpx;
  79. min-height: 68rpx;
  80. font-size: 26rpx;
  81. color: #333333;
  82. }
  83. .tip {
  84. margin-top: 80rpx;
  85. font-size: 26rpx;
  86. color: #f83c6c;
  87. }
  88. .unit {
  89. min-height: 28rpx;
  90. font-size: 20rpx;
  91. color: #999999;
  92. }
  93. .tags {
  94. min-height: 30rpx;
  95. }
  96. .price {
  97. font-size: 26rpx;
  98. font-weight: 600;
  99. color: #f83c6c;
  100. }
  101. .numberbox {
  102. position: absolute;
  103. right: 0;
  104. bottom: 0;
  105. }
  106. }
  107. </style>