东西湖大屏
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.

113 lines
2.9 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
  1. <template>
  2. <!-- 新书推荐 -->
  3. <div class="screen-item lending-ranking">
  4. <div class="common-title">新书推荐</div>
  5. <div ref="newbook" class="big-module module-content">
  6. <swiper ref="swiperThumbs" class="swiper gallery-thumbs directive" :options="swiperOptionThumbs">
  7. <swiper-slide v-for="(item,index) in rankingList" :key="index" class="slide-1">
  8. <div class="book-list-item">
  9. <div class="book-img">
  10. <img :src="coverUrl" :onerror="defaultImg">
  11. </div>
  12. <div class="book-info">
  13. <h4 class="title-item">{{ item.nbName }}</h4>
  14. <p>{{ item.nbAuthor }}</p>
  15. </div>
  16. <div class="ranking-num">
  17. <svg v-if="index === 0" class="icon" aria-hidden="true">
  18. <use xlink:href="#icon-a-no1" />
  19. </svg>
  20. <svg v-if="index === 1" class="icon" aria-hidden="true">
  21. <use xlink:href="#icon-a-no21" />
  22. </svg>
  23. <svg v-if="index === 2" class="icon" aria-hidden="true">
  24. <use xlink:href="#icon-a-no3" />
  25. </svg>
  26. <p>NO.{{ index+1 }}</p>
  27. </div>
  28. </div>
  29. </swiper-slide>
  30. </swiper>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. import { FetchNewBookRecommend, FetchCoverByISBN } from '@/api/library'
  36. import { swiper, swiperSlide } from 'vue-awesome-swiper'
  37. import 'swiper/dist/css/swiper.css'
  38. export default {
  39. name: 'NewBookRecommend',
  40. components: {
  41. swiper,
  42. swiperSlide
  43. },
  44. data() {
  45. return {
  46. defaultImg: 'this.src="' + require('@/assets/images/default-img.png') + '"',
  47. rankingList: [],
  48. swiperOptionThumbs: {
  49. direction: 'vertical',
  50. autoplay: true,
  51. loop: true,
  52. slidesPerView: 'auto',
  53. centeredSlides: true,
  54. touchRatio: 0.2,
  55. autoScrollOffset: true
  56. }
  57. }
  58. },
  59. computed: {
  60. swiper() {
  61. return this.$refs.swiperThumbs.swiper
  62. }
  63. },
  64. created() {
  65. },
  66. mounted() {
  67. this.getNewBookRecommend()
  68. },
  69. methods: {
  70. getNewBookRecommend() {
  71. FetchNewBookRecommend().then(res => {
  72. if (res.errCode === 0) {
  73. this.rankingList = res.data
  74. this.rankingList.forEach(item => {
  75. this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
  76. })
  77. } else {
  78. this.$message.error('接口错误')
  79. }
  80. })
  81. },
  82. getCoverByISBN(isbn, item) {
  83. const params = {
  84. isbn: isbn
  85. }
  86. FetchCoverByISBN(params).then((res) => {
  87. item.cover = window.URL.createObjectURL(res)
  88. })
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="scss">
  94. @import "~@/assets/styles/index.scss";
  95. .swiper-container{
  96. overflow: initial;
  97. }
  98. .swiper {
  99. &.gallery-thumbs {
  100. height: 1.275rem;
  101. }
  102. &.gallery-thumbs .swiper-slide {
  103. width: 100%;
  104. height: 100%;
  105. }
  106. &.gallery-thumbs .swiper-slide-active {
  107. background-color: #09194B;
  108. }
  109. }
  110. </style>