Blame view

admin-web-master/src/views/aaa/components/canvasShow/basics/banner.vue 2.32 KB
3f535f30   杨鑫   '初始'
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
  <template>
    <div class="banner"  :class="'terminal' + terminal">
      <swiper :options="swiperOption">
        <swiper-slide class="banner-item" v-for="(item,index) in bannerList" :key="index" :style="{backgroundImage: 'url('+ item.bannerUrl +')','height':componentContent.height + 'px'}" @click="jumpLink(item.linkObj)">
  <!--        <div class="a-link" @click="jumpLink(item.linkObj)"><img class="img" :src="item.bannerUrl" v-show="item.bannerUrl"></div>-->
        </swiper-slide>
      </swiper>
      <div class="swiper-pagination" slot="pagination"></div>
    </div>
  </template>
  
  <script>
  import { directive, Swiper, SwiperSlide } from 'vue-awesome-swiper'
  import 'swiper/css/swiper.css'
    import {funMixin} from '../config/mixin'
    export default {
      name: 'cereBanner',
      mixins: [funMixin],
      data () {
        return {
          swiperOption: {
            autoplay: false, // 可选选项,自动滑动
            loop: true,
            pagination: {
              el: '.swiper-pagination'
            }
          }
        }
      },
      props: {
        terminal: {
          type: Number,
          default: 4
        },
        componentContent: {
          type: Object
        }
      },
      components: {
        Swiper,
        SwiperSlide
      },
      directives: {
        swiper: directive
      },
      mounted() {
        this.$forceUpdate() // 刷新轮播图
      },
      computed: {
        bannerList: function () {
          console.log(this.componentContent)
          return this.componentContent.bannerData.filter(function (item) {
            return item.bannerUrl
          })
        }
      }
    }
  </script>
  
  <style lang="scss" scoped>
  .banner{
    .banner-item {
      width: 100%;
      background-repeat: no-repeat;
      background-position: center;
      background-size: auto 100%;
      img {
        width: 100%;
      }
    }
    &.terminal4{
      ::v-deep .el-carousel{
        height: 100%;
        .el-carousel__container{
          height: 100%;
        }
      }
      .banner-item{
        img{
          display: none;
        }
      }
    }
    .swiper-pagination{
      display: flex;
      justify-content: center;
      bottom: 20px;
      width: 100%;
      ::v-deep .swiper-pagination-bullet{
        width: 30px;
        height: 4px;
        background: #fff;
        opacity: 0.5;
        border-radius: 2px;
        margin: 0 7.5px;
      }
      ::v-deep .swiper-pagination-bullet-active{
        opacity: 1;
        width: 58px;
      }
    }
  }
  </style>