<template>
	<!-- 医生直接跳转过来，查看开单记录 -->
	<view>
		His登录
		
	</view>
</template>

<script setup>
	import {
		HisAutoLogin
	} from "@/api/api.js";
	import {
		ElMessage
	} from 'element-plus'
	import {
		ref,nextTick,onMounted
	} from 'vue'
	const autoLogin=()=>{
		HisAutoLogin({
			usercode: getParameterByName('usercode'),
			deptcode: getParameterByName('deptcode')
		}).then(res => {
				if(res.status){
					sessionStorage.setItem('token', res.data.access_token);
					sessionStorage.setItem('refreshToken', res.data.refresh_token);
					sessionStorage.setItem('default_reg_num', getParameterByName('cardno'));//设置默认查询患者id
					// sessionStorage.setItem('tk', JSON.stringify(res.data.tk));
					var token = sessionStorage.getItem('token');
					console.log(token)
					if (token!=null && token == res.data.access_token) {
						window.location.href = "./#/yewu/mainList"
						//window.location.href = "./#/info/EntrustList"
					}else{
						ElMessage.error("登录失败")
					}
				}else{
					ElMessage.error(res.msg)
				}
		})
	}
	onMounted(()=>{
		 autoLogin()
	})
	//获取url参数
	    function getParameterByName(name, url) {
	        if (!url) url = decodeURIComponent(window.location.href)
	        name = name.replace(/[\[\]]/g, '\\$&')
	        var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
	            results = regex.exec(url)
	        if (!results) return null
	        if (!results[2]) return ''
	        return decodeURIComponent(results[2].replace(/\+/g, ' '))
	    }
</script>

<style>
</style>