mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-13 12:56:46 +08:00
对登录控制验证进行整理
This commit is contained in:
@@ -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=>{
|
||||
|
||||
Reference in New Issue
Block a user