对登录控制验证进行整理

This commit is contained in:
daihh
2023-03-01 19:25:50 +08:00
parent 8d2a270fa7
commit b874ef5307
9 changed files with 180 additions and 114 deletions

View File

@@ -19,23 +19,23 @@
mounted() {
let token=getToken();
let $this=this;
let urlPre=window.location.protocol+'//'+window.location.host+this.$config.context;
//console.log(token,'得到token');
if(!token){
console.log('未获得token,转向登录');
//this.$router.push({ path: process.env.VUE_APP_LOGIN_URL })
// #ifdef APP-PLUS
plus.runtime.openURL(this.$config.loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
// #endif
// #ifdef H5
//console.log('this.$config.loginPath',this.$config.loginPath);
if(this.$config.loginPath.startsWith('http')){
let returnUrl=window.location.protocol+'//'+window.location.host+this.$config.context;
location.href=this.$config.loginPath+"?returnUrl="+encodeURIComponent(returnUrl+'/pages/login/loading');
}else{
location.href=this.$config.loginPath;
}
// #endif
//this.$router.push({ path: process.env.VUE_APP_LOGIN_URL })
// #ifdef APP-PLUS
plus.runtime.openURL(this.$config.loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
// #endif
// #ifdef H5
//console.log('this.toUrl',this.toUrl);
//console.log('this.$config.loginPath',this.$config.loginPath);
if(this.toUrl){
location.href=this.$config.loginPath+"?returnUrl="+encodeURIComponent(urlPre+'/pages/login/loading?returnUrl='+this.toUrl);
}else{
location.href=this.$config.loginPath+"?returnUrl="+encodeURIComponent(urlPre+'/pages/login/loading');
}
// #endif
}else{
apiLogin.boeLogin(token).then(rs=>{
if(rs.status==200){
@@ -49,7 +49,10 @@
// })
uni.setStorageSync("boe_new_login",1);//记录新登录
let openUrl=$this.toUrl;
console.log(openUrl);
//http://localhost:8081/mobile/pages/login/loading?returnUrl=/pages/study/courseStudy?id=1028700304503054336
if(openUrl){
//如果openUrl的页面不存在或不对就会出现跳转不动的问题这个情况
if(openUrl.startsWith('http')){
location.href=openUrl
}else{
@@ -74,8 +77,11 @@
plus.runtime.openURL(this.$config.loginPath) //这里默认使用外部浏览器打开而不是内部web-view组件打开
// #endif
// #ifdef H5
location.href=this.$config.loginPath;
//window.open(this.$config.loginPath)
if(this.toUrl){
location.href=this.$config.loginPath+"?returnUrl="+encodeURIComponent(urlPre+'/pages/login/loading?returnUrl='+this.toUrl);
}else{
location.href=this.$config.loginPath+"?returnUrl="+encodeURIComponent(urlPre+'/pages/login/loading');
}
// #endif
}
}).catch(err=>{