Browse Source

Merge pull request '加盟页重复跳转问题' (#107) from wpd_bug into master

Reviewed-on: #107
pull/108/head
pengda 3 weeks ago
parent
commit
9e359da7dd
  1. 18
      src/utils/login.js

18
src/utils/login.js

@ -28,9 +28,9 @@ export async function autoLoginByToken(timeout = 10000) {
throw new Error('登陆失败'); throw new Error('登陆失败');
} }
// 可选:将 token 存入 localStorage // 存入 localStorage
localStorage.setItem('token', res.data.data.access_token) if(res.data.data.access_token) localStorage.setItem('token', res.data.data.access_token)
localStorage.setItem('nick', res.data.data.nick) if(res.data.data.nick) localStorage.setItem('nick', res.data.data.nick)
} }
const res = await axiosWithTimeout( const res = await axiosWithTimeout(
@ -45,16 +45,20 @@ export async function autoLoginByToken(timeout = 10000) {
} }
const access_token = localStorage.getItem('token') const access_token = localStorage.getItem('token')
if(access_token === ''){ if(!access_token){
throw new Error('登陆有误'); throw new Error('登陆有误');
} }
//非代理商 直接跳至加盟页 访问加盟页的话 不再重复跳转
const nick = localStorage.getItem('nick') const nick = localStorage.getItem('nick')
const currentPath = window.location.pathname
//非代理商 直接跳至加盟页 if(!nick && currentPath !== '/franchise'){
if(nick === ''){
const aid = urlParams.get('aid') const aid = urlParams.get('aid')
if(aid){
window.location.href = "/franchise?aid="+aid window.location.href = "/franchise?aid="+aid
}else{
window.location.href = "/franchise"
}
return true return true
} }

Loading…
Cancel
Save