跳转登录去掉多加的/,同时清除一下token

This commit is contained in:
daihh
2022-12-10 10:24:28 +08:00
parent 9189b7e18f
commit 125d801424
3 changed files with 14 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
import config from '../config/index.js'
import {getToken} from '@/utils/token.js'
import {getToken,removeToken} from '@/utils/token.js'
import qs from 'qs'
const ReLoginUrl="/login";
@@ -33,6 +33,7 @@ const formRequest=function(method,url,data){
success:function(rs,statusCode){
if(rs.statusCode==200){
if(rs.data.status==401 || rs.data.status==402){
removeToken();
let loginPath=config.loginPath;
if(loginPath.startsWith('http')){
// #ifdef APP-PLUS
@@ -40,7 +41,7 @@ const formRequest=function(method,url,data){
// #endif
// #ifdef H5
//window.open(loginPath)
let returnUrl=window.location.protocol+'//'+window.location.host+"/"+config.context;
let returnUrl=window.location.protocol+'//'+window.location.host+config.context;
location.href=config.loginPath+"?returnUrl="+encodeURIComponent(returnUrl+'/pages/login/loading');
// #endif
}else{
@@ -83,6 +84,7 @@ const jsonRequest=function(method,url,data){
success:function(rs,statusCode){
if(rs.statusCode==200){
if(rs.data.status==401 || rs.data.status==402){
removeToken();
let loginPath=config.loginPath;
if(loginPath.startsWith('http')){
// #ifdef APP-PLUS
@@ -90,7 +92,7 @@ const jsonRequest=function(method,url,data){
// #endif
// #ifdef H5
//window.open(loginPath)
let returnUrl=window.location.protocol+'//'+window.location.host+"/"+config.context;
let returnUrl=window.location.protocol+'//'+window.location.host+config.context;
location.href=config.loginPath+"?returnUrl="+encodeURIComponent(returnUrl+'/pages/login/loading');
// #endif
}else{