<template>
	<!-- 今日记录模块 -->
	<view class="module-container">
		<u-tabs :list="list" :current="current" @change="change"
			:activeStyle="{color: '#5b7cff',fontWeight: 'bold',transform: 'scale(1.04)',}"
			:inactiveStyle="{color: '#b0b0b1',fontWeight: 'bold',transform: 'scale(1)'}" lineColor="#5b7cff"
			lineWidth="60"></u-tabs>

		<!-- 记录模块 -->
		<view class="module-box" v-if="current == 0">
			<view class="module-item">
				<view class="module-item-box">
					<text class="module-item-text">自主学习记录</text>
					<view class="num-box">
						<text class="module-item-num">5.5</text>
						<text class="unit">小时</text>
					</view>
					<view class="t-icon t-icon-shizhong-copy2-copy"></view>
				</view>
			</view>

			<view class="module-item" style="background-color: #00cca3;">
				<view class="module-item-box">
					<text class="module-item-text">娱乐放松记录</text>
					<view class="num-box">
						<text class="module-item-num">5</text>
						<text class="unit">小时</text>
					</view>
					<view class="t-icon t-icon-shizhong-copy3-copy"></view>
				</view>
			</view>

			<view class="module-item" style="background-color: #ff9db2;">
				<view class="module-item-box">
					<text class="module-item-text">运动锻炼记录</text>
					<view class="num-box">
						<text class="module-item-num">5</text>
						<text class="unit">分钟</text>
					</view>
					<view class="t-icon t-icon-shizhong-copy4-copy"></view>
				</view>
			</view>

			<view class="module-item" style="background-color: #f9c752;">
				<view class="module-item-box">
					<text class="module-item-text">睡眠记录</text>
					<view class="num-box">
						<text class="module-item-num">8</text>
						<text class="unit">小时</text>
					</view>
					<view class="t-icon t-icon-shizhong-copy1-copy"></view>
				</view>
			</view>
		</view>

		<!-- 记录表 -->
		<view class="module-box" v-if="current == 1">
			<view class="card-item" style="width: 710rpx;">
				<view class="card-info">
					<view class="t-icon t-icon-jiaoshidaka"></view>
					<text class="info-text">本周学习记录</text>
				</view>
				<view style="width: 100%; height: 500rpx; margin-top: -30rpx;">
					<qiun-data-charts type="column" :chartData="todayData.studyColumn" :loadingType="4" :canvas2d='true'
						canvasId='canvans912' :opts="{dataLabel:false, extra:{column: {barBorderCircle:true}}}" />
				</view>
			</view>

			<view class="card-item">
				<view class="card-info">
					<view class="t-icon t-icon-jiankangshangbao"></view>
					<text class="info-text">本周运动</text>
				</view>
				<view style="width: 100%; height: 350rpx; margin-top: -10rpx;">
					<qiun-data-charts type="pie" :chartData="todayData.exercisePie" :loadingType="4" :canvas2d='true'
						canvasId='canvans8121' />
				</view>
			</view>

			<view class="card-item">
				<view class="card-info">
					<view class="t-icon t-icon-jiankangshangbao"></view>
					<text class="info-text">本周睡眠</text>
				</view>
				<view style="width: 100%; height: 350rpx; margin-top: -10rpx;">
					<qiun-data-charts type="ring" :chartData="todayData.sleepRing" :loadingType="4" :canvas2d='true'
						canvasId='canvans9122' :tooltipFormat='yAxisDemo1' />
				</view>
			</view>
		</view>


	</view>

</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		name: "todaydata-box",
		computed: {
			...mapState('m_chart', ['todayData']),
		},
		data() {
			return {
				//模块名
				list: [{
					name: '今日记录'
				}, {
					name: '历史记录'
				}],
				//当前模块
				current: 0,
				//动画
				transition: true


			};
		},
		methods: {
			change(index) {
				console.log(index)
				this.current = index.index
			}
		}
	}
</script>

<style lang="scss">
	.module-container {
		display: flex;
		flex-direction: column;
	}

	.module-box {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: space-between;

		.module-item {
			margin: 10rpx 0;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			background-color: #FFFFFF;
			box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.05);
			border-radius: 16rpx;
			width: 347rpx;
			height: 230rpx;
			background-color: #5b7cff;
			overflow: hidden;

			.module-item-box {
				padding: 30rpx;
				width: 100%;
				display: flex;
				flex-direction: column;

				.t-icon {
					width: 250rpx;
					height: 250rpx;
					margin: -250rpx 0 0 150rpx;
				}
			}

		}
	}

	.card-item {
		margin: 10rpx 0;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		background-color: #FFFFFF;
		box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.05);
		border-radius: 16rpx;
		width: 347rpx;
		height: auto;

		.card-info {
			display: flex;
			align-items: center;
			padding: 15rpx;

			.info-text {
				font-size: 30rpx;
				font-weight: bold;
				color: #3B4144;
				margin-left: 10rpx;
			}

			.t-icon {
				width: 40rpx;
				height: 40rpx;
			}
		}

		.card-content {
			font-size: 35rpx;
			margin: 10rpx 0 10rpx 25rpx;
			color: #3B4144;
			font-weight: bold;
		}
	}

	.module-item-text {
		color: #FFFFFF;
		font-size: 35rpx;
		font-weight: bold;
		z-index: 1;
	}

	.num-box {
		margin: 30rpx 0 0 20rpx;
		display: flex;
		align-items: flex-end;

		.module-item-num {
			color: #FFFFFF;
			font-size: 70rpx;
			font-weight: bold;
			z-index: 1;
		}

		.unit {
			margin-bottom: 15rpx;
			margin-left: 20rpx;
			color: #f5f5f5;
			font-size: 35rpx;
			font-weight: bold;
			z-index: 1;
		}
	}
</style>
