From a0e9c96897b4a082f880f5e1898c4063e8787594 Mon Sep 17 00:00:00 2001 From: liyuanchao <438964165@qq.com> Date: Wed, 10 Sep 2025 13:34:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/http.interceptor.js | 9 +++++++++ pages/sys/home/home.vue | 22 +++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/common/http.interceptor.js b/common/http.interceptor.js index 87898be..2971a0c 100644 --- a/common/http.interceptor.js +++ b/common/http.interceptor.js @@ -52,6 +52,15 @@ const install = (Vue, vm) => { vm.$u.toast('未连接到服务器') return false; } + if(data.code == 401 && req.url.indexOf('/system/user/profile') === -1){ + // 清除用户信息并返回登录页 + vm.$u.vuex('vuex_user', {}); + vm.$u.vuex('vuex_token', ''); + uni.redirectTo({ + url: '/pages/sys/login/login' + }); + return false + } if (typeof data === 'object' && !(data instanceof Array)){ if (data.token){ diff --git a/pages/sys/home/home.vue b/pages/sys/home/home.vue index 9c2ce41..e65aeaf 100644 --- a/pages/sys/home/home.vue +++ b/pages/sys/home/home.vue @@ -148,9 +148,29 @@ import toast from '../../../uview-ui/libs/function/toast'; async getActivityList() { let res = await this.$u.api.getActivityList(); if (res.code == '200') { - this.hotList = res.rows + this.hotList = res.rows; + // 处理图片链接 + await this.getImageUrl(); } }, + async getImageUrl() { + // 处理hotList中的图片链接 + for (let i = 0; i < this.hotList.length; i++) { + const item = this.hotList[i]; + if (item.activityImgUrl) { + try { + const imgRes = await this.$u.api.getImageUrl({}, item.activityImgUrl); + if (imgRes.code == 200 && imgRes.data && imgRes.data.length > 0) { + // 将图片ID替换为实际的图片URL + this.$set(this.hotList[i], 'activityImgUrl', imgRes.data[0].url); + } + } catch (error) { + console.error('获取图片链接失败:', error); + } + } + } + console.log('t1',this.hotList) + }, goNoticeDetail(item){ let params = {} params.title = item.title