swiper.vue
1.71 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
<template>
<div class="swiper-box" :class="{'points-mall-swiper':isPointsMall}" v-if="swipers && swipers.length">
<swipe class="swipe" :autoplay="5000" :touchable="swipers.length===1 ? false : true" :show-indicators="options && options.showIndicators !== undefined ? options.showIndicators : showIndicators" @change="onChange">
<swipe-item class="swipe-item" v-for="(item, index) in swipers" :key="index">
<div class="item" @click="$parent.$parent.gotoDetail(item)">
<div class="img-box">
<img v-if="isPointsMall" v-lazy="item + SIGN.BIG" class="img" mode="widthFix" />
<img v-else v-lazy="item.simg + SIGN.BIG" class="img" mode="widthFix" />
</div>
</div>
</swipe-item>
<template v-if="isPointsMall" #indicator>
<div class="custom-indicator">
{{ current + 1 }}/{{swipers.length}}
</div>
</template>
</swipe>
</div>
</template>
<script>
// 引入组件
// import { Swipe, SwipeItem } from 'mint-ui';
import { Swipe, SwipeItem } from "vant";
export default {
data () {
return {
showIndicators: true,
current: 0 // 图片位置
}
},
props: ["swipers", "options", "isPointsMall"],
components: {
Swipe,
SwipeItem
},
methods: {
/**
* 当swiper切换
* @param {int} index [切换swiper索引]
*/
onChange (index) {
this.current = index;
this.$emit("onChange", index);
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style rel="stylesheet/less" lang="less" scoped>
@import './swiper';
</style>