mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-12 04:16:48 +08:00
对登录控制验证进行整理
This commit is contained in:
33
utils/tologin.js
Normal file
33
utils/tologin.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import config from '@/config/index.js'
|
||||
|
||||
export function toLogin(ajaxUrl) {
|
||||
let pageUrl=location.href;
|
||||
console.log(pageUrl,'pageUrl');
|
||||
let urlPre=window.location.protocol+'//'+window.location.host;
|
||||
console.log(urlPre,'urlPre');
|
||||
let urlContext=config.context;
|
||||
console.log(urlContext,'urlContext');
|
||||
let returnPage=pageUrl.substring((urlPre+urlContext).length);
|
||||
console.log(returnPage,'returnPage');
|
||||
console.log(config.loginPath+"?returnUrl="+urlPre+urlContext+'/pages/login/loading?returnUrl='+returnPage,'生成的url');
|
||||
|
||||
if(ajaxUrl && ajaxUrl.indexOf('/xboe/portal/init')>-1){
|
||||
return;
|
||||
}
|
||||
//http://localhost:8081/mobile/pages/study/courseStudy?id=1028700304503054336
|
||||
if(pageUrl.indexOf('returnUrl')>-1){
|
||||
console.log(pageUrl,'to pageUrl')
|
||||
//location.href=config.loginPath+"?returnUrl="+pageUrl;
|
||||
// uni.redirectTo({
|
||||
// url:config.loginPath
|
||||
// })
|
||||
}else{
|
||||
if(process.env.NODE_ENV === 'development'){
|
||||
location.href=config.loginPath+"?returnUrl="+encodeURIComponent(returnPage);
|
||||
}else{
|
||||
location.href=config.loginPath+"?returnUrl="+encodeURIComponent(urlPre+urlContext+'/pages/login/loading?returnUrl='+returnPage);
|
||||
}
|
||||
//location.href=config.loginPath
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user