lunbo.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div
  3. class="lunbo"
  4. :class="{ rjianjin: isReverse }"
  5. :key="id"
  6. :ref="id"
  7. v-swiper:mySwiper="swiperOptions"
  8. >
  9. <ul class="swiper-wrapper swiper2">
  10. <li
  11. class="swiper-slide"
  12. v-for="(item, i) in data"
  13. :data-link="item.link"
  14. :key="i"
  15. >
  16. <img
  17. :src="require(`@/assets/images/collection/${active}/${item.img}`)"
  18. />
  19. <span>{{ item.name }}</span>
  20. </li>
  21. </ul>
  22. <div
  23. :style="{ backgroundImage: `url(${require('@/assets/images/bg.jpg')})` }"
  24. class="jianchubg"
  25. ></div>
  26. </div>
  27. </template>
  28. <script>
  29. import { directive } from "vue-awesome-swiper";
  30. // import style (<= Swiper 5.x)
  31. import "swiper/css/swiper.css";
  32. export default {
  33. props: ["isReverse", "id", "active", "data"],
  34. directives: {
  35. swiper: directive,
  36. },
  37. computed: {
  38. swiperOptions() {
  39. let that = this;
  40. return {
  41. preventLinksPropagation: !1,
  42. slidesPerView: "auto",
  43. speed: 1e4,
  44. loop: true,
  45. freeMode: false,
  46. autoplay: {
  47. delay: 0,
  48. disableOnInteraction: !1,
  49. reverseDirection: this.isReverse,
  50. },
  51. on: {
  52. click: function () {
  53. const clickedRealIndex = parseInt(
  54. this.clickedSlide.dataset.swiperSlideIndex || this.clickedIndex
  55. );
  56. let { link, name } = that.data[clickedRealIndex];
  57. that.$emit("openIframe", { url: link, isShow: true, name: name });
  58. },
  59. },
  60. };
  61. },
  62. },
  63. beforeDestroy() {
  64. this.$refs[this.id].swiper.destroy();
  65. }
  66. };
  67. </script>
  68. <style lang="less" scoped>
  69. @jianjinw: 10%;
  70. .lunbo {
  71. width: 100%;
  72. position: relative;
  73. &::before {
  74. content: "";
  75. position: absolute;
  76. pointer-events: none;
  77. background: linear-gradient(
  78. 90deg,
  79. #034c52 0,
  80. rgba(3, 76, 82, 1) 50%,
  81. rgba(3, 76, 82, 0) 100%
  82. );
  83. left: 0;
  84. top: 0;
  85. height: 100%;
  86. width: @jianjinw;
  87. z-index: 9999;
  88. }
  89. &::after {
  90. content: "";
  91. position: absolute;
  92. pointer-events: none;
  93. background: linear-gradient(-90deg, #034c52, rgba(3, 76, 82, 0));
  94. right: 0;
  95. top: 0;
  96. height: 100%;
  97. width: @jianjinw*0.8;
  98. z-index: 9999;
  99. }
  100. .jianchubg {
  101. width: 100%;
  102. }
  103. .swiper-wrapper {
  104. width: 100%;
  105. .swiper-slide {
  106. width: 15vw;
  107. height: 15vw;
  108. position: relative;
  109. cursor: pointer;
  110. transition: 0.3s ease all;
  111. margin: 0 1vw 0;
  112. > img {
  113. width: 100%;
  114. height: 100%;
  115. }
  116. > span {
  117. position: absolute;
  118. right: 13px;
  119. top: 14px;
  120. writing-mode: vertical-lr;
  121. display: inline-block;
  122. color: #9c8e4f;
  123. text-shadow: 0px 0px 4px #000000;
  124. letter-spacing: 2px;
  125. font-family: KaiTi;
  126. font-size: 16px;
  127. }
  128. &:hover {
  129. transform: scale(1.1);
  130. }
  131. }
  132. }
  133. }
  134. .rjianjin {
  135. &::before {
  136. content: "";
  137. position: absolute;
  138. background: linear-gradient(90deg, #034c52, rgba(3, 76, 82, 0));
  139. left: 0;
  140. top: 0;
  141. height: 100%;
  142. width: @jianjinw*0.8;
  143. z-index: 9999;
  144. }
  145. &::after {
  146. content: "";
  147. position: absolute;
  148. background: linear-gradient(
  149. -90deg,
  150. #034c52 0,
  151. rgba(3, 76, 82, 0.7) 76%,
  152. rgba(3, 76, 82, 0) 100%
  153. );
  154. right: 0;
  155. top: 0;
  156. height: 100%;
  157. width: @jianjinw;
  158. z-index: 9999;
  159. }
  160. }
  161. </style>
  162. <style lang="less">
  163. .swiper-container .swiper-wrapper {
  164. transition-timing-function: linear !important;
  165. }
  166. </style>