<template>
	<view class="container">
		<!-- 头部区域 -->
		<view class="header">
			<!-- 时间区域 -->
			<view class="calendar">
				<!-- 双左箭头区域 -->
				<view class="double" @click="handleDoubleLeft">
					<img src="../../static/double_left.png">
				</view>
				<!-- 左箭头区域区域 -->
				<view class="single" @click="handleLeft">
					<img src="../../static/left.png">
				</view>
				<!-- 时间区域 -->
				<view class="time">
					{{year}}-{{comMonth}}
				</view>
				<!-- 双右箭头区域 -->
				<view class="single2" @click="handleRight">
					<img src="../../static/right2.png">
				</view>
				<!-- 右箭头区域 -->
				<view class="double" @click="handleDoubleRight">
					<img src="../../static/double_right.png">
				</view>

			</view>

			<!-- 打卡状态切换区域 -->
			<view class="state">
				<uni-segmented-control :current="current" :values="items" styleType="text" @clickItem="onClickItem"
					activeColor="#0082FC"></uni-segmented-control>
			</view>
		</view>

		<!-- 打卡记录区域 -->
		<view class="list">
			<!-- 每一条记录区域 -->
			<view class="box" v-for="item in list" :key="item.id">
				<!-- 人物信息区域 -->
				<view class="person">
					<view class="img">
						<img :src="item.peopleImg">
					</view>
					<view class="info">
						<view class="name">
							{{item.name}}
						</view>
						<view class="college">
							{{item.college}}
						</view>
					</view>
				</view>
				<!-- 图片区域 -->
				<view class="imgs" v-if="item.imgsList">
					<view class="imgs_item" v-for="(img,index) in (item.imgsList)" :key="index">
						<view class="image">
							<img :src="img.url">
						</view>
						<view class="title">
							{{img.title}}
						</view>
					</view>

				</view>
				<!-- 打卡信息区域 -->
				<view class="msg">
					<view class="msg_item">
						<view class="key">
							打卡状态：
						</view>
						<view class="value">
							{{item.status}}
						</view>
					</view>
					<view class="msg_item">
						<view class="key">
							打卡规则：
						</view>
						<view class="value">
							{{item.rule}}
						</view>
					</view>
					<view class="msg_item" v-if="item.time">
						<view class="key">
							打卡时间：
						</view>
						<view class="value">
							{{item.time}}
						</view>
					</view>
					<view class="msg_item" v-if="item.place">
						<view class="key">
							打卡地址：
						</view>
						<view class="value">
							{{item.place}}
						</view>
					</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				year: null,
				month: null,
				items: ['全部', '打卡成功', '打卡失败'],
				current: 0,
				list: [],
				list2: [{
						id: 1,
						peopleImg: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_bt%2F0%2F13579194276%2F1000&refer=http%3A%2F%2Finews.gtimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1671596163&t=52c9def84f0fa7832bfc5824364917e0",
						name: "程佳欢",
						college: "文法学院",
						imgsList: [{
								url: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_bt%2F0%2F13579194276%2F1000&refer=http%3A%2F%2Finews.gtimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1671596163&t=52c9def84f0fa7832bfc5824364917e0",
								title: "匹对照片"
							},
							{
								url: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_bt%2F0%2F13579194276%2F1000&refer=http%3A%2F%2Finews.gtimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1671596163&t=52c9def84f0fa7832bfc5824364917e0",
								title: "被匹对照片"
							},
							{
								url: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_bt%2F0%2F13579194276%2F1000&refer=http%3A%2F%2Finews.gtimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1671596163&t=52c9def84f0fa7832bfc5824364917e0",
								title: "场景照片"
							},
						],
						status: '打卡成功',
						rule: "课间操打卡规则已打卡",
						time: "2022-02-04   15:15:15",
						place: "江西省南昌市南昌交通学院操场"
					},

					{
						id: 2,
						peopleImg: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_bt%2F0%2F13579194276%2F1000&refer=http%3A%2F%2Finews.gtimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1671596163&t=52c9def84f0fa7832bfc5824364917e0",
						name: "陈志斌",
						college: "南昌交通学院",
						imgsList: [{
								url: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_bt%2F0%2F13579194276%2F1000&refer=http%3A%2F%2Finews.gtimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1671596163&t=52c9def84f0fa7832bfc5824364917e0",
								title: "匹对照片"
							},
							{
								url: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_bt%2F0%2F13579194276%2F1000&refer=http%3A%2F%2Finews.gtimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1671596163&t=52c9def84f0fa7832bfc5824364917e0",
								title: "被匹对照片"
							},
							{
								url: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_bt%2F0%2F13579194276%2F1000&refer=http%3A%2F%2Finews.gtimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1671596163&t=52c9def84f0fa7832bfc5824364917e0",
								title: "场景照片"
							},
						],
						status: '打卡成功',
						rule: "课间操打卡规则已打卡",
						time: "2022-11-04   15:15:15",
						place: "江西省南昌市经开区"
					},
				],
				list3: [{
						id: 1,
						peopleImg: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_bt%2F0%2F13579194276%2F1000&refer=http%3A%2F%2Finews.gtimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1671596163&t=52c9def84f0fa7832bfc5824364917e0",
						name: "甘昱新",
						college: "文法学院",
						status: '未打卡',
						rule: "课间操打卡规则",
					},
					{
						id: 2,
						peopleImg: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_bt%2F0%2F13579194276%2F1000&refer=http%3A%2F%2Finews.gtimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1671596163&t=52c9def84f0fa7832bfc5824364917e0",
						name: "甘昱新",
						college: "文法学院",
						status: '未打卡',
						rule: "课间操打卡规则",
					},
				]
			};
		},
		onLoad(options) {
			this.month = options.month - 0 || 1
			this.getTime()
			this.list = this.list2
		},
		computed: {
			comMonth() {
				if (this.month) {
					let month = this.month < 10 ? '0' + this.month : this.month
					console.log(month);
					return month
				}
			}
		},
		methods: {
			// 获取当前年份
			getTime() {
				let date = new Date()
				let year = date.getFullYear()
				this.year = year
			},

			onClickItem(e) {
				console.log(e.currentIndex);
				// if (e.currentIndex == 0) {
				// 	this.list = this.list2
				// } else {
				// 	this.list = this.list3
				// }
			},

			handleDoubleLeft() {
				if (this.year <= 2000) {
					uni.showToast({
						title: "不能选择2000年之前",
						icon: 'none'
					})
				} else {
					this.year -= 1
				}
			},
			handleLeft() {
				if (this.month <= 1) {
					if (this.year <= 2000) {
						uni.showToast({
							title: "不能选择2000年之前",
							icon: 'none'
						})
					} else {
						this.year -= 1
						this.month = 12
					}
				} else {
					this.month -= 1
				}
			},

			handleRight() {
				if (this.month >= 12) {
					if (this.year >= 2025) {
						uni.showToast({
							title: "不能选择2025年之后",
							icon: 'none'
						})
					} else {
						this.year += 1
						this.month = 1
					}
				} else {
					this.month += 1
				}
			},
			handleDoubleRight() {
				if (this.year >= 2025) {
					uni.showToast({
						title: "不能选择2025年之后",
						icon: 'none'
					})
				} else {
					this.year += 1
				}
			},
		}
	}
</script>

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

		.header {
			display: flex;
			flex-direction: column;
			justify-content: space-evenly;
			margin: 0 auto;
			width: 690rpx;
			height: 192rpx;
			background-color: #fff;

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

				.double {
					width: 40rpx;
					height: 40rpx;

					img {
						width: 100%;
						height: 100%;
					}
				}

				.single {
					margin-left: 30rpx;
					width: 40rpx;
					height: 40rpx;

					img {
						width: 80%;
						height: 70%;
					}
				}

				.single2 {
					margin-right: 30rpx;
					width: 40rpx;
					height: 40rpx;

					img {
						width: 100%;
						height: 70%;
					}
				}

				.time {
					width: 180rpx;
					height: 44rpx;
					font-size: 32rpx;
					text-align: center;
				}
			}

			.state {
				display: flex;
				flex-direction: column;
				justify-content: center;
				flex: 1;
			}
		}

		.list {
			padding-bottom: 50rpx;

			.box {
				margin: 0 auto;
				margin-top: 20rpx;
				width: 690rpx;
				background-color: #fff;

				.person {
					display: flex;
					align-items: center;
					height: 134rpx;

					.img {
						margin: 0 20rpx 0 30rpx;
						width: 70rpx;
						height: 70rpx;

						img {
							width: 100%;
							height: 100%;
						}
					}

					.info {
						width: 620rpx;
						height: 70rpx;

						.name {
							font-size: 32rpx;
						}

						.college {
							font-size: 24rpx;
							color: #A6A6A6;
						}
					}
				}

				.imgs {
					display: flex;
					justify-content: space-evenly;
					height: 201rpx;

					.imgs_item {
						display: flex;
						flex-direction: column;
						align-items: center;
						flex: 1;

						.image {
							width: 120rpx;
							height: 120rpx;

							img {
								width: 100%;
								height: 100%;
							}
						}

						.title {
							margin-top: 10rpx;
							font-size: 28rpx;
						}
					}
				}

				.msg {
					margin-left: 30rpx;

					.msg_item {
						display: flex;
						align-items: center;
						height: 63rpx;
						font-size: 28rpx;

						.key {
							color: #808080;
						}

						.value {}
					}
				}
			}
		}
	}
</style>
