ScanBookList.vue 2.4 KB

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