BookItem.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <view class="book-item">
  3. <view class="book-info">
  4. <image class="book-cover" :src="book.cover" mode="aspectFill" />
  5. <view class="book-detail">
  6. <view class="top-info">
  7. <view class="book-title">{{ book.bookName }}</view>
  8. <view class="book-tags">
  9. <text class="tzs tag-text" v-if="book.suit==1">套装书</text>
  10. <text class="kmdb tag-text" v-if="book.maxNum>1">可卖多本</text>
  11. </view>
  12. </view>
  13. <view class="flex flex-j-b flex-a-c">
  14. <view class="book-price">回收价: ¥{{ book.recycleMoney }}</view>
  15. <u-number-box class="number-box" bg-color="#38c148" color="#ffffff" v-model="book.num" :min="1"
  16. :max="book.maxNum||40" @blur="onQuantityChange" @minus="addReduceNum(-1)"
  17. @plus="addReduceNum(1)"></u-number-box>
  18. </view>
  19. </view>
  20. <view class="delete-btn" @tap="onDelete">
  21. <u-icon name="close" size="26" color="#999"></u-icon>
  22. </view>
  23. </view>
  24. <common-dialog ref="deleteDialog" title="温馨提示" @confirm="confirmDelete">
  25. <text>确定删除这本图书吗?</text>
  26. </common-dialog>
  27. </view>
  28. </template>
  29. <script>
  30. import commonDialog from '@/components/common-dialog.vue';
  31. export default {
  32. components: {
  33. commonDialog
  34. },
  35. props: {
  36. book: {
  37. type: Object,
  38. required: true
  39. }
  40. },
  41. data() {
  42. return {}
  43. },
  44. methods: {
  45. onDelete() {
  46. this.$refs.deleteDialog.openPopup()
  47. },
  48. confirmDelete() {
  49. this.$emit('delete', this.book.isbn)
  50. },
  51. // /api/token/order/addReduceNum
  52. addReduceNum(changeNum) {
  53. uni.$u.http.post('/token/order/addReduceNum', {
  54. orderId: this.book.orderId,
  55. isbn: this.book.isbn,
  56. changeNum
  57. }).then(res => {
  58. if (res.data == 1) {
  59. this.$emit('quantity-change', this.book)
  60. }
  61. })
  62. },
  63. onQuantityChange(data) {
  64. console.log(this.book, 'xxxxx')
  65. uni.$u.http.post('/token/order/changeNum', {
  66. orderId: this.book.orderId,
  67. isbn: this.book.isbn,
  68. afterNum: data.value
  69. }).then(res => {
  70. if (res.data == 1) {
  71. this.$emit('quantity-change', this.book)
  72. }
  73. })
  74. }
  75. }
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. .book-item {
  80. background: #FFFFFF;
  81. padding: 20rpx;
  82. margin-top: 20rpx;
  83. border-radius: 10rpx;
  84. .book-info {
  85. display: flex;
  86. position: relative;
  87. .book-cover {
  88. width: 140rpx;
  89. height: 196rpx;
  90. border-radius: 8rpx;
  91. }
  92. .tag-text {
  93. font-family: Source Han Sans CN;
  94. font-weight: 400;
  95. font-size: 24rpx;
  96. color: #FFFFFF;
  97. }
  98. .tzs {
  99. width: 91rpx;
  100. height: 30rpx;
  101. background: linear-gradient(263deg, #98E05F, #0DE3AC);
  102. border-radius: 2rpx;
  103. padding: 4rpx 10rpx;
  104. margin-right: 10rpx;
  105. }
  106. .kmdb {
  107. width: 117rpx;
  108. height: 30rpx;
  109. background: linear-gradient(263deg, #F7CB6B, #FBA980);
  110. border-radius: 2rpx;
  111. padding: 4rpx 10rpx;
  112. margin-right: 10rpx;
  113. }
  114. .book-detail {
  115. flex: 1;
  116. margin-left: 20rpx;
  117. display: flex;
  118. flex-direction: column;
  119. justify-content: space-between;
  120. :v-deep .u-number-input {
  121. background: #F9F9F9 !important;
  122. border-radius: 6rpx;
  123. }
  124. .book-title {
  125. max-width: 400rpx;
  126. font-size: 28rpx;
  127. color: #333;
  128. line-height: 1.4;
  129. margin-bottom: 20rpx;
  130. display: -webkit-box;
  131. -webkit-box-orient: vertical;
  132. -webkit-line-clamp: 2;
  133. overflow: hidden;
  134. font-family: Source Han Sans CN;
  135. font-weight: bold;
  136. }
  137. .book-price {
  138. font-family: Source Han Sans CN;
  139. font-weight: 400;
  140. font-size: 24rpx;
  141. color: #999999;
  142. }
  143. }
  144. .delete-btn {
  145. position: absolute;
  146. right: 0;
  147. top: -10rpx;
  148. padding: 10rpx;
  149. }
  150. }
  151. }
  152. </style>