修复bug

This commit is contained in:
weipengfei 2023-09-08 17:25:49 +08:00
parent 571237bb0e
commit ac6618421b
3 changed files with 20 additions and 9 deletions

View File

@ -3,7 +3,7 @@ import oahttp from "@/utils/oahttp.js";
/**
* 登录
*/
export const loginAccount = (data) => oahttp.post('/login/account', data, { noAuth: true })
export const loginAccount = (data, onReLogin = false) => oahttp.post('/login/account', data, { noAuth: true, onReLogin: onReLogin })
/**
* cesi

View File

@ -59,16 +59,22 @@ const actions = {
RE_LOGIN({ state, commit }, data) {
return new Promise((resolve, reject) => {
let fromData = encrypt.decode('ACT');
loginAccount({ ...fromData }).then((res) => {
commit('SET_TOKEN', res.data);
oaHttp[data.method](data.url, data.data, data.opt).then((e) => {
resolve(e);
console.log(fromData);
if(fromData) {
loginAccount({ ...fromData }, true).then((res) => {
commit('SET_TOKEN', res.data);
oaHttp[data.method](data.url, data.data, data.opt).then((e) => {
resolve(e);
}).catch((err) => {
reject(err)
})
}).catch((err) => {
reject(err)
})
}).catch((err) => {
reject(err)
})
}else {
commit('LOGOUT')
reject();
}
})
},
MobileLogin({ state, commit }, force) {

View File

@ -19,7 +19,8 @@ function toLogin() {
function baseRequestTwo(url, method, data, {
noAuth = false,
noVerify = false
noVerify = false,
onReLogin = false
}) {
let Url = HTTP_REQUEST_URL_THREE,
header = HEADER;
@ -59,6 +60,10 @@ function baseRequestTwo(url, method, data, {
if (noVerify)
reslove(res.data);
else if (res.data.code == -1) {
if(onReLogin) {
store.commit('LOGOUT');
return reject();
}
// 如果登录超时,自动重新登录并且继续发送请求
store.dispatch("RE_LOGIN", {
url: url,