ScanBookList.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <view class="scan-book-list">
  3. <!-- 顶部提示 -->
  4. <view class="tip-text">
  5. 套装书(相同ISBN相同的系列书籍)只需扫描其中一本,扫描价即套装价;需用户将整个套装全部寄出,缺册不予回收。
  6. </view>
  7. <!-- 书籍列表 -->
  8. <view class="book-list">
  9. <BookItem v-for="(book,index) in bookList" :key="book.isbn" :book="book" @delete="handleDeleteBook"
  10. @quantity-change="handleQuantityChange" />
  11. </view>
  12. <view class="link-wrap flex-a">
  13. <text class="link-btn flex-1" @click="goToScannedBooks">扫过的书 ></text>
  14. <text class="link-btn flex-1" @click="goToRules">卖书规则 ></text>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import BookItem from './BookItem.vue'
  20. export default {
  21. components: {
  22. BookItem
  23. },
  24. props: {
  25. bookList: {
  26. type: Array,
  27. default: () => []
  28. }
  29. },
  30. data() {
  31. return {
  32. books: []
  33. }
  34. },
  35. watch: {
  36. bookList: {
  37. handler(newVal) {
  38. this.books = newVal
  39. },
  40. deep: true,
  41. immediate:true
  42. }
  43. },
  44. methods: {
  45. handleDeleteBook(bookId) {
  46. this.books = this.books.filter(book => book.isbn !== bookId)
  47. this.$emit('updateBooks', this.books)
  48. },
  49. handleQuantityChange(data) {
  50. const book = this.books.find(book => book.isbn === data.isbn)
  51. if (book) {
  52. book.num = data.num
  53. }
  54. this.$emit('updateBooks', this.books)
  55. },
  56. onNext() {
  57. this.$emit('next')
  58. },
  59. goToScannedBooks() {
  60. uni.navigateTo({
  61. url: '/pages-home/pages/scaned-book'
  62. })
  63. },
  64. goToRules() {
  65. uni.navigateTo({
  66. url: '/pages/rules/index'
  67. })
  68. },
  69. }
  70. }
  71. </script>
  72. <style lang="scss">
  73. .scan-book-list {
  74. padding: 20rpx;
  75. .tip-text {
  76. font-family: Source Han Sans CN;
  77. font-weight: 400;
  78. font-size: 24rpx;
  79. color: #FF8A4B;
  80. line-height: 36rpx;
  81. }
  82. .link-wrap {
  83. gap: 20rpx;
  84. box-sizing: border-box;
  85. margin-top: 20rpx;
  86. .link-btn {
  87. height: 80rpx;
  88. background: #ffffff;
  89. border-radius: 10rpx;
  90. display: flex;
  91. align-items: center;
  92. justify-content: center;
  93. font-family: PingFang SC;
  94. font-weight: 500;
  95. font-size: 32rpx;
  96. color: #666666;
  97. }
  98. }
  99. }
  100. </style>