slide.vue 1.58 KB
Newer Older
王建威's avatar
王建威 committed
1 2
<template>
	<view>
王建威's avatar
王建威 committed
3 4
		<uni-swiper-dot :info="slide_list" :dotsStyles="{'width': 4,'height':4, 'bottom':5, 'selectedBackgroundColor':'#fff', 'backgroundColor': '#ccc', 'border':'none','selectedBorder':'none'}" :mode="slide_setting.tipsStyle === 1 ? 'dot' : 'default'" :current="current" :showDots="slide_setting.dots">
			<swiper :autoplay="autoplay" :style="{'background-color': slide_setting.bg_color, 'height': slide_setting.slideHeight*2+'rpx'}" circular="true" :interval="interval" @change="change">
王建威's avatar
王建威 committed
5 6 7 8 9 10 11
				<swiper-item v-for="(item, key) in slide_list" :key="key">
					<view :style="{'height': slide_setting.slideHeight*2+'rpx'}">
						<image class="slide_img" :src="item.img_url" @click="$jump(item.img_href)"></image>
					</view>
				</swiper-item>
			</swiper>
		</uni-swiper-dot>
王建威's avatar
王建威 committed
12 13 14 15
	</view>
</template>

<script>
王建威's avatar
王建威 committed
16
	import uniSwiperDot from "@/components/uni-swiper-dot/uni-swiper-dot.vue"
王建威's avatar
王建威 committed
17 18 19 20 21 22 23 24 25
	export default {
		props: {
			wrapper_props: {
				type: Object
			}
		},
		data() {
			return {
				slide_setting: this.wrapper_props.slide_setting,
王建威's avatar
王建威 committed
26 27
				slide_list: this.wrapper_props.slide_list,
				current: 0,
王建威's avatar
王建威 committed
28 29
				interval: 3000,
				autoplay: this.wrapper_props.slide_setting.autoplay
王建威's avatar
王建威 committed
30 31
			}
		},
王建威's avatar
王建威 committed
32 33 34 35 36 37 38 39 40 41
		mounted() {
			const { infinite } = this.slide_setting;
			if(!infinite) {
				const time = this.interval * this.slide_list.length;
				setTimeout(() => {
					this.autoplay = false;
				}, time);
			}
			
		},
王建威's avatar
王建威 committed
42
		methods: {
王建威's avatar
王建威 committed
43 44
			change(e) {
				this.current = e.detail.current;
王建威's avatar
王建威 committed
45
			}
王建威's avatar
王建威 committed
46 47 48
		},
		components: {
			uniSwiperDot
王建威's avatar
王建威 committed
49 50 51 52 53 54 55 56 57 58
		}
	}
</script>

<style lang="less" scoped>
	.slide_img {
		width: 100%;
		height: 100%;
	}
</style>