<template>
	<view class="bg">
		<headerVue></headerVue>
		<view class="content">
			<swiper class="top-banner"  :indicator-dots="false" :autoplay="false" v-if="topBanner && topBanner.length > 0">
				<swiper-item v-for="(item, index) in topBanner" :key="index" @click.stop="gotoUrlNew(item)">
					<image class="top-banner" :src="showImg(item.head_img)" mode="aspectFill" lazy-load="true"></image>
				</swiper-item>
			</swiper>
		</view>
		<CustomTabBar :currentTab="0" />
	</view>
</template>

<script>
	import headerVue from "@/components/header.vue"
	import CustomTabBar from '@/components/CustomTabBar.vue';
	export default {
		components: {CustomTabBar,headerVue},
		data() {
			return {
				topBanner: []
			}
		},
		onLoad() {
			
		},
		onReady() {
			this.getList()
			
		},
		onReachBottom() {
			
		},
		methods: {
			viewDetail(item) {
				if (item.url) {
					uni.navigateTo({
						url:"/subPackages/webPage/webPage?url="+encodeURIComponent(item.url)
					})
					return
				}
				uni.navigateTo({
					url:'/subPackages/letter/detail?id='+item.id
				})
			},
			
			getList() {
				// 大轮播
				this.Post({
					type_id: 3,
					position: 17,
				}, '/api/adv/getAdv').then(res => {
					if(res.data) {
						this.topBanner = res.data;
					}
				});
			},
			gotoVideo(item) {
				uni.navigateTo({
					url: '/subPackages/video/video?item=' + encodeURIComponent(JSON.stringify(item))
				})
			},
			
		}
	}
</script>

<style lang="scss" scoped>

	.bg {
		min-height: 100vh;
		background: #FFFFFF;
		display: flex;
		flex-direction: column;
	}
	.content{
		flex: 1;
		height: 200rpx;
		width: 100%;
	}
	.top-banner {
		width: 100%;
		height: 100%;
	}
	
</style>
