Files
learning-system-portal/src/views/Loading.vue
2023-11-23 14:28:25 +08:00

62 lines
1.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div>
<!--页面加载加载完成后-->
</div>
</template>
<script>
import Cookies from 'vue-cookies'
import apiLogin from '@/api/login.js'
import { getToken,setToken } from '@/utils/token'
export default{
mounted(){
this.toUrl=this.$route.query.returnUrl;
let token=getToken();
let $this=this;
if(!token){
//console.log(token,'未获取token');
setTimeout(function(){
$this.curToken=getToken();
if(!$this.curToken){
//console.log(token,'第二次未获取token');
location.href = process.env.VUE_APP_LOGIN_URL;
}else{
$this.boeLogin();
}
},500);
}else{
this.curToken=token;
this.boeLogin();
}
},
data(){
return {
curToken:'',
toUrl:''
}
},
methods:{
boeLogin(){
apiLogin.boeLogin(this.curToken).then(rs=>{
if(rs.status==200){
//setToken(rs.result.access_token);
localStorage.setItem(this.$xpage.constants.newLoginKey,1);
if(this.toUrl){
location.href=this.toUrl;
}else{
this.$router.push({ path: "/index" })
}
//this.$router.push({ path: "/index" })
}else{
this.$message.error("登录失败:"+rs.message);
}
})
}
}
}
</script>
<style>
</style>