巴青农资商城

CheckoutMultiGoodsRow.vue 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view class="multi-goods-row">
  3. <image class="multi-goods-row__pic" :src="item.displayPic" mode="aspectFill" />
  4. <view class="multi-goods-row__main">
  5. <text class="multi-goods-row__name">{{ item.goodsName }}</text>
  6. <view v-if="item.specList && item.specList.length" class="multi-goods-row__specs">
  7. <text
  8. v-for="(spec, index) in item.specList"
  9. :key="index"
  10. class="multi-goods-row__spec"
  11. >{{ spec }}</text>
  12. </view>
  13. <text v-if="item.serviceDesc" class="multi-goods-row__service">{{ item.serviceDesc }}</text>
  14. <view class="multi-goods-row__price-row">
  15. <text class="multi-goods-row__price">¥{{ item.priceText }}</text>
  16. <view class="multi-goods-row__qty">
  17. <view class="qty-btn" @click="onMinus">-</view>
  18. <text class="qty-num">{{ item.quantity }}</text>
  19. <view class="qty-btn" @click="onPlus">+</view>
  20. </view>
  21. </view>
  22. <text class="multi-goods-row__subtotal">小计 ¥{{ item.subtotalText }}</text>
  23. <view class="multi-goods-row__remark">
  24. <text class="multi-goods-row__remark-label">备注</text>
  25. <input
  26. class="multi-goods-row__remark-input"
  27. :value="item.buyerRemark"
  28. :maxlength="remarkMax"
  29. placeholder="选填"
  30. @input="onRemarkInput"
  31. />
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script setup>
  37. import { CHECKOUT_REMARK_MAX } from '@/constants/checkout'
  38. const props = defineProps({
  39. item: {
  40. type: Object,
  41. required: true
  42. }
  43. })
  44. const emit = defineEmits(['quantity-change', 'remark-change'])
  45. const remarkMax = CHECKOUT_REMARK_MAX
  46. function onMinus() {
  47. const next = Math.max(1, props.item.quantity - 1)
  48. if (next !== props.item.quantity) {
  49. emit('quantity-change', next)
  50. }
  51. }
  52. function onPlus() {
  53. const max = props.item.maxStock || 999999
  54. const next = props.item.quantity + 1
  55. if (next > max) {
  56. uni.showToast({ title: '库存不足', icon: 'none' })
  57. return
  58. }
  59. emit('quantity-change', next)
  60. }
  61. function onRemarkInput(e) {
  62. const val = (e && e.detail && e.detail.value) || ''
  63. emit('remark-change', val)
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. .multi-goods-row {
  68. display: flex;
  69. padding: 20rpx 24rpx;
  70. border-bottom: 1rpx solid #f5f5f5;
  71. }
  72. .multi-goods-row__pic {
  73. width: 160rpx;
  74. height: 160rpx;
  75. border-radius: 8rpx;
  76. background: #eee;
  77. flex-shrink: 0;
  78. }
  79. .multi-goods-row__main {
  80. flex: 1;
  81. margin-left: 16rpx;
  82. min-width: 0;
  83. }
  84. .multi-goods-row__name {
  85. font-size: 28rpx;
  86. color: #333;
  87. line-height: 1.4;
  88. }
  89. .multi-goods-row__specs {
  90. margin-top: 8rpx;
  91. display: flex;
  92. flex-direction: column;
  93. gap: 4rpx;
  94. }
  95. .multi-goods-row__spec {
  96. font-size: 24rpx;
  97. color: #999;
  98. }
  99. .multi-goods-row__service {
  100. display: block;
  101. margin-top: 8rpx;
  102. font-size: 22rpx;
  103. color: #2e7d32;
  104. }
  105. .multi-goods-row__price-row {
  106. margin-top: 12rpx;
  107. display: flex;
  108. align-items: center;
  109. justify-content: space-between;
  110. }
  111. .multi-goods-row__price {
  112. font-size: 30rpx;
  113. color: #e53935;
  114. font-weight: 600;
  115. }
  116. .multi-goods-row__qty {
  117. display: flex;
  118. align-items: center;
  119. border: 1rpx solid #e0e0e0;
  120. border-radius: 8rpx;
  121. overflow: hidden;
  122. }
  123. .qty-btn {
  124. width: 52rpx;
  125. height: 52rpx;
  126. line-height: 52rpx;
  127. text-align: center;
  128. font-size: 32rpx;
  129. color: #333;
  130. background: #f5f5f5;
  131. }
  132. .qty-num {
  133. min-width: 56rpx;
  134. text-align: center;
  135. font-size: 26rpx;
  136. }
  137. .multi-goods-row__subtotal {
  138. display: block;
  139. margin-top: 8rpx;
  140. font-size: 24rpx;
  141. color: #666;
  142. text-align: right;
  143. }
  144. .multi-goods-row__remark {
  145. margin-top: 12rpx;
  146. display: flex;
  147. align-items: center;
  148. }
  149. .multi-goods-row__remark-label {
  150. font-size: 24rpx;
  151. color: #999;
  152. margin-right: 12rpx;
  153. flex-shrink: 0;
  154. }
  155. .multi-goods-row__remark-input {
  156. flex: 1;
  157. height: 56rpx;
  158. padding: 0 16rpx;
  159. font-size: 24rpx;
  160. background: #f9f9f9;
  161. border-radius: 8rpx;
  162. }
  163. </style>