<template>
	<view>
		<u-swiper :list="list5" @change="e => current = e.current" :autoplay="true" height="calc((100vw - 40rpx) * 0.42)"
			style="margin-top: 100rpx;background: transparent;margin-left: 20rpx;margin-right: 20rpx;" keyName="image" showTitle @click="goto">
			<view slot="indicator" class="indicator">
				<view class="indicator__dot" v-for="(item, index) in list5" :key="index"
					:class="[index === current && 'indicator__dot--active']">
				</view>
			</view>
		</u-swiper>
	</view>
</template>

<script>
	import { getAd } from "@/api/setting.js"
	export default {
		name: "swiper",
		data() {
			return {
				list5: [],
				current: 0
			};
		},
		created() {
			getAd().then(r=>{
				r.sort((a,b)=>{
					return a.sort - b.sort
				})
				this.list5 = r
			})
		},
		methods:{
			goto(e){
				window.open(this.list5[e].link,'_blank')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.indicator {
		@include flex(row);
		justify-content: center;

		&__dot {
			height: 6px;
			width: 6px;
			border-radius: 100px;
			background-color: rgba(255, 255, 255, 0.35);
			margin: 0 5px;
			transition: background-color 0.3s;

			&--active {
				background-color: #ffffff;
			}
		}
	}

	.indicator-num {
		padding: 2px 0;
		background-color: rgba(0, 0, 0, 0.35);
		border-radius: 100px;
		width: 35px;
		@include flex;
		justify-content: center;

		&__text {
			color: #FFFFFF;
			font-size: 12px;
		}
	}
</style>