Browse Source

加盟页重复跳转问题

pull/107/head
pengda 3 weeks ago
parent
commit
e7746da2e0
  1. 11
      src/utils/login.js

11
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,13 +45,12 @@ 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 const currentPath = window.location.pathname
if(!nick && currentPath !== '/franchise'){ if(!nick && currentPath !== '/franchise'){
const aid = urlParams.get('aid') const aid = urlParams.get('aid')

Loading…
Cancel
Save