banner.vue
2.6 KB
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
<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(https://picnew9.photophoto.cn/20150705/dianshangshangchengguanggao-25066527_1.jpg)',
'height':componentContent.height + 'px'
}"
:id="JSON.stringify(item.linkObj)"
>
<div class="a-link">
<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],
props: {
terminal: {
type: Number,
default: 4
},
componentContent: {
type: Object
}
},
components: {
Swiper,
SwiperSlide
},
data () {
return {
swiperOption: {
autoplay: true, // 可选选项,自动滑动
loop: true,
pagination: {
el: '.swiper-pagination'
},
on: {}
}
}
},
directives: {
swiper: directive
},
created() {
// 配置轮播跳转
const _vm = this
this.swiperOption.on['click'] = function(e) {
_vm.jumpLink(JSON.parse(e.target.id))
}
},
mounted() {
this.$forceUpdate() // 刷新轮播图
},
computed: {
bannerList () {
return this.componentContent.bannerData.filter(function (item) {
return item.bannerUrl
})
}
}
}
</script>
<style lang="scss" scoped>
.banner{
.banner-item {
width: 100%;
img {
width: 100%;
}
}
&.terminal4{
::v-deep .el-carousel{
height: 100%;
.el-carousel__container{
height: 100%;
}
}
.banner-item{
background-repeat: no-repeat;
background-position: center;
background-size: auto 100%;
img{
display: none;
}
}
}
.swiper-pagination{
width: 100%;
position: relative;
top: -30px;
display: flex;
justify-content: center;
::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>