index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <div class="swiper-container">
  3. <swiper class="swiper-wrapper swiper-wrapper-n" :options="swiperOption">
  4. <swiper-slide class="swiper-slide" v-for="(item,index) in imgs" :key="index">
  5. <img class="main-img" :src="item">
  6. </swiper-slide>
  7. <div class="swiper-pagination" id="pagination" slot="pagination">
  8. <div class="swiper-button-prev swiper-button-white"></div>
  9. <div class="swiper-button-next swiper-button-white"></div>
  10. </div>
  11. </swiper>
  12. </div>
  13. </template>
  14. <script>
  15. import 'swiper/dist/css/swiper.css'
  16. import { swiper, swiperSlide } from 'vue-awesome-swiper'
  17. export default {
  18. data () {
  19. return {
  20. imgs: [
  21. this.$cdn + '/images/slider_img/slider_1.jpg',
  22. this.$cdn + '/images/slider_img/slider_2.jpg',
  23. this.$cdn + '/images/slider_img/slider_3.jpg',
  24. this.$cdn + '/images/slider_img/slider_4.jpg',
  25. this.$cdn + '/images/slider_img/slider_5.jpg',
  26. this.$cdn + '/images/slider_img/slider_6.jpg',
  27. this.$cdn + '/images/slider_img/slider_7.jpg',
  28. this.$cdn + '/images/slider_img/slider_8.jpg'
  29. ],
  30. swiperOption: {
  31. slidesPerView: 'auto',
  32. autoplay: true,
  33. centeredSlides: true,
  34. watchSlidesProgress: true,
  35. // pagination: {
  36. // el: '.swiper-pagination'
  37. // },
  38. navigation: {
  39. nextEl: '.swiper-button-next',
  40. prevEl: '.swiper-button-prev'
  41. },
  42. loop: true,
  43. paginationClickable: true,
  44. on: {
  45. progress: function () {
  46. var a = this
  47. var b, c, d
  48. for (b = 0; b < a.slides.length; b++) {
  49. c = a.slides[b]
  50. d = c.progress
  51. var scale = 1 - Math.min(Math.abs(0.2 * d), 1)
  52. var es = c.style
  53. es.opacity = 1 - Math.min(Math.abs(d / 2), 1)
  54. es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform =
  55. 'translate3d(0px,0,' +
  56. -Math.abs(400 * d) +
  57. 'px) scale(' +
  58. scale +
  59. ')'
  60. }
  61. },
  62. setTransition: function (b) {
  63. var a = this
  64. for (var c = 0; c < a.slides.length; c++) {
  65. var es = a.slides[c].style
  66. es.webkitTransitionDuration = es.MsTransitionDuration = es.msTransitionDuration = es.MozTransitionDuration = es.OTransitionDuration = es.transitionDuration =
  67. b + 'ms'
  68. }
  69. }
  70. }
  71. }
  72. }
  73. },
  74. components: {
  75. swiper,
  76. swiperSlide
  77. }
  78. }
  79. </script>
  80. <style type="text/css" scoped>
  81. .swiper-container {
  82. width: 100%;
  83. -webkit-perspective: 1200px;
  84. -moz-perspective: 1200px;
  85. -ms-perspective: 1200px;
  86. perspective: 1200px;
  87. }
  88. .swiper-wrapper {
  89. margin-top: 10px;
  90. }
  91. .swiper-slide {
  92. width: 60%;
  93. transform-style: preserve-3d;
  94. }
  95. .swiper-slide .main-img {
  96. width: 100%;
  97. margin: 0 auto;
  98. display: block;
  99. border-radius: 10px;
  100. }
  101. #pagination {
  102. position: absolute;
  103. bottom: 100px;
  104. width: 100%;
  105. }
  106. .swiper-button-white{
  107. -webkit-tap-highlight-color:transparent;
  108. -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  109. }
  110. #pagination .swiper-pagination-bullet {
  111. width: 9.5%;
  112. float: left;
  113. margin: 0 0 0 6.15%;
  114. background: 0;
  115. opacity: 1;
  116. }
  117. .swiper-pagination-bullet i {
  118. background: #41203f;
  119. width: 24px;
  120. height: 24px;
  121. line-height: 24px;
  122. font-size: 12px;
  123. border-radius: 50px;
  124. display: block;
  125. font-style: normal;
  126. text-align: center;
  127. margin: 0 auto;
  128. color: #f5b55c;
  129. }
  130. .swiper-pagination-bullet-active i {
  131. transform: scale(1.5);
  132. background-size: auto 100%;
  133. color: #815d4b;
  134. }
  135. @media screen and (min-height: 481px) {
  136. .swiper-wrapper {
  137. margin-top: 20px;
  138. }
  139. #pagination {
  140. bottom: 110px;
  141. }
  142. }
  143. @media screen and (min-height: 569px) {
  144. .swiper-wrapper {
  145. margin-top: 40px;
  146. }
  147. #pagination {
  148. bottom: 120px;
  149. }
  150. .swiper-pagination-bullet i {
  151. width: 30px;
  152. height: 30px;
  153. line-height: 30px;
  154. font-size: 15px;
  155. }
  156. }
  157. </style>
  158. <style type="text/css">
  159. </style>