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
3.8 KiB

  1. <template>
  2. <!-- 新书推荐 -->
  3. <div class="content-main new-main">
  4. <div class="swiper-container">
  5. <div class="swiper-wrapper new-book-list">
  6. <div v-for="(item,index) in rankingList" :key="index" class="swiper-slide">
  7. <div class="book-list-item">
  8. <div class="book-img">
  9. <img :src="item.img" :onerror="defaultImg">
  10. </div>
  11. <div class="book-info">
  12. <h4 class="title-item">{{ item.title }}</h4>
  13. <p>作者{{ item.author }}</p>
  14. <p>出版社教育出版社</p>
  15. <p>出版日期2022-03-03 <span class="icon iconfont ">&#xe638;</span></p>
  16. </div>
  17. </div>
  18. </div>
  19. </div>
  20. <!-- <div class="icon iconfont prev-btn">&#xe638;</div> -->
  21. <!-- <div class="icon iconfont next-btn">&#xe635;</div> -->
  22. <div class="icon iconfont prev-btn">
  23. <svg class="icon svg-icon" aria-hidden="true">
  24. <use xlink:href="#icon-zuohua" />
  25. </svg>
  26. </div>
  27. <div class="icon iconfont next-btn">
  28. <svg class="icon svg-icon" aria-hidden="true">
  29. <use xlink:href="#icon-youhua" />
  30. </svg>
  31. </div>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import data from './data'
  37. import { Swiper } from 'vue-awesome-swiper'
  38. import 'swiper/swiper-bundle.css'
  39. export default {
  40. name: 'NewBookRecommend',
  41. data() {
  42. return {
  43. defaultImg: 'this.src="' + require('@/assets/images/default-img.png') + '"',
  44. rankingList: []
  45. }
  46. },
  47. created() {
  48. this.rankingList = data.ranking
  49. },
  50. mounted() {
  51. this.initSwiper()
  52. },
  53. methods: {
  54. initSwiper() {
  55. this.$nextTick(() => {
  56. new Swiper('.swiper-container', {
  57. touchEventsTarget: '.swiper-container',
  58. slidesPerView: 5,
  59. spaceBetween: 20,
  60. centeredSlides: true,
  61. observer: true,
  62. loop: true,
  63. centeredSlidesBounds: true,
  64. watchSlidesVisibility: true,
  65. navigation: {
  66. nextEl: '.next-btn',
  67. prevEl: '.prev-btn'
  68. }
  69. })
  70. })
  71. }
  72. }
  73. }
  74. </script>
  75. <style lang="scss">
  76. @import "~@/assets/styles/index.scss";
  77. .new-main{
  78. position: relative;
  79. padding: 0 50px;
  80. }
  81. .new-book-list{
  82. color: #333;
  83. .book-list-item{
  84. width: 100%;
  85. box-shadow: 0px 0px 20px 1px #D2D2D2;
  86. border-radius: 2px 2px 2px 2px;
  87. }
  88. .book-img{
  89. height: 6.575rem;
  90. img{
  91. display: block;
  92. width: 100%;
  93. height: 100%;
  94. }
  95. }
  96. .book-info{
  97. padding: 10px 20px;
  98. h4{
  99. font-weight: normal;
  100. margin-bottom: 20px;
  101. }
  102. p{
  103. margin-bottom: 10px;
  104. }
  105. }
  106. }
  107. .icon{
  108. height: 1.1em;
  109. }
  110. .prev-btn,
  111. .next-btn{
  112. position: absolute;
  113. bottom: 60px;
  114. font-size: 60px;
  115. // color: #71C09E;
  116. z-index: 999;
  117. }
  118. .prev-btn{
  119. left: 100px;
  120. }
  121. .next-btn{
  122. right: 100px;
  123. }
  124. .swiper-container {
  125. width: 100%;
  126. height: 100%;
  127. overflow: hidden;
  128. }
  129. .swiper-slide {
  130. display: -webkit-box;
  131. display: -ms-flexbox;
  132. display: -webkit-flex;
  133. display: flex;
  134. -webkit-box-pack: center;
  135. -ms-flex-pack: center;
  136. -webkit-justify-content: center;
  137. justify-content: center;
  138. -webkit-box-align: center;
  139. -ms-flex-align: center;
  140. -webkit-align-items: center;
  141. align-items: center;
  142. transition: 300ms;
  143. transform: scale(0.84);
  144. .book-info{
  145. line-height: 20px;
  146. font-size: 16px;
  147. h4{
  148. font-size: 20px;
  149. }
  150. }
  151. }
  152. .swiper-slide.swiper-slide-prev,
  153. .swiper-slide.swiper-slide-next {
  154. font-size: 28px;
  155. transform: scale(0.9);
  156. .book-info{
  157. line-height: 28px;
  158. font-size: 22px;
  159. h4{
  160. font-size: 28px;
  161. }
  162. }
  163. }
  164. .swiper-slide-active,.swiper-slide-duplicate-active {
  165. transform: scaleX(1);
  166. .book-info{
  167. line-height: 40px;
  168. font-size: 28px;
  169. h4{
  170. font-size: 40px;
  171. }
  172. }
  173. }
  174. </style>