<template>
	<view class="rotation">
		<swiper class="swiper-h" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
			<swiper-item v-for="item in list" :key="item.id" @click="jumpDetails(item.jumpType,item)">
				<image class="h-150" :src="item.url"></image>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
import { rotation } from 'api/rotation'
export default {
	data() {
		return {
		indicatorDots: true,
		autoplay: true,
		interval: 3000,
		duration: 500,
		list:[],
		}
	},
	async created(options){
		try{
			const params = {}
			const data = await rotation(params)
			this.list = data
		}catch(e){
			//TODO handle the exception
		}
	},
	methods: {
		changeIndicatorDots(e) {
			this.indicatorDots = !this.indicatorDots
		},
		changeAutoplay(e) {
			this.autoplay = !this.autoplay
		},
		intervalChange(e) {
			this.interval = e.target.value
		},
		durationChange(e) {
			this.duration = e.target.value
		},
		jumpDetails(type,item) {
			if(type == 2){
				const obj = JSON.parse(item.param)
				uni.navigateTo({
					url:`../HomePages/ListDetails?id=${obj.id}`
				})
			}else if(type == 3){
				const obj1 = JSON.parse(item.param)
				uni.navigateTo({
					url:`../HomePages/peixun?id=${obj1.id}`
				})
			}else if(type == 1){
				const Url = item.jumpUrl
				console.log(Url)
				uni.navigateTo({
					url:`../outH5/outH5?con=${Url}`
				})
			}
		}
	},
}
</script>

<style lang="scss">
.rotation{
	padding-top: 88upx;
	text-align: center;
	background-color: $white;
}
.swiper-h{
	height: 363upx;
}
.h-150{
	height: 363upx;
	width: 100%;
}
</style>
