<template>
	<view class="home-container">
		<!-- 头部区域 -->
		<top-box v-bind:timeStamp="timeStamp"></top-box>
		<!-- 滚动条 -->
		<view class="notice">
			<u-notice-bar :text="myData.msgList[0]" mode="closable" bgColor="rgba(91, 126, 220, 0.5)" color="#FFFFFF"></u-notice-bar>
		</view>
		<!-- 卡片区域 -->
		<view class="card-box">

			<!-- 今日打卡 -->
			<view class="card-item" style="width: 100%;">
				<view class="card-info">
					<view class="t-icon t-icon-xueshengdaka"></view>
					<text class="info-text">今日打卡情况(今日迟到情况)</text>
				</view>
				<!-- 内容 -->
				<view class="calendar_container">
					<zsyCalendar :sundayIndex="6" @change="chooseCalendar" :mode="'close'" />
				</view>
			</view>

			<view class="card-item">
				<view class="card-info">
					<view class="t-icon t-icon-chengjiguanli"></view>
					<text class="info-text">今日评测</text>
				</view>
				<view class="charts-box">
					<qiun-data-charts type="arcbar" :chartData="todayData.evaluationArcbar" :loadingType="4"
						:canvas2d='true' canvasId='canvans931' :opts="evaluationOpts" />
				</view>
			</view>

			<view class="card-item">
				<view class="card-info">
					<view class="t-icon t-icon-xuexiaobaobei"></view>
					<text class="info-text">今日作业</text>
				</view>
				<view class="charts-box">
					<qiun-data-charts type="arcbar" :chartData="todayData.homeworkArcbar" :loadingType="4"
						:canvas2d='true' canvasId='canvans932' :opts="homeworkOpts" />
				</view>
			</view>

			<!-- 今日课程 -->
			<view class="card-item">
				<view class="card-info">
					<view class="t-icon t-icon-jiaowuxunke"></view>
					<text class="info-text">今日课程</text>
				</view>
				<!-- 内容 -->
				<view style="display: flex; align-items: center;">
					<view style="color: #3B4144;margin-left: 30rpx;font-size: 30rpx;font-weight: bold;">个人课程数:</view>
					<view class="card-content">{{classNum}}</view>
				</view>
				<view class="u-page__item">
					<u-collapse accordion :border="false">
						<u-collapse-item title="孩子今日课程:">
							<view style="display: flex; flex-wrap: wrap;">
								<u-tag v-for="(item,index) in classList" :key="index" :text="item" plain shape="circle"
									size="mini"></u-tag>
							</view>
						</u-collapse-item>
						<u-collapse-item title="今日授课老师:">
							<view style="display: flex; flex-wrap: wrap;">
								<u-tag v-for="(item,index) in teacherList" :key="index" :text="item" plain
									shape="circle" size="mini"></u-tag>
							</view>
						</u-collapse-item>
					</u-collapse>
				</view>
			</view>

			<!-- 今日问卷 -->
			<view class="card-item">
				<view class="card-info">
					<view class="t-icon t-icon-qingjiatiaoke"></view>
					<text class="info-text">今日活动</text>
				</view>
				<!-- 内容 -->
				<view style="display: flex; align-items: center;">
					<view style="color: #3B4144;margin-left: 30rpx;font-size: 30rpx;font-weight: bold;">问卷完成率:</view>
					<view class="card-content">{{questionnaire}}%</view>
				</view>
				<view style="padding: 0rpx 20rpx 10rpx 20rpx;">
					<u-line-progress :showText="false" :percentage="questionnaire" activeColor="#5b7cff" height="15">
					</u-line-progress>
				</view>
				<!-- 内容 -->
				<view style="display: flex; align-items: center;">
					<view style="color: #3B4144;margin-left: 30rpx;font-size: 30rpx;font-weight: bold;">投票完成率:</view>
					<view class="card-content">{{vote}}%</view>
				</view>
				<view style="padding: 0rpx 20rpx 10rpx 20rpx;">
					<u-line-progress :showText="false" :percentage="vote" activeColor="#ff9db2" height="15">
					</u-line-progress>
				</view>
			</view>
			<!-- 今日记录模块 -->
			<todaydata-box></todaydata-box>


			

		</view>

	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	//日历组件
	import zsyCalendar from '@/components/zsy-calendar/zsy-calendar'
	export default {
		name: 'Calendar',
		computed: {
			...mapState('m_chart', ['todayData']),
			...mapState('m_children', ['childreninfo']),
			...mapState('m_parent', ['myData'])
		},
		components: {
			zsyCalendar
		},
		data() {
			return {
				//今日课堂数
				classNum: 5,
				//今日课程
				classList: ['数学', '语文', '英语', '体育', '思品'],
				//授课老师
				teacherList: ['张老师', '李老师', '王老师', '陈老师', '黄老师'],

				//评测进度条属性
				evaluationOpts: {},
				//作业进度条属性
				homeworkOpts: {},
				//时间戳
				timeStamp: '',
				//问卷完成率
				questionnaire: 56,
				//投票完成率
				vote: 100,
			}
		},
		onLoad() {
			this.setOpts()
			this.getTimeStamp()
		},
		onPullDownRefresh() {
			this.setOpts()
			this.getTimeStamp()
			console.log('refresh')
			setTimeout(function() {
				uni.stopPullDownRefresh()
			}, 1000);
		},
		methods: {
			//设置更新
			setOpts() {
				//圆环图标题和副标题动态变化
				let evaluation = {
					title: {
						name: this.todayData.evaluationArcbar.series[0].data * 100 + "%",
						color: this.todayData.evaluationArcbar.series[0].color
					},
					subtitle: {
						name: this.todayData.evaluationArcbar.series[0].name
					},
					extra: {
						arcbar: {
							type: 'circle'
						}
					}
				}
				let homework = {
					title: {
						name: this.todayData.homeworkArcbar.series[0].data * 100 + "%",
						color: this.todayData.homeworkArcbar.series[0].color
					},
					subtitle: {
						name: this.todayData.homeworkArcbar.series[0].name
					},
					extra: {
						arcbar: {
							type: 'circle'
						}
					}
				}
				this.evaluationOpts = evaluation;
				this.homeworkOpts = homework;
			},
			// 日历选中日期改变事件回调
			chooseCalendar(e) {
				console.log(e)
			},
			//更新时间戳
			getTimeStamp() {
				var date = new Date(),
					hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
					minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
				this.timeStamp = (hour + ':' + minute).toString();
			}

		},
	}
</script>

<style lang="scss">
	@import '@/pages/common/mainpage.scss';
	//日历
	.calendar_container {
		background-color: #FFFFFF;
		padding: 10rpx;
		margin: 10rpx;
		box-sizing: border-box;
	}
</style>
