<template>
<!-- 	<custom-scroll-list :refreshFn="getBaomingList" :tabList="tabData" :defaultTab="0" ref="scrollRef"
		placeholder="请输入报名考试名称">
		<template #default="{list}">
			<scroll-list-card-baoming v-for="(item,index) in list" :key="item.lxId" :data="item"
				@btnClick="handleClick"></scroll-list-card-baoming>
		</template>
	</custom-scroll-list> -->
	<!-- 考试须知 -->
	<kaoshixuzhi ref="ksxzRef" @confirm="handleConfirm"></kaoshixuzhi>
</template>

<script setup>
	// import scrollListCardBaoming from "@/components/score-list-card-baoming/score-list-card-baoming.vue"
	import kaoshixuzhi from "@/components/kaoshixuzhi/kaoshixuzhi.vue"
	import {
		getBaomingList,
	} from "@/api/baoming.js";
	import {
		ref
	} from "vue";


	const tabData = [{
			label: "审核中",
			value: 0,
		},
		{
			label: "已通过",
			value: 1,
		}, {
			label: "未通过",
			value: 2,
		}, {
			label: "未报名",
			value: 3,
		}, {
			label: "已结束",
			value: 4,
		}
	]


	function goKaoshiPage(data) {
		uni.navigateTo({
			url: `/pages/exam/exam?ksId=${data.ksId}&zhuapai=${data.zhuapai}`
		})
	}
	
	function handleConfirm() {
		goKaoshiPage(activeKs.value)
	}

	function showKaoshiXuzhi() {
		const option = {
			ksId: activeKs.value.ksId
		}
		getClientKaoshiInfo(option).then(res => {
			examNoticeInfo.value = res.data;
			// 校验抓拍
			doCheckZhuapai()
		})

	}

	function doCheckZhuapai() {
		if (examNoticeInfo.value.zhuapai) {
			// 存在抓拍
		} else {
			// 不存在抓拍
			ksxzRef.value.showDialog(examNoticeInfo.value)
		}
	}

	function handleClick(data) {
		activeKs.value = data;
		if (data.status == 0) {
			// 未开始
			showKaoshiXuzhi()
		}
		if (data.status == 1) {
			// 可以考试
			showKaoshiXuzhi()
		}
		if (data.status == 2) {
			// 再次考试
			showKaoshiXuzhi()
		}
		if (data.status == 3) {
			// 考试中
			showKaoshiXuzhi()
		}
		if (data.status == 4) {
			// 已结束
			uni.showToast({
				title: '考试已结束',
				icon: 'none'
			})
		}
		if (data.status == 5) {
			// 未报名
			kaoShiApply({
				ksId: data.ksId
			}).then(res => {
				uni.showToast({
					title: '报名成功',
					icon: 'none'
				})
				scrollRef.value.onRefresh()
			})
		}

	}
</script>

<style lang="scss">

</style>