ScanBookList.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <scroll-view
  3. scroll-y
  4. refresher-enabled
  5. :refresher-triggered="isRefreshing"
  6. @refresherrefresh="onRefresh"
  7. class="book-scroll"
  8. >
  9. <view class="scan-book-list">
  10. <!-- 顶部提示 -->
  11. <view class="tip-text">
  12. 套装书(相同ISBN相同的系列书籍)只需扫描其中一本,扫描价即套装价;需用户将整个套装全部寄出,缺册不予回收。
  13. </view>
  14. <!-- 书籍列表 -->
  15. <view class="book-list">
  16. <BookItem
  17. v-for="book in bookList"
  18. :key="book.isbn"
  19. :book="book"
  20. @delete="handleDeleteBook"
  21. @quantity-change="handleQuantityChange"
  22. @upsell="handleUpsell"
  23. />
  24. </view>
  25. <view class="link-wrap flex-a">
  26. <text class="link-btn flex-1" @click="goToScannedBooks"
  27. >扫过的书 ></text
  28. >
  29. <text class="link-btn flex-1" @click="goToRules">卖书规则 ></text>
  30. </view>
  31. </view>
  32. </scroll-view>
  33. </template>
  34. <script>
  35. import BookItem from "./BookItem.vue";
  36. export default {
  37. components: {
  38. BookItem,
  39. },
  40. props: {
  41. bookList: {
  42. type: Array,
  43. default: () => [],
  44. },
  45. },
  46. data() {
  47. return {
  48. books: [],
  49. isRefreshing: false,
  50. };
  51. },
  52. watch: {
  53. bookList: {
  54. handler(newVal) {
  55. this.books = newVal;
  56. },
  57. deep: true,
  58. immediate: true,
  59. },
  60. },
  61. methods: {
  62. // 下拉刷新
  63. onRefresh() {
  64. this.isRefreshing = true;
  65. // 触发父组件的刷新事件
  66. this.$emit("refresh");
  67. // 模拟刷新完成后关闭刷新状态
  68. setTimeout(() => {
  69. this.isRefreshing = false;
  70. }, 600);
  71. },
  72. // 加价
  73. handleUpsell(book) {
  74. this.$emit("upsell", book);
  75. },
  76. handleDeleteBook(book) {
  77. this.$emit("deleted", book);
  78. },
  79. handleQuantityChange(data) {
  80. const book = this.books.find((book) => book.isbn === data.isbn);
  81. if (book) {
  82. book.num = data.num;
  83. }
  84. this.$emit("updateBooks", this.books, book);
  85. },
  86. onNext() {
  87. this.$emit("next");
  88. },
  89. goToScannedBooks() {
  90. uni.navigateTo({
  91. url: "/pages-home/pages/scaned-book",
  92. });
  93. },
  94. goToRules() {
  95. uni.navigateTo({
  96. url: "/pages-mine/pages/rules-for-sellbooks",
  97. });
  98. },
  99. },
  100. };
  101. </script>
  102. <style lang="scss">
  103. .scan-book-list {
  104. padding: 20rpx;
  105. display: flex;
  106. flex-direction: column;
  107. height: 100%;
  108. min-height: calc(100vh - 240px);
  109. .tip-text {
  110. font-family: Source Han Sans CN;
  111. font-weight: 400;
  112. font-size: 24rpx;
  113. color: #ff8a4b;
  114. line-height: 36rpx;
  115. }
  116. .book-scroll {
  117. flex: 1;
  118. height: 0;
  119. }
  120. .link-wrap {
  121. gap: 20rpx;
  122. box-sizing: border-box;
  123. margin-top: 20rpx;
  124. .link-btn {
  125. height: 80rpx;
  126. background: #ffffff;
  127. border-radius: 10rpx;
  128. display: flex;
  129. align-items: center;
  130. justify-content: center;
  131. font-family: PingFang SC;
  132. font-weight: 500;
  133. font-size: 32rpx;
  134. color: #666666;
  135. }
  136. }
  137. }
  138. </style>