<template>
	<view>
		<zhuapaiConfirm ref="zhuapaiConfirmRef" @success="zpConfirmSuccess" @error="zpConfirmError"
			@cancel="zpConfirmCancel" key="1"></zhuapaiConfirm>
	</view>
</template>

<script setup>
	import {
		onLoad,
		onShow,
		onHide
	} from "@dcloudio/uni-app";
	import {
		ref,nextTick
	} from "vue";
	import zhuapaiConfirm from "@/components/zhuapaiConfirm/index.vue";

	const opt = ref(null);
	const zhuapaiConfirmRef = ref(null);

	onLoad((options) => {
		opt.value = options;
		nextTick(() => {
			zhuapaiConfirmRef.value.showDialog()
		})
	})

	function zpConfirmSuccess() {
		uni.redirectTo({
			url: `/pages/client/Kaoshi/exam?ksId=${opt.value.ksId}&zhuapai=${opt.value.zhuapai}&userKaozhengId=${opt.value.userKaozhengId}&from=${opt.value.from}`
		})
	}

	function zpConfirmError() {
		handleBack();
	}

	function zpConfirmCancel() {
		handleBack();
	}

	function handleBack() {
		const pages = getCurrentPages();
		if (pages.length > 1) {
			uni.navigateBack()
		} else {
			history.back();
		}
	}
</script>

<style>

</style>