yd-cart-product.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <view>
  3. <view class="product-item" v-for="(item, index) in productList" :key="item.productId" @click="handleProductItemClick(item.productId)">
  4. <view class="product-check" @click.stop="handleCheckProduct(item.productId, item.checked)">
  5. <u-icon v-if="item.checked" name="checkmark-circle-fill" color="#3c9cff" size="22"></u-icon>
  6. <view v-else class="un-check-box"></view>
  7. </view>
  8. <image class="product-image" :src="item.coverUrl"></image>
  9. <view class="item-info">
  10. <view class="info-text">
  11. <u--text :lines="1" size="15px" color="#333333" :text="item.productTitle"></u--text>
  12. <u-gap height="2px"></u-gap>
  13. <u--text class="info-tips" :lines="1" size="12px" color="#939393" :text="item.tips"></u--text>
  14. </view>
  15. <view class="price-number-box">
  16. <view class="price-box">
  17. <yd-text-price color="red" size="13" intSize="20" :price="item.sellPrice"></yd-text-price>
  18. <yd-text-price v-if="item.strikePrice" style="margin-left: 5px" decoration="line-through" color="#999" size="12" :price="item.sellPrice"></yd-text-price>
  19. </view>
  20. <view class="number-box" @click.stop>
  21. <u-number-box min="1" max="999" bgColor="#fff" integer :disableMinus="false" :disabledInput="true" :name="item.productId" :value="item.productCount" @change="handleProductCountChange"></u-number-box>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. /**
  30. * 购物车商品列表
  31. */
  32. export default {
  33. name: 'yd-cart-product',
  34. props: {
  35. productList: {
  36. type: Array,
  37. default: () => []
  38. }
  39. },
  40. data() {
  41. return {
  42. //status: 'nomore',
  43. loadingText: '加载中...',
  44. loadmoreText: '上拉加载更多',
  45. nomoreText: '没有更多了'
  46. }
  47. },
  48. methods: {
  49. handleProductItemClick(productId) {
  50. uni.$u.route('/pages/product/product', {
  51. id: productId
  52. })
  53. },
  54. handleItemCartClick(productId) {
  55. this.$store.dispatch('CartProductCountChange', { productIds: [productId], productCount: 1, addition: true }).then(res => {
  56. uni.$u.toast('已添加到购物车')
  57. })
  58. },
  59. handleCheckProduct(productId, checked) {
  60. this.$emit('productCheckedChange', productId, !checked)
  61. },
  62. handleProductCountChange({ name, value }) {
  63. this.$emit('productCartProductCountChange', name, value)
  64. }
  65. }
  66. }
  67. </script>
  68. <style lang="scss" scoped>
  69. .product-item {
  70. background: #ffffff;
  71. @include flex-space-between;
  72. border-bottom: $custom-border-style;
  73. padding: 10rpx 0 0 5rpx;
  74. .product-check {
  75. padding: 20rpx;
  76. .un-check-box {
  77. width: 20px;
  78. height: 20px;
  79. border: 1px solid #939393;
  80. border-radius: 50%;
  81. }
  82. }
  83. .product-image {
  84. width: 180rpx;
  85. height: 180rpx;
  86. border-radius: 10rpx;
  87. }
  88. .item-info {
  89. flex: 1;
  90. padding: 20rpx 20rpx 0;
  91. .info-text {
  92. height: 70rpx;
  93. padding-bottom: 10rpx;
  94. }
  95. .price-number-box {
  96. @include flex-space-between;
  97. .price-box {
  98. @include flex-left();
  99. }
  100. .number-box {
  101. height: 100rpx;
  102. @include flex-center;
  103. }
  104. }
  105. }
  106. }
  107. </style>