图书馆小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
2.7 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. <template>
  2. <view class="collection-page">
  3. <view class="content-box">
  4. <view class="empty" v-if="bookCollectList.length === 0">
  5. <uni-icons style="margin-left: 20px;" custom-prefix="iconfont" type="icon-kongshuju" size="80"></uni-icons>
  6. <text style="margin-top: 20px;">暂无收藏的图书~</text>
  7. </view>
  8. <view class="recommendation-list" v-else>
  9. <view
  10. class="book-item"
  11. v-for="(item, index) in bookCollectList"
  12. @click="goToBookDetail(item)"
  13. :key="index"
  14. >
  15. <image class="book-cover" :src="item.cover"></image>
  16. <view class="book-title">{{ item.title }}</view>
  17. </view>
  18. </view>
  19. <uni-load-more status="loading" v-if="isLoading"></uni-load-more>
  20. <view class="no-more" v-if="noMore && bookCollectList.length > 0">
  21. 没有更多数据了
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. data() {
  29. return {
  30. isLoading: false,
  31. noMore: false,
  32. pageNum: 1,
  33. pageSize: 5,
  34. bookCollectList: [
  35. { isbn: '9787544741110', title: '人工智能基础——数学知识', cover: 'https://qiniu.aiyxlib.com/1606124577077' },
  36. { isbn: '9787539938032', title: 'Vim 8文本处理实战', cover: 'https://qiniu.aiyxlib.com/1606178450151' },
  37. { isbn: '9787536692930', title: 'Oracle从入门到精通', cover: 'https://qiniu.aiyxlib.com/1606123986028' }
  38. ],
  39. }
  40. },
  41. onLoad() {
  42. },
  43. onPullDownRefresh() {
  44. this.refreshData()
  45. },
  46. onReachBottom() {
  47. if (this.noMore || this.isLoading) return
  48. this.loadMore()
  49. },
  50. methods: {
  51. refreshData() {
  52. this.isLoading = true
  53. setTimeout(() => {
  54. this.bookCollectList = [
  55. { isbn: '9787544741110', title: '人工智能基础——数学知识', cover: 'https://qiniu.aiyxlib.com/1606124577077' },
  56. { isbn: '9787539938032', title: 'Vim 8文本处理实战', cover: 'https://qiniu.aiyxlib.com/1606178450151' },
  57. { isbn: '9787536692930', title: 'Oracle从入门到精通', cover: 'https://qiniu.aiyxlib.com/1606123986028' }
  58. ]
  59. this.isLoading = false
  60. uni.stopPullDownRefresh()
  61. }, 500)
  62. },
  63. loadMore() {
  64. this.isLoading = true
  65. this.pageNum++
  66. setTimeout(() => {
  67. this.noMore = true
  68. this.isLoading = false
  69. }, 500)
  70. },
  71. goToBookDetail(item) {
  72. uni.navigateTo({ url: "/subpkg/pages/book-detail/book-detail?isbn=" + item.isbn })
  73. },
  74. },
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. .collection-page {
  79. padding: 10px 0;
  80. background-color: #f7f8fa;
  81. min-height: 100vh;
  82. }
  83. .content-box {
  84. padding: 0 10px;
  85. }
  86. .empty {
  87. text-align: center;
  88. padding: 60px 0;
  89. color: #999;
  90. font-size: 14px;
  91. }
  92. .no-more {
  93. text-align: center;
  94. padding: 20px 0;
  95. color: #999;
  96. font-size: 13px;
  97. }
  98. .recommendation-list{
  99. flex-wrap: wrap;
  100. .book-item {
  101. margin-bottom: 16px;
  102. }
  103. }
  104. </style>