<template>
	<view class="bg">
		<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="1" />
	</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()
		},
		methods: {
			getList() {
				// 大轮播
				this.Post({
					type_id: 3,
					position: 1,
				}, '/api/adv/getAdv').then(res => {
					if(res.data) {
						this.topBanner = res.data;
					}
				});
			},
			// 2是各种详情页，3是列表专题页面，4是小程序
			gotoUrlNew(item) {
				console.log(item);
				let that = this;
				let url = '';
				switch (item.jump_type) {
					case 0:
						break;
					case 2:
						uni.navigateTo({
							url: item.tdata
						});
						break;
					case 3:
						uni.navigateTo({
							url: '/subPackages/webPage/webPage?url=' + item.tdata
						});
						break;
					case 4:
						uni.navigateToMiniProgram({
							appId: item.tdata.appid, // 此为appid
							path: item.tdata.page, // 此为首页路径
							envVersion: 'release',
							success: res => {
								// 打开成功
								console.log('打开成功', res);
							},
							fail: err => {
								console.log(err);
							}
						});
						break;
					default:
						break;
				}
			},
			
			

			
		}
	}
</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>
