Compare commits

..

3 Commits

Author SHA1 Message Date
@zuopngfei
96f78218d6 dssff 2025-07-24 13:41:27 +08:00
@zuopngfei
d2257bdf30 Merge branch 'main' of https://git.1024tool.vip/xz/doctor-mini into main 2025-07-24 13:36:17 +08:00
@zuopngfei
3bcd80be76 dssff 2025-07-24 13:36:04 +08:00
3 changed files with 38 additions and 46 deletions

View File

@ -1,19 +1,8 @@
// 在登录成功后请调用 resetTokenInvalid() 重置 isTokenInvalid 标志
let isTokenInvalid = false;
const baseUrl = 'https://ddbs.1024tool.vip/'; 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需求加点逻辑判断处理即可
@ -33,13 +22,7 @@ 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: () => {
@ -47,7 +30,6 @@ function request(url, method = 'GET', data = {}) {
} }
}); });
} }
}
reject(res.data); reject(res.data);
return; return;
} }

View File

@ -34,6 +34,8 @@ Page({
weightData: [], weightData: [],
heightChart: null, heightChart: null,
weightChart: null, weightChart: null,
directChart: null,
indirectChart: null,
carList: [], carList: [],
carLength: 0, carLength: 0,
userInfo: {}, userInfo: {},
@ -145,6 +147,14 @@ 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;
}
}, },
// 初始化身高图表 // 初始化身高图表
@ -318,6 +328,7 @@ Page({
] ]
}); });
this.directChart = chart;
return chart; return chart;
}); });
} }
@ -353,6 +364,7 @@ Page({
] ]
}); });
this.indirectChart = chart;
return chart; return chart;
}); });
} }

View File

@ -1,5 +1,4 @@
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({
@ -47,7 +46,6 @@ 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