<template>
	<view class="center">
		<!-- <view class="cl"></view> -->
		<view class="carousel-section">
			<swiper class="carousel" autoplay="true" interval="5000" duration="400" @change="swiperChange">
				<swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item" @click="bannerNavToUrl(item)"> 
					<image :src="item.pic" />
				</swiper-item>	
			</swiper>
		</view>
		<view class="navBox">
			<view class="navBox-item" @click="nav('/pages/course/course')">
				<image class="bg1" src="../../static/img/indexMycourse.png" ></image>
				<view class="font">
					我的课程
				</view>
			</view>
			<view class="navBox-item" @click="nav('/pages/course/courseWan')">
				<image class="bg2" src="../../static/img/indexKcpj.png" ></image>
				<view class="font">
					课程评价
				</view>
			</view>
			<view class="navBox-item" @click="nav('/pages/leave/leaveClass')">
				<image class="bg3" src="../../static/img/indexQjsp.png" mode=""></image>
				<view class="font">
					请假审批
				</view>
			</view>
			<view class="navBox-item" @click="nav('/pages/problem/problem')">
				<image class="bg4" src="../../static/img/indexWtfq.png" mode="aspectFill"></image>
				<view class="font">
					问题反馈
				</view>
			</view>
		</view>
		<view class="title">教育资讯</view>
		<scroll-view scroll-y="true" class="listBox">
			<view v-for="(item,index) in dataList" :key="index" class="list" @click="nav('/pages/index/message')">
				<view class="img"><image src="../../static/img/test.jpg" mode=""></image></view>
				<view class="right">
					<view class="r-title">{{ item.title }}</view>
					<view class="time">{{ item.time }}</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import { banner } from '@/api/index.js'
export default {
	data(){
		return{
			swiperCurrent: 0,
			carouselList: [],
			dataList: [
				{
					title: "马云马化腾对决交通场景，一文说清双方布局",
					time: "2020-12-26 12:30",
				},
				{
					title: "贾跃亭的一篇采访，让我的朋友圈干起了架",
					time: "2020-12-26 12:30",
				},
				{
					title: "世界互联网大会红利释放 互联网产业发展迅速世界互联网",
					time: "2020-12-26 12:30",
				},
				{
					title: "学习教育网名师在线答疑",
					time: "2020-12-26 12:30",
				},
				{
					title: "学习教育网名师在线答疑",
					time: "2020-12-26 12:30",
				},
			]
		}
	},
	onLoad() {
		this.loadData();
	},
	methods: {
		nav(url){
			uni.navigateTo({
				url: url,
			})
		},
		async loadData(){
			const obj = this;
			banner({}).then(e => {
				obj.carouselList = e.data.banner;
			})
		},
		swiperChange(e) {
			const index = e.detail.current;
			this.swiperCurrent = index;
			this.titleNViewBackground = this.carouselList[index].background;
		},
	}
}
</script>

<style lang="scss">
.center{
	height: 100%;
}
.cl {
	height: 44px;
}
.carousel-section {
	margin: 0 auto;
	width: 90%;
	height: 280rpx;
	border-radius: 20rpx;
	image{
		border-radius: 20rpx;
		height: 100%;
		width: 100%;
	}
	// width: 100%;
	// height: 320rpx;
	// border-radius: 24rpx;
	// .titleNview-placing {
	// 	height: var(--status-bar-height);
	// 	padding-top: 44px;
	// 	box-sizing: content-box;
	// }
	// .carousel {
	// 	width: 92%;
	// 	height: 240rpx;
	// 	.carousel-item {
	// 		width: 100%;
	// 		height: 100%;
	// 	}
	// 	image {
	// 		width: 100%;
	// 		height: 100%;
	// 		border-radius: $border-radius-sm;
	// 	}
	// }
}
.bg1{
	width: 70rpx;
	height: 60rpx;
}
.bg2{
	width: 62rpx;
	height: 66rpx;
}
.bg3{
	width: 78rpx;
	height: 70rpx;
}
.bg4{
	width: 60rpx;
	height: 62rpx;
}
.navBox {
	display: flex;
	align-items: center;
	.navBox-item {
		text-align: center;
		margin-top: 100rpx;
		flex: 1;
		.font {
			font-size: 24rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #69717B;
		}
	}
}
.title {
	margin-top: 60rpx;
	padding-left: 32rpx;
	font-size: 36rpx;
	font-family: PingFang SC;
	font-weight: bold;
	color: #24272C;
}
.listBox {
	margin-top: 28rpx;
}
.list {
	margin-bottom: 50rpx;
	padding-left: 34rpx;
	padding-right: 40rpx;
	display: flex;
	.img{
		background-color: #FFFFFF;
		width: 200rpx;
		height: 160rpx;
		flex-shrink:0;
		image {
			width: 100%;
			height: 100%;
		}
	}
	.right {
		text-align: left;
		width: 100%;
		padding-left: 20rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		.r-title {
			font-size: 32rpx;
			font-weight: 400;
			color: #333333;
		}
		.time {
			font-size: 26rpx;
			font-weight: 400;
			color: #999999;
		}
	}
}
</style>
