大数据展示系统-前端
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.

171 lines
5.0 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div id="bookshelf">
  3. <div class="bookshelf-header">
  4. <h2>RFID智慧书架</h2>
  5. <span class="shelf-num">{{ shelfName }}</span>
  6. </div>
  7. <!-- 本架分类 -->
  8. <div class="book-category">
  9. <p>{{ leftShelfMsg }}</p>
  10. <p>{{ rightShelfMsg }}</p>
  11. </div>
  12. <!-- 智慧书架导航 -->
  13. <ul class="book-nav">
  14. <li>
  15. <img src="~@/assets/images/home/nav1.png">
  16. <p>图书检索</p>
  17. </li>
  18. <li @click="toPath('/HotBook?bookType=hot')">
  19. <img src="~@/assets/images/home/nav2.png">
  20. <p>热门图书</p>
  21. </li>
  22. <li @click="toPath('/AuthorRecommend')">
  23. <img src="~@/assets/images/home/nav3.png">
  24. <p>作者推荐</p>
  25. </li>
  26. <li @click="toPath('/DigitalResource')">
  27. <img src="~@/assets/images/home/nav4.png">
  28. <p>数字资源</p>
  29. </li>
  30. <li>
  31. <img src="~@/assets/images/home/nav5.png">
  32. <p>场馆导航</p>
  33. </li>
  34. </ul>
  35. <!-- 本架图书 -->
  36. <div class="book-rack">
  37. <div class="list-top">
  38. <div class="list-top-title">
  39. <svg class="icon" aria-hidden="true">
  40. <use xlink:href="#icon-benjiatushu" />
  41. </svg>
  42. <p>本架图书</p>
  43. </div>
  44. <span class="more" @click="toPath('/CurrentRackBook')">更多<i class="iconfont icon-zuo rotate" /></span>
  45. </div>
  46. <div class="rack-list">
  47. <BookListItem :list-data.sync="rackList" />
  48. <BookListItem :list-data.sync="otherList" :is-other-book="true" />
  49. </div>
  50. </div>
  51. <!-- 新书推荐 -->
  52. <div class="book-rack new-recommend">
  53. <div class="list-top">
  54. <div class="list-top-title">
  55. <p>新书推荐</p>
  56. </div>
  57. <span class="more" @click="toPath('/NewBook?bookType=new')">更多<i class="iconfont icon-zuo rotate" /></span>
  58. </div>
  59. <BookListItem :list-data.sync="newList" :is-new-book="true" />
  60. </div>
  61. </div>
  62. </template>
  63. <script>
  64. import BookListItem from '@/views/module/homeListItem.vue'
  65. import { FetchNewBookRecommend, FetchCoverByISBN, initSmartBookshelf } from '@/api/bookshelf'
  66. export default {
  67. name: 'Home',
  68. components: {
  69. BookListItem
  70. },
  71. data() {
  72. return {
  73. shelfName: '1',
  74. leftShelfMsg: '',
  75. rightShelfMsg: '',
  76. leftShelfNo: '1201-03-001-A-01',
  77. rightShelfNo: '1201-03-001-B-01',
  78. rackList: [], // 本架图书排行第一
  79. otherList: [], // 本架图书排行后两本
  80. newList: [] // 新书推荐
  81. }
  82. },
  83. created() {
  84. this.getNewBookList()
  85. // 本架图书 + 书架借本信息
  86. this.initSmartBookshelf()
  87. },
  88. mounted() {
  89. },
  90. methods: {
  91. toPath(path) {
  92. if (path === '/CurrentRackBook') {
  93. const query = { leftShelfNo: this.leftShelfNo, rightShelfNo: this.rightShelfNo }
  94. this.$router.push({ path: path, query: query })
  95. } else {
  96. this.$router.push(path)
  97. }
  98. },
  99. // 首页 - 新书推荐
  100. getNewBookList() {
  101. const params = {
  102. libcode: this.libcode,
  103. pageNo: 1,
  104. pageSize: 4
  105. }
  106. FetchNewBookRecommend(params).then(res => {
  107. let data = []
  108. data = res.newbookList
  109. data.forEach(item => {
  110. this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
  111. })
  112. }).catch(() => {
  113. this.$message.error('接口错误')
  114. })
  115. },
  116. // 根据isbn获取图书封面
  117. getCoverByISBN(isbn, item) {
  118. const params = {
  119. isbn: isbn
  120. }
  121. FetchCoverByISBN(params).then((res) => {
  122. item.cover = window.URL.createObjectURL(res)
  123. this.newList.push(item)
  124. })
  125. },
  126. // 初始化首页书架信息
  127. initSmartBookshelf() {
  128. // this.leftShelfNo = this.$route.query.leftShelfNo
  129. // this.rightShelfNo = this.$route.query.rightShelfNo
  130. const params = { leftShelfNo: this.leftShelfNo, rightShelfNo: this.rightShelfNo }
  131. // const _this = this
  132. initSmartBookshelf(params).then((res) => {
  133. this.shelfName = res.shelfName
  134. this.leftShelfMsg = res.leftShelf.sortMsg
  135. this.rightShelfMsg = res.rightShelf.sortMsg
  136. Promise.all(this.initBookData(res.bookList.splice(0, 1))).then((res) => {
  137. this.rackList = res
  138. })
  139. Promise.all(this.initBookData(res.bookList.splice(-2))).then((res) => {
  140. this.otherList = res
  141. })
  142. })
  143. },
  144. // 处理数据格式
  145. initBookData(bookList) {
  146. return bookList.map(async(item, index) => {
  147. const newItem = {
  148. ranking: item.bookUID,
  149. nbName: item.bookName,
  150. isOtherBook: index !== 0,
  151. nbAuthor: item.bookAuthor,
  152. isNewBook: false,
  153. num: item.heat ? item.heat : '0',
  154. isbn: item.isbn
  155. }
  156. const params = {
  157. isbn: item.isbn
  158. }
  159. const res = await FetchCoverByISBN(params)
  160. newItem.cover = window.URL.createObjectURL(res)
  161. return newItem
  162. })
  163. }
  164. }
  165. }
  166. </script>
  167. <style lang="scss">
  168. @import "~@/assets/styles/index.scss";
  169. </style>