<template>
	<div style="display: flex;flex-direction: column;height: 100vh; justify-content: center;align-items: center;">
		<div style="font-size: 16px;margin-left: -80px;margin-top: -68px;">登 录</div>
		<div>
			<el-input v-model="regnum" style="width: 240px" placeholder="" />
			<el-button type="primary" style="margin-left: 20px;" @click="login()">登 录</el-button>
		</div>
		
	</div>
</template>

<script setup>
	import {
		Login
	} from "@/api/api.js";
	import {
		ElMessage
	} from 'element-plus'
	import {
		ref,
		nextTick,
		onMounted
	} from 'vue'
	let regnum = ref('');
	const login = () => {
		if (regnum.value == '') {
			alert('请输入患者id');
			return false
		}

		Login({regnum:regnum.value}).then(res => {
			console.log(res)
			if (res.status) {
				sessionStorage.setItem('token', res.data.token);
				sessionStorage.setItem('refreshToken', res.data.refresh_token);
				var token = sessionStorage.getItem('token');
				if (token == res.data.token) {
					window.location.href = "./#/index"
				}

			} else {
				ElMessage.error(res.data.msg)
			}
		})
	}
	onMounted(() => {
		// login()
	})
</script>

<style scoped>
</style>