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

126 lines
3.7 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
  1. <template>
  2. <div id="bookshelf">
  3. <div class="bookshelf-header" style="height:120px">
  4. <router-link to="/">
  5. <span class="icon iconfont icon-l">&#xe631;</span>
  6. </router-link>
  7. <h2>本架图书</h2>
  8. <div class="rack-direct">
  9. <span :class="classnameL" @click="handleDirect(-1)"></span>
  10. <span :class="classnameR" @click="handleDirect(1)"></span>
  11. </div>
  12. </div>
  13. <div class="rack-box">
  14. <div v-for="(item,index) in listData" :key="index" class="rack-item">
  15. <!-- <ul class="rack-box-list">
  16. <li v-for="(eitem , eindex) in bookList" :key="eitem.id" class="list-item" @click="handleDetails(eindex)">
  17. <div class="box-txt">
  18. <span class="book-name">{{ eitem.title }}</span>
  19. <span class="book-writer">{{ eitem.author }}</span>
  20. </div>
  21. </li>
  22. </ul> -->
  23. <!-- <div class="rack-floor">
  24. <span class="icon iconfont icon-l" @click="handlePage(-1)">&#xe631;</span>
  25. <p><span style="margin-right:25px">第一层</span><span>(共15本)</span></p>
  26. <span class="icon iconfont icon-r" @click="handlePage(1)">&#xe62f;</span>
  27. </div> -->
  28. <div :class="['swiper'+index,'rack-box-list']">
  29. <div class="swiper-wrapper">
  30. <div v-for="(eitem , eindex) in bookList" :key="eitem.id" class="list-item swiper-slide" @click="handleDetails(eindex)">
  31. <div class="box-txt">
  32. <span class="book-name">{{ eitem.title }} {{ eindex+1 }}</span>
  33. <span class="book-writer">{{ eitem.author }}</span>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. <div class="'rack-floor'">
  39. <span :class="['icon','iconfont','icon-l'+index]" @click="handlePage(-1)">&#xe631;</span>
  40. <p><span style="margin-right:25px">{{ index+1 }}</span><span>( {{ bookList.length }})</span></p>
  41. <span :class="['icon','iconfont','icon-r'+index]" @click="handlePage(1)">&#xe62f;</span>
  42. </div>
  43. </div>
  44. </div>
  45. <BookDetails ref="detailDom" />
  46. </div>
  47. </template>
  48. <script>
  49. import data1 from './data1.json'
  50. import BookDetails from './module/bookDetails.vue'
  51. import { Swiper } from 'vue-awesome-swiper'
  52. import 'swiper/swiper-bundle.css'
  53. export default {
  54. name: 'CurrentRackBook',
  55. components: {
  56. BookDetails
  57. },
  58. data() {
  59. return {
  60. listData: [],
  61. bookList: [],
  62. classnameL: 'rack-direct-active',
  63. classnameR: null
  64. }
  65. },
  66. created() {
  67. this.listData = data1.listData
  68. this.bookList = data1.rackBook
  69. },
  70. mounted() {
  71. this.initSwiper()
  72. },
  73. methods: {
  74. initSwiper() {
  75. this.$nextTick(() => {
  76. this.bookList.forEach((el, index) => {
  77. new Swiper('.swiper' + index, {
  78. slidesPerView: 'auto',
  79. slidesPerGroup: 15,
  80. observer: true,
  81. navigation: {
  82. nextEl: '.icon-r' + index,
  83. prevEl: '.icon-l' + index
  84. }
  85. })
  86. })
  87. })
  88. },
  89. handleDetails(index) {
  90. this.$refs.detailDom.bookData = this.bookList[index]
  91. this.$refs.detailDom.dialogVisible = true
  92. },
  93. // 翻页
  94. handlePage(page) {
  95. if (page === 1) {
  96. // 下一页
  97. } else {
  98. // 上一页
  99. }
  100. },
  101. // 控制左右
  102. handleDirect(n) {
  103. if (n === -1) { // 左
  104. this.classnameR = null
  105. this.classnameL = 'rack-direct-active'
  106. } else { // 右
  107. this.classnameL = null
  108. this.classnameR = 'rack-direct-active'
  109. }
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss">
  115. @import "~@/assets/styles/index.scss";
  116. .swiper-container{
  117. position: relative;
  118. width: 100%;
  119. }
  120. .swiper-slide{
  121. width: 65px !important;
  122. }
  123. </style>