From 49eeab90e233d8b9bc5ffdcb1d15c546a9aca057 Mon Sep 17 00:00:00 2001 From: WindowBird <13870814+windows-bird@user.noreply.gitee.com> Date: Mon, 1 Sep 2025 11:51:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7=E8=87=AA?= =?UTF-8?q?=E5=B7=B1=E7=9A=84=E8=AE=BE=E5=A4=87=E5=88=97=E8=A1=A8=EF=BC=8C?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7=E6=95=B0=E6=8D=AE=EF=BC=8C?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=98=AF=E5=90=A6=E6=98=AF=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E4=BA=BA=EF=BC=8C=E9=80=9A=E8=BF=87=E6=98=AF=E5=90=A6=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=88=A4=E5=88=AB=E6=98=AF=E5=90=A6=E5=8F=91=E9=80=81?= =?UTF-8?q?=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.vue | 6 ++++++ pages/profile/profile.vue | 10 ++++++++++ utils/request.js | 8 +------- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index fa99df7..b07bcb3 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -171,7 +171,13 @@ export default { // 获取设备列表 async fetchDeviceList() { try { + const token = uni.getStorageSync('token') + if (!token) { + console.log('暂无登录,不请求设备列表') + return + } const response = await getDeviceList() + if (response.code === 200 && response.data && Array.isArray(response.data)) { // 转换设备数据格式 const devices = response.data.map(device => { diff --git a/pages/profile/profile.vue b/pages/profile/profile.vue index 7301314..5e03c81 100644 --- a/pages/profile/profile.vue +++ b/pages/profile/profile.vue @@ -174,6 +174,11 @@ export default { async fetchUserData() { this.loading = true try { + const token = uni.getStorageSync('token') + if (!token) { + console.log('暂无登录,不请求用户数据') + return + } // 并行获取所有数据 const [userInfoRes, financialRes, statsRes] = await Promise.allSettled([ this.fetchUserInfo(), @@ -235,6 +240,11 @@ export default { async getIsAgent() { try { + const token = uni.getStorageSync('token') + if (!token) { + console.log('暂无登录,不请求是否是代理人') + return + } const response = await isAgent() this.isAgent = response.data } catch (error) { diff --git a/utils/request.js b/utils/request.js index 292112d..93cde2c 100644 --- a/utils/request.js +++ b/utils/request.js @@ -139,13 +139,7 @@ function handleResponseError(res, reject, options = {}) { const errorMap = { 401: { title: '登录已过期,请重新登录', - action: () => { - setTimeout(() => { - uni.reLaunch({ - url: '/pages/login/login', - }) - }, 1500) - }, + action: () => {}, }, 403: { title: '权限不足',