BookItem.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view class="book-item">
  3. <view class="book-info">
  4. <u-image width="140rpx" height="196rpx" :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">回收价: ¥{{ 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. computed: {
  45. recycleMoney() {
  46. return (this.book.recyclePrice * (this.book.num || 1)).toFixed(2)
  47. }
  48. },
  49. methods: {
  50. onDelete() {
  51. this.$refs.deleteDialog.openPopup()
  52. },
  53. confirmDelete() {
  54. this.$emit('delete', this.book)
  55. },
  56. // /api/token/order/addReduceNum
  57. addReduceNum(changeNum) {
  58. uni.$u.http.post('/token/order/addReduceNum', {
  59. orderId: this.book.orderId,
  60. isbn: this.book.isbn,
  61. changeNum
  62. }).then(res => {
  63. if (res.data == 1) {
  64. this.$emit('quantity-change', this.book)
  65. }
  66. })
  67. },
  68. onQuantityChange(data) {
  69. uni.$u.http.post('/token/order/changeNum', {
  70. orderId: this.book.orderId,
  71. isbn: this.book.isbn,
  72. afterNum: data.value
  73. }).then(res => {
  74. if (res.data == 1) {
  75. this.$emit('quantity-change', this.book)
  76. }
  77. })
  78. }
  79. }
  80. }
  81. </script>
  82. <style lang="scss" scoped>
  83. .book-item {
  84. background: #FFFFFF;
  85. padding: 20rpx;
  86. margin-top: 20rpx;
  87. border-radius: 10rpx;
  88. .book-info {
  89. display: flex;
  90. position: relative;
  91. .book-cover {
  92. width: 140rpx;
  93. height: 196rpx;
  94. border-radius: 8rpx;
  95. }
  96. .tag-text {
  97. font-family: Source Han Sans CN;
  98. font-weight: 400;
  99. font-size: 24rpx;
  100. color: #FFFFFF;
  101. }
  102. .tzs {
  103. width: 91rpx;
  104. height: 30rpx;
  105. background: linear-gradient(263deg, #98E05F, #0DE3AC);
  106. border-radius: 2rpx;
  107. padding: 4rpx 10rpx;
  108. margin-right: 10rpx;
  109. }
  110. .kmdb {
  111. width: 117rpx;
  112. height: 30rpx;
  113. background: linear-gradient(263deg, #F7CB6B, #FBA980);
  114. border-radius: 2rpx;
  115. padding: 4rpx 10rpx;
  116. margin-right: 10rpx;
  117. }
  118. .book-detail {
  119. flex: 1;
  120. margin-left: 20rpx;
  121. display: flex;
  122. flex-direction: column;
  123. justify-content: space-between;
  124. :v-deep .u-number-input {
  125. background: #F9F9F9 !important;
  126. border-radius: 6rpx;
  127. }
  128. .book-title {
  129. max-width: 400rpx;
  130. font-size: 28rpx;
  131. color: #333;
  132. line-height: 1.4;
  133. margin-bottom: 20rpx;
  134. display: -webkit-box;
  135. -webkit-box-orient: vertical;
  136. -webkit-line-clamp: 2;
  137. overflow: hidden;
  138. font-family: Source Han Sans CN;
  139. font-weight: bold;
  140. }
  141. .book-price {
  142. font-family: Source Han Sans CN;
  143. font-weight: 400;
  144. font-size: 24rpx;
  145. color: #999999;
  146. }
  147. }
  148. .delete-btn {
  149. position: absolute;
  150. right: 0;
  151. top: -10rpx;
  152. padding: 10rpx;
  153. }
  154. }
  155. }
  156. </style>