From e3720c597147584cd7580505d40c9a7c00590a92 Mon Sep 17 00:00:00 2001 From: huliyong <2783385703@qq.com> Date: Wed, 7 May 2025 17:14:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=99=BB=E5=BD=95=E7=8A=B6=E6=80=81):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95=E7=8A=B6=E6=80=81=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E6=97=B6=E7=9A=84=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在用户登录状态失效时,移除本地存储的token并跳转到登录页面,同时在各页面添加登录状态检查,确保未登录用户无法访问相关功能。 --- api/http.js | 1 + mixins/list.js | 5 + pages/index/center.vue | 785 +++++++++++++++++++++++++------------------------ pages/index/record.vue | 595 +++++++++++++++++++------------------ 4 files changed, 721 insertions(+), 665 deletions(-) diff --git a/api/http.js b/api/http.js index 6c3da63..fdf74ea 100644 --- a/api/http.js +++ b/api/http.js @@ -35,6 +35,7 @@ function http(uri, data, callback, method = 'GET', showLoading, title) { if(res.statusCode == 401 || res.data.message == '操作失败,token非法无效!' || res.data.message == '操作失败,用户不存在!'){ + uni.removeStorageSync('token') store.commit('logout') console.error('登录过期'); utils.toLogin() diff --git a/mixins/list.js b/mixins/list.js index 23bb70e..3eea63b 100644 --- a/mixins/list.js +++ b/mixins/list.js @@ -46,6 +46,11 @@ export default { * @returns {Promise} 返回Promise对象 */ getData(queryParams){ + + if(this.authApi && !uni.getStorageSync('token')){ + return + } + return new Promise((success, error) => { if(!this.mixinsListApi){ return console.error('mixinsListApi 缺失'); diff --git a/pages/index/center.vue b/pages/index/center.vue index a878b45..d8c48f9 100644 --- a/pages/index/center.vue +++ b/pages/index/center.vue @@ -1,395 +1,408 @@ \ No newline at end of file diff --git a/pages/index/record.vue b/pages/index/record.vue index fde38f6..8e46e80 100644 --- a/pages/index/record.vue +++ b/pages/index/record.vue @@ -1,287 +1,324 @@