<template>
	<view class="container">
		<!-- 头部月份区域 -->
		<view class="header">
			<view class="title">
				<view class="month">
					{{month}}月汇总
				</view>
				<view class="right" @click="goToDetail">
					<img src="../../static/right.png" alt="">
				</view>
			</view>
			<view class="state">
				<view class="err">
					<view class="number">
						0
					</view>
					<view class="mes">
						异常次数（次）
					</view>
				</view>
				<view class="success">
					<view class="number">
						1
					</view>
					<view class="mes">
						打卡成功（次）
					</view>
				</view>
			</view>
		</view>

		<!-- 日历区域 -->
		<view class="calendar">
			<view class="calendar_title">
				每日记录
				<span>（5月）</span>
			</view>

			<view class="calendar_body">
				<uni-calendar :showMonth="false" @change="change" :selected="list" />
			</view>

			<view class="calendar_foot">

				<!-- 每一条记录区域 -->
				<view class="foot_item" v-for="item in list2" :key="item.id">
					<view>
						{{item.msg}}
					</view>
					<view class="box">
						<view class="circular" v-if="item.status==1"></view>
						<view class="circular color" v-else></view>
						{{item.status==0?"未打卡":"已打卡"}}
						<span>{{item.time}}</span>
					</view>
				</view>

			</view>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
						date: "2022-11-20",
						info: ''
					},
					{
						date: "2022-11-21",
						info: '',
						data: {
							custom: '自定义信息',
							name: '自定义消息头'
						}
					},
					{
						date: "2022-11-22",
						info: ''
					}
				],
				list2: [{
						id: 1,
						msg: "规则：课间操考勤打卡09:00 - 09:15",
						status: 0,
						time: "09:25:25"
					},
					{
						id: 2,
						msg: "规则：考勤打卡19:00 - 20:15",
						status: 1,
						time: "19:25:25"
					},
				],
				month: null
			};
		},
		onLoad() {
			this.getMonth()
		},
		methods: {
			// 获取当前时间月份
			getMonth() {
				let date = new Date()
				let month = date.getMonth() + 1
				this.month = month
			},
			// 点击日历日期回调
			change(e) {
				console.log('change 返回:', e)
			},
			// 跳转统计详情页面
			goToDetail() {
				uni.navigateTo({
					url: `/pages/statDetail/statDetail?month=${this.month}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		padding-top: 20rpx;

		.header {
			margin: 0 auto;
			width: 690rpx;
			height: 236rpx;
			background-color: #fff;

			.title {
				display: flex;
				height: 92rpx;

				.month {
					flex: 8;
					margin: 30rpx 0 0 30rpx;
					font-size: 32rpx;
					font-weight: 500
				}

				.right {
					display: flex;
					justify-content: center;
					align-items: center;
					flex: 1;

					img {
						width: 15rpx;
						height: 30rpx
					}
				}
			}

			.state {
				display: flex;
				height: 144rpx;

				.err {
					flex: 1;
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;

					.number {
						font-size: 46rpx;
						font-weight: 700;
					}

					.mes {
						font-size: 28rpx;
						color: #999999;
					}
				}

				.success {
					flex: 1;
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;

					.number {
						font-size: 46rpx;
						font-weight: 700;
					}

					.mes {
						font-size: 28rpx;
						color: #999999;
					}
				}
			}
		}

		.calendar {
			margin: 0 auto;
			margin-top: 30rpx;
			width: 693rpx;
			background-color: #fff;

			.calendar_title {
				padding-left: 30rpx;
				height: 100rpx;
				line-height: 100rpx;
				font-size: 32rpx;
				font-weight: 500;

				span {
					font-size: 26rpx;
					color: #999999
				}
			}

			.calendar_body {
				height: 690rpx;
				background-color: skyblue;
			}

			.calendar_foot {
				padding: 0 30rpx;
				margin-bottom: 80rpx;

				.foot_item {
					box-sizing: border-box;
					padding: 30rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-evenly;
					height: 130rpx;
					font-size: 24rpx;
					color: #808080;

					.box {
						display: flex;
						align-items: center;

						.circular {
							margin-right: 18rpx;
							width: 12rpx;
							height: 12rpx;
							border-radius: 6rpx;
							background-color: #31C20E;
						}

						.color {
							background-color: #999999;
						}

						span {
							margin-left: 18rpx;
						}
					}
				}
			}
		}
	}

	// 修改选中日期盒子圆角
	::v-deep .uni-calendar-item--isDay {
		border-radius: 50rpx;
	}

	::v-deep .uni-calendar-item--checked {
		border-radius: 50rpx;
	}
</style>
