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

177 lines
5.2 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
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 @click="toRoomNav">
  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"></i></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"></i></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. leftShelfNo: '',
  79. rightShelfNo: '',
  80. rackList: [], // 本架图书排行第一
  81. otherList: [], // 本架图书排行后两本
  82. newList: [] // 新书推荐
  83. }
  84. },
  85. created() {
  86. this.getNewBookList()
  87. // 本架图书 + 书架借本信息
  88. this.initSmartBookshelf()
  89. },
  90. mounted() {
  91. },
  92. methods: {
  93. toPath(path) {
  94. if (path === '/CurrentRackBook') {
  95. const query = { leftShelfNo: this.leftShelfNo, rightShelfNo: this.rightShelfNo }
  96. this.$router.push({ path: path, query: query })
  97. } else {
  98. this.$router.push(path)
  99. }
  100. },
  101. toRoomNav() {
  102. const linkSrc = process.env.VUE_APP_BASE_API
  103. window.location.href = linkSrc + '/anchoring/initVenueNavigation.do?libcode=1201'
  104. },
  105. // 首页 - 新书推荐
  106. getNewBookList() {
  107. const params = {
  108. libcode: this.libcode,
  109. pageNo: 1,
  110. pageSize: 4
  111. }
  112. FetchNewBookRecommend(params).then(res => {
  113. let data = []
  114. data = res.newbookList
  115. data.forEach(item => {
  116. this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
  117. })
  118. }).catch(() => {
  119. this.$message.error('接口错误')
  120. })
  121. },
  122. // 根据isbn获取图书封面
  123. getCoverByISBN(isbn, item) {
  124. const params = {
  125. isbn: isbn
  126. }
  127. FetchCoverByISBN(params).then((res) => {
  128. item.cover = window.URL.createObjectURL(res)
  129. this.newList.push(item)
  130. })
  131. },
  132. // 初始化首页书架信息
  133. initSmartBookshelf() {
  134. this.leftShelfNo = this.$route.query.leftShelfNo
  135. this.rightShelfNo = this.$route.query.rightShelfNo
  136. const params = { leftShelfNo: this.leftShelfNo, rightShelfNo: this.rightShelfNo }
  137. // const _this = this
  138. initSmartBookshelf(params).then((res) => {
  139. this.shelfName = res.shelfName
  140. this.leftShelfMsg = res.leftShelf.sortMsg
  141. this.rightShelfMsg = res.rightShelf.sortMsg
  142. Promise.all(this.initBookData(res.bookList.splice(0, 1))).then((res) => {
  143. this.rackList = res
  144. })
  145. Promise.all(this.initBookData(res.bookList.splice(-2))).then((res) => {
  146. this.otherList = res
  147. })
  148. })
  149. },
  150. // 处理数据格式
  151. initBookData(bookList) {
  152. return bookList.map(async(item, index) => {
  153. const newItem = {
  154. ranking: item.bookUID,
  155. nbName: item.bookName,
  156. isOtherBook: index !== 0,
  157. nbAuthor: item.bookAuthor,
  158. isNewBook: false,
  159. num: item.heat ? item.heat : '0',
  160. isbn: item.isbn
  161. }
  162. const params = {
  163. isbn: item.isbn
  164. }
  165. const res = await FetchCoverByISBN(params)
  166. newItem.cover = window.URL.createObjectURL(res)
  167. return newItem
  168. })
  169. }
  170. }
  171. }
  172. </script>
  173. <style lang="scss">
  174. @import "~@/assets/styles/index.scss";
  175. </style>