index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <div class="swiper-container" ref="swiper-container">
  3. <swiper class="swiper-wrapper swiper-wrapper-n" :options="swiperOption">
  4. <swiper-slide class="swiper-slide" v-for="(item,index) in idata" :key="index">
  5. <div class="s-item" :style="{height:wh.width+'px'}" >
  6. <div v-if="item.video" class="video-bg">
  7. <video controls="controls" playsinline="playsinline" muted="muted" :poster="`${$cdn}images/${floder}/${item.video}.png`" >
  8. <source :src="`${$cdn}images/${floder}/${item.big}.mp4`" type="video/mp4">
  9. </video>
  10. </div>
  11. <img v-else class="main-img" :src="`${$cdn}images/${floder}/${item.big}.png`">
  12. </div>
  13. </swiper-slide>
  14. <div class="swiper-pagination" slot="pagination"></div>
  15. </swiper>
  16. </div>
  17. </template>
  18. <script>
  19. import 'swiper/dist/css/swiper.css'
  20. import { swiper, swiperSlide } from 'vue-awesome-swiper'
  21. let wh = {
  22. width: window.innerWidth,
  23. height: window.innerHeight
  24. }
  25. export default {
  26. props: ['idata', 'floder', 'mTop'],
  27. data () {
  28. return {
  29. wh,
  30. swiperOption: {
  31. slidesPerView: 'auto',
  32. autoplay: false,
  33. centeredSlides: true,
  34. watchSlidesProgress: true,
  35. pagination: {
  36. el: '.swiper-pagination'
  37. // bulletClass: 'my-bullet'
  38. },
  39. loop: true,
  40. paginationClickable: true
  41. }
  42. }
  43. },
  44. methods: {
  45. goto (url) {
  46. window.open(url, '_blank')
  47. }
  48. },
  49. components: {
  50. swiper,
  51. swiperSlide
  52. }
  53. }
  54. </script>
  55. <style lang="scss" scoped>
  56. .swiper-wrapper{
  57. position: relative!important;
  58. }
  59. .swiper-slide {
  60. width: 100%;
  61. transform-style: preserve-3d;
  62. }
  63. .swiper-slide {
  64. .main-img {
  65. width: 100%;
  66. margin: 0 auto;
  67. display: block;
  68. }
  69. }
  70. .swiper-slide {
  71. .s-item{
  72. width: 100%;
  73. // background: #ebebeb;
  74. }
  75. }
  76. .swiper-slide{
  77. width: 100%;
  78. .s-item{
  79. width: 100%;
  80. display: flex;
  81. align-items: center;
  82. video,img{
  83. // position: absolute;
  84. // transform: translate(-50%,-50%);
  85. // left: 50%;
  86. // top: 50%;
  87. width: 100%;
  88. }
  89. }
  90. }
  91. </style>
  92. <style>
  93. .swiper-pagination-bullet-active{
  94. background: #1fe4dc!important;
  95. }
  96. .video-bg {
  97. width: 100%;
  98. height: 100%;
  99. background: #202020;
  100. display: flex;
  101. align-items: center;
  102. }
  103. </style>