ScanBookList.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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(book) {
  46. uni.$u.http.post('/token/order/removeBook', {
  47. orderId: book.orderId,
  48. isbn: book.isbn
  49. }).then(res => {
  50. if (res.code == 200) {
  51. this.$u.toast('删除成功')
  52. this.$emit('deleted', this.book)
  53. }
  54. })
  55. },
  56. handleQuantityChange(data) {
  57. const book = this.books.find(book => book.isbn === data.isbn)
  58. if (book) {
  59. book.num = data.num
  60. }
  61. this.$emit('updateBooks', this.books)
  62. },
  63. onNext() {
  64. this.$emit('next')
  65. },
  66. goToScannedBooks() {
  67. uni.navigateTo({
  68. url: '/pages-home/pages/scaned-book'
  69. })
  70. },
  71. goToRules() {
  72. uni.navigateTo({
  73. url: '/pages/rules/index'
  74. })
  75. },
  76. }
  77. }
  78. </script>
  79. <style lang="scss">
  80. .scan-book-list {
  81. padding: 20rpx;
  82. .tip-text {
  83. font-family: Source Han Sans CN;
  84. font-weight: 400;
  85. font-size: 24rpx;
  86. color: #FF8A4B;
  87. line-height: 36rpx;
  88. }
  89. .link-wrap {
  90. gap: 20rpx;
  91. box-sizing: border-box;
  92. margin-top: 20rpx;
  93. .link-btn {
  94. height: 80rpx;
  95. background: #ffffff;
  96. border-radius: 10rpx;
  97. display: flex;
  98. align-items: center;
  99. justify-content: center;
  100. font-family: PingFang SC;
  101. font-weight: 500;
  102. font-size: 32rpx;
  103. color: #666666;
  104. }
  105. }
  106. }
  107. </style>