BookItem.vue 6.2 KB

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