江夏区图书馆自助查询机
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.

183 lines
5.5 KiB

6 months ago
5 months ago
6 months ago
6 months ago
  1. <template>
  2. <div class="content-main">
  3. <Search ref="searchRefs" />
  4. <div class="bookList-wrap" style="margin: 30px 44px;">
  5. <div class="bookList-left">
  6. <Ranking />
  7. </div>
  8. <!-- 图书列表 -->
  9. <div class="book-content2">
  10. <div class="result">检索结果<span>{{ totalNum }}</span></div>
  11. <div class="book-all-list" @scroll="listenScroll">
  12. <div v-for="(item,index) in bookList" :key="index" class="book-item" @click="getBookDetaisByBookRecNo(item)">
  13. <div class="book-info">
  14. <div class="book-img">
  15. <img :src="item.bookCover && item.bookCover === null ? defaultImg : baseUrl + '/api/fileRelevant/getImg?imgType=2&imgId=' + item.bookCover+'.jpg'" :onerror="defaultImg" alt="">
  16. <!-- <img :src="coverUrl+'/demoRecommend/getBookCover.do?id='+item.id" :onerror="defaultImg" alt=""> -->
  17. </div>
  18. <div class="book-txt">
  19. <h4> {{ item.title }} </h4>
  20. <div class="book-autor"> {{ item.author }} </div>
  21. <div class="book-publish"> {{ item.publisher }} </div>
  22. <div class="book-isbn">ISBN{{ item.isbn }}</div>
  23. <!-- <div class="book-intro title-item"> {{ item.introduce }} </div> -->
  24. <div class="to-book-more">查看详情</div>
  25. </div>
  26. </div>
  27. </div>
  28. <div v-if="!hasNextPage" class="load-data">暂无更多数据</div>
  29. <div v-else class="load-data">加载中...</div>
  30. </div>
  31. </div>
  32. </div>
  33. <BookDetails ref="bookDetailsRef" />
  34. </div>
  35. </template>
  36. <script>
  37. import { FetchFindBooksByQuery, FetchBookDetaisByBookRecNo } from '@/api/inquiryMachine'
  38. import { positionCrud } from './mixins/index.js'
  39. import Search from './module/search'
  40. import Ranking from './module/ranking'
  41. import BookDetails from './module/bookDetails'
  42. export default {
  43. name: 'BookList',
  44. components: {
  45. Search,
  46. Ranking,
  47. BookDetails
  48. },
  49. mixins: [positionCrud],
  50. data() {
  51. return {
  52. baseUrl: process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API,
  53. defaultImg: 'this.src="' + require('@/assets/images/default-img.png') + '"',
  54. bookList: [],
  55. coverUrl: null,
  56. pageIndex: 1,
  57. pageSize: 10,
  58. hasNextPage: false,
  59. totalPages: 0,
  60. totalNum: 0
  61. }
  62. },
  63. computed: {
  64. },
  65. created() {
  66. },
  67. mounted() {
  68. this.getBookRecommendList()
  69. },
  70. methods: {
  71. getLocation(row) {
  72. const parts = []
  73. if (row.floorName) {
  74. parts.push(row.floorName)
  75. }
  76. if (row.regionName) {
  77. parts.push(row.regionName)
  78. }
  79. if (row.gridName) {
  80. parts.push(row.gridName)
  81. }
  82. return parts.length > 0 ? parts.join('-') : '-'
  83. },
  84. getBookRecommendList() {
  85. let params
  86. if (localStorage.getItem('searchKey')) {
  87. this.$refs.searchRefs.keyword = localStorage.getItem('searchKey')
  88. this.$refs.searchRefs.keyWordIndex = parseInt(localStorage.getItem('keyWordIndex'))
  89. params = {
  90. 'fondsCode': this.libcode,
  91. 'search': localStorage.getItem('searchKey'),
  92. 'page': this.pageIndex - 1,
  93. 'size': this.pageSize
  94. }
  95. } else {
  96. params = {
  97. 'fondsCode': this.libcode,
  98. 'search': this.$refs.searchRefs.keyword,
  99. 'page': this.pageIndex - 1,
  100. 'size': this.pageSize
  101. }
  102. }
  103. FetchFindBooksByQuery(params).then(res => {
  104. const resData = res.content
  105. if (resData.length === 0) {
  106. this.hasNextPage = false
  107. } else {
  108. this.hasNextPage = resData.length === this.pageSize
  109. }
  110. this.totalNum = res.totalElements
  111. this.totalPages = res.totalPages
  112. this.bookList = this.bookList.concat(resData)
  113. // if (this.pageIndex > res.totalPages) {
  114. // this.hasNextPage = false
  115. // }
  116. localStorage.removeItem('searchKey')
  117. localStorage.removeItem('keyWordIndex')
  118. }).catch(() => {
  119. this.$message.error('接口错误')
  120. })
  121. },
  122. // 监听滚动
  123. listenScroll(e) {
  124. const ele = e.srcElement ? e.srcElement : e.target
  125. if (ele.scrollTop + ele.offsetHeight > ele.scrollHeight - 100) { // 监听滚动到div底部
  126. this.addMoreData()
  127. }
  128. },
  129. // 加载更多
  130. addMoreData() {
  131. if (this.hasNextPage) {
  132. this.getBookRecommendList()
  133. this.pageIndex++
  134. }
  135. },
  136. getBookDetaisByBookRecNo(item) {
  137. FetchBookDetaisByBookRecNo({
  138. 'bookRecNo': item.bookRecNo
  139. }).then(res => {
  140. this.$refs.bookDetailsRef.getBookRankingDetail(res)
  141. }).catch(() => {
  142. this.$message.error('接口错误')
  143. })
  144. }
  145. }
  146. }
  147. </script>
  148. <style lang="scss" scoped>
  149. @import "~@/assets/styles/index.scss";
  150. ::v-deep .el-dialog{
  151. width: 930px;
  152. border-radius: 16px;
  153. background: #F8F8FD;
  154. box-shadow: 0px 3px 20px 1px rgba(0,0,0,0.05);
  155. .el-dialog__body{
  156. padding: 20px 0 23px 0;
  157. }
  158. }
  159. .detail-dialog{
  160. ::v-deep .el-dialog__header{
  161. display: none;
  162. }
  163. }
  164. .dialog-book{
  165. padding: 30px;
  166. font-size: 28px;
  167. .book-txt{
  168. color: #191A1A!important;
  169. font-size: 30px !important;
  170. }
  171. .book-autor{
  172. font-size: 24px !important;
  173. }
  174. .book-publish{
  175. font-size: 28px !important;
  176. }
  177. }
  178. </style>