landjj321
2021-03-23 a92bf232a8e4881d4bf9993949676b9c3526b017
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<template>
  <div class="art-subject">
    <div class="bg">
      <img class="title" src="@/assets/home/art_subject/title.png">
 
      <div class="swiper-container swiper-container-art">
        <div class="swiper-wrapper">
          <div
            v-for="(banner, i) in banners"
            :key="banner"
            class="swiper-slide"
            :class="className[i]+1"
            @click="switchover(i)"
          >
            <img :src="banner" class="shadow">
          </div>
        </div>
        <!-- Add Pagination -->
        <!--        <div class="swiper-pagination" />-->
      </div>
    </div>
  </div>
</template>
 
<script>
import Swiper from 'swiper/swiper-bundle.js'
import 'swiper/swiper-bundle.css'
 
export default {
  name: 'ArtSubject',
  data() {
    return {
      activeIndex: 2, // 最上层图片索引
      banners: [ // 需要显示的图片
        require('@/assets/home/core_value/1.jpg'),
        require('@/assets/home/core_value/2.jpg'),
        require('@/assets/home/core_value/3.jpg'),
        require('@/assets/home/core_value/4.jpg'),
        require('@/assets/home/core_value/5.jpg'),
        require('@/assets/home/core_value/6.jpg')
      ],
      className: ['ele-0', 'ele-1', 'ele-2', 'ele-3', 'ele-4', 'ele-5']
    }
  },
  mounted() {
    new Swiper('.swiper-container-art', {
      autoplay: {
        delay: 1000
      },
      slidesPerView: 5,
      spaceBetween: 45,
      centeredSlides: true,
      centeredSlidesBounds: true,
      loop: true,
      pagination: {
        el: '.swiper-pagination',
        clickable: true
      }
    });
  },
  methods: {
    switchover(index) {
      let removeItemCount = index - this.activeIndex
      if (!removeItemCount) {
        // 如果在最优位置,则不动
        return
      }
 
      if (removeItemCount < 0) {
        removeItemCount = removeItemCount + 6
      }
      const className = Object.assign([], this.className)
      let result = []
      result = className.splice(6 - removeItemCount)
      result = result.concat(className)
      this.className = result
      this.activeIndex = index
    }
  }
}
</script>
 
<style lang="scss" scoped>
@import "~@/styles/variables.scss";
 
.art-subject {
  width: 100%;
  height: 33.5rem;
  position: relative;
  text-align: center;
 
  .bg {
    width: 100%;
    height: 33.5rem;
    background-image: url("../../../assets/home/art_subject/bg.png");
    background-size: 100% 100%;
 
    .title {
      width: 523px;
      height: 70px;
      margin-top: 42px;
    }
 
    .swiper-container {
      width: 1200px;
      .swiper-wrapper {
        height: 422px;
        width: 1200px;
        position: relative;
        top: -50px;
        //transform: translateX(0px) rotateY(-20px);
 
        .swiper-slide {
 
          width: 466px;
          height: 422px;
          //transition: transform 300ms, top 300ms, left 300ms, right 300ms, margin-top 300ms, margin-left 300ms, margin-right 300ms;
 
          img {
            width: 366px;
            height: 188px;
          }
 
          .shadow {
            -webkit-box-reflect: below 0 linear-gradient(transparent, transparent, rgba(0, 0, 0, 0.8))
          }
        }
 
        .swiper-slide {
          text-align: center;
          font-size: 18px;
          display: flex;
          justify-content: center;
          align-items: center;
          transition: 300ms;
          transform: scale(0.8);
        }
 
        .swiper-slide-active, .swiper-slide-duplicate-active {
          transform: scale(1);
          z-index: 200;
        }
 
        .swiper-slide-next,.swiper-slide-prev{
          transform: scale(0.9);
          z-index:100;
        }
      }
    }
 
  }
 
}
</style>