<template>
	<view class="check-infomation">
		<view class="info-message">
			新生核验属于入校必办步骤，请到校后，持身份证、录取通知书至新生报到点进行刷脸核验。
		</view>
		<view class="list">
			<view class="sm-list">
				<text>姓名</text>
				<text>{{infoList.xsxm}}</text>
			</view>
			<view class="sm-list">
				<text>是否核验</text>
				<text>{{ infoList.isCheck === "1" ? '已核验' : '未核验' }}</text>
			</view>
			<FloatBall />
		</view>
		<button @click="doEdit" class="save-button">确认</button>
	</view>
</template>

<script>
	import FloatBall from "@/pages/compoents/FloatBall.vue";
	import {
		getCheckksh
	} from "@/api/information-check.js";

	import {
		confirmBdhy
	} from "@/api/toApi.js";
	export default {
		components: {
			FloatBall
		},
		created() {
			this.getCheckList();
		},
		data() {
			return {
				loading: false,
				checkList: [],
				infoList: {
					xsxm: '',
					ksh: '',
					isCheck: ''
				}
			};
		},
		methods: {
			async getCheckList() {
				try {
					let res = await getCheckksh();
					if (res.code === 200) {
						console.log(res);
						this.infoList.xsxm = res.data.stuinfo.xsxm;
						this.infoList.isCheck = res.data.isCheck;
						// console.log(res.data)
					}
				} catch (error) {
					console.error('获取核验信息失败:', error);
				}
			},
			async doEdit() {
				if (this.infoList.isCheck === "1") {
					try {
						const res = await confirmBdhy();
						if (res.code == 200) {
							uni.redirectTo({
								url: "/pages/newindex/newindex"
							});
						} else {
							wx.showToast({
								title: '确认请求失败',
								icon: 'none',
								duration: 1500
							});
						}
					} catch (error) {
						console.error('确认请求时出错', error);
						this.$refs.uToast.show({
							type: "error",
							message: '请求失败',
							duration: 1500
						});
					}
				} else {
					// 提示用户到线下进行核验
					wx.showToast({
						title: '请到线下先核验',
						icon: 'none',
						duration: 1500
					});
				}
			}
		}
	}
</script>


<style lang="scss">
	.check-infomation {

		.list {
			// display: flex;
			// justify-content: center;
			// align-items: center;
			// display: flex;
			// align-items: center;
			// flex-direction: column;
			padding: 20rpx;
			width: 100%;

			display: flex;
			flex-direction: column;
			justify-content: space-between;

			.sm-list {
				display: flex;
				justify-content: space-between;
				align-items: center;

				margin-top: 10px;
				width: 722rpx;
				height: 60rpx;
				border-top: 1px solid #EFEFEF;

				text:nth-child(1) {
					margin-top: 15px;
					color: #494949;
				}

				text:nth-child(2) {
					margin-top: 15px;
					color: #808080;
				}


			}

			.u-form-item {
				/deep/ .u-form-item__body__left {
					margin-bottom: 10px !important;
				}
			}


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

				.save-button {
					position: fixed;
					bottom: 100rpx;
					width: 80%;
					border-radius: 50rpx;
					background-color: #38B865;
					color: white;
				}
			}
		}

		.info-message {
			padding: 10px;
			background-color: #f8d7da;
			color: #721c24;
			border: 1px solid #f5c6cb;
			border-radius: 5px;
			margin-bottom: 10px;
		}

		.save-button {
			position: fixed;
			bottom: 100rpx;
			margin-left: 60rpx;
			width: 80%;
			border-radius: 50rpx;
			background-color: #38B865;
			color: white;
		}
	}
</style>