Compare commits
No commits in common. "96f78218d65b555f3645ea0fa6fadac6b5170a71" and "d5fbedd1919f1dac67564df0854d04359c52824f" have entirely different histories.
96f78218d6
...
d5fbedd191
@ -1,8 +1,19 @@
|
|||||||
const baseUrl = 'https://ddbs.1024tool.vip/';
|
// 在登录成功后请调用 resetTokenInvalid() 重置 isTokenInvalid 标志
|
||||||
|
let isTokenInvalid = false;
|
||||||
|
|
||||||
|
const baseUrl = 'https://ddbs.1024tool.vip/';
|
||||||
|
let isNavigatingToLogin = false;
|
||||||
|
|
||||||
|
// 重置 token 失效标志(登录成功后调用)
|
||||||
|
export function resetTokenInvalid() {
|
||||||
|
isTokenInvalid = false;
|
||||||
|
}
|
||||||
|
|
||||||
function request(url, method = 'GET', data = {}) {
|
function request(url, method = 'GET', data = {}) {
|
||||||
|
// 如果 token 已失效,直接中断请求
|
||||||
|
if (isTokenInvalid) {
|
||||||
|
return Promise.reject({ code: 10103, message: '登录已失效,请重新登录' });
|
||||||
|
}
|
||||||
const header = {
|
const header = {
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
// 有其他content-type需求加点逻辑判断处理即可
|
// 有其他content-type需求加点逻辑判断处理即可
|
||||||
@ -22,7 +33,13 @@ function request(url, method = 'GET', data = {}) {
|
|||||||
success(res) {
|
success(res) {
|
||||||
if (res.data.code) {
|
if (res.data.code) {
|
||||||
if (res.data.code == 10103) {
|
if (res.data.code == 10103) {
|
||||||
|
isTokenInvalid = true;
|
||||||
wx.removeStorageSync('access_token');
|
wx.removeStorageSync('access_token');
|
||||||
|
if (!isNavigatingToLogin) {
|
||||||
|
const pages = getCurrentPages();
|
||||||
|
const currentRoute = pages[pages.length - 1]?.route;
|
||||||
|
if (currentRoute !== 'pages/login/login') {
|
||||||
|
isNavigatingToLogin = true;
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '/pages/login/login',
|
url: '/pages/login/login',
|
||||||
complete: () => {
|
complete: () => {
|
||||||
@ -30,6 +47,7 @@ function request(url, method = 'GET', data = {}) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
reject(res.data);
|
reject(res.data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,8 +34,6 @@ Page({
|
|||||||
weightData: [],
|
weightData: [],
|
||||||
heightChart: null,
|
heightChart: null,
|
||||||
weightChart: null,
|
weightChart: null,
|
||||||
directChart: null,
|
|
||||||
indirectChart: null,
|
|
||||||
carList: [],
|
carList: [],
|
||||||
carLength: 0,
|
carLength: 0,
|
||||||
userInfo: {},
|
userInfo: {},
|
||||||
@ -147,14 +145,6 @@ Page({
|
|||||||
this.weightChart.dispose();
|
this.weightChart.dispose();
|
||||||
this.weightChart = null;
|
this.weightChart = null;
|
||||||
}
|
}
|
||||||
if (this.directChart) {
|
|
||||||
this.directChart.dispose();
|
|
||||||
this.directChart = null;
|
|
||||||
}
|
|
||||||
if (this.indirectChart) {
|
|
||||||
this.indirectChart.dispose();
|
|
||||||
this.indirectChart = null;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 初始化身高图表
|
// 初始化身高图表
|
||||||
@ -328,7 +318,6 @@ Page({
|
|||||||
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
this.directChart = chart;
|
|
||||||
return chart;
|
return chart;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -364,7 +353,6 @@ Page({
|
|||||||
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
this.indirectChart = chart;
|
|
||||||
return chart;
|
return chart;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import request from '~/api/request';
|
import request from '~/api/request';
|
||||||
|
import { resetTokenInvalid } from '~/api/request';
|
||||||
import { aesCryptoJS } from '~/utils/util';
|
import { aesCryptoJS } from '~/utils/util';
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
@ -46,6 +47,7 @@ Page({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetTokenInvalid()
|
||||||
const res = await request('doctor/login', 'post', {
|
const res = await request('doctor/login', 'post', {
|
||||||
password: aesCryptoJS(this.data.password),
|
password: aesCryptoJS(this.data.password),
|
||||||
mobile: this.data.mobile
|
mobile: this.data.mobile
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user