You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.1 KiB

// utils/login.js
import axios from 'axios'
export async function autoLoginByToken() {
const urlParams = new URLSearchParams(window.location.search)
const token = urlParams.get('token')
if (token) {
try {
const res = await axios.post(process.env.VUE_APP_BASE_API+'/agentnew/token_login', { token: token },{
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
})
if (res.data.status) {
// 可选:将 token 存入 localStorage
localStorage.setItem('token', res.data.data.access_token)
4 weeks ago
localStorage.setItem('nick', res.data.data.nick)
4 weeks ago
//非代理商 直接跳至加盟页
4 weeks ago
if(res.data.data.nick === ''){
4 weeks ago
const aid = urlParams.get('aid')
window.location.href = "/franchise?aid="+aid
return true
}
1 month ago
const url = new URL(window.location.href);
url.searchParams.delete('token');
window.location.replace(url.toString());
return true
} else {
return false
}
} catch (e) {
console.error('请求异常', e)
}
}
return false
}