<template>
	<view class="mobile-tzs-page">
		<view class="icon-title-navBar-box">
			<text class="nav-bar-title">录取通知书</text>
		</view>
		<view class="serch-box">
			<input class="serch-input" v-model="name" focus placeholder="请输入姓名" />
			<input class="serch-input" v-model="idcard" type="idcard" placeholder="请输入身份证号" />
		</view>
		<view class="tzs-btn" @click="zhengshuSearch">搜索</view>
	</view>
</template>

<script setup>
	import {
		toast
	} from "@/utils/common";
	import {
		onLoad
	} from "@dcloudio/uni-app";
	import {
		getAppConfig,
		login,
		queryCert
	} from '@/api/login.js'
	import cacheManager from '@/utils/cacheManager.js'
	import JSEncrypt from 'jsencrypt';
	import {
		ref
	} from 'vue';
	const name = ref('')
	const idcard = ref('')
	onLoad(() => {

	})

	function zhengshuSearch() {
		if (!name.value) {
			toast('请输入姓名')

			return false;
		}
		if (!idcard.value) {
			toast('请输入身份证号')
			return false;
		}

		let req = {
			name: name.value,
			idcard: idcard.value
		};
		queryCert(req).then(res => {
			console.log(res);
			if (res.code == 0) {

				if (cacheManager.get('qrCode')) {
					cacheManager.remove('qrCode')
				}
				cacheManager.set('qrCode', JSON.stringify({
					base64: res.data
				}));
				uni.redirectTo({
					url: '/pages/showZhengshu'
				});
		
			} else {
				toast('无对应证书信息！');
				return false
			}
		})
	}
</script>