From 2548e15ac4e7d7355bf2f5b2613cb728f6287186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=88=90?= Date: Sun, 5 Oct 2025 11:23:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=99=BB=E9=99=86=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/env.ts | 6 +++--- src/other_pages/message/index.scss | 2 +- src/services/httpService.ts | 33 +++++++++++++++++------------- src/services/loginService.ts | 24 ---------------------- src/services/userService.ts | 2 +- src/store/userStore.ts | 2 +- 6 files changed, 25 insertions(+), 44 deletions(-) diff --git a/src/config/env.ts b/src/config/env.ts index 4587a0e..ae07994 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -24,11 +24,11 @@ const envConfigs: Record = { // 开发环境 development: { name: '开发环境', - apiBaseURL: 'https://sit.light120.com', - // apiBaseURL: 'http://localhost:9098', + // apiBaseURL: 'https://sit.light120.com', + apiBaseURL: 'http://localhost:9098', timeout: 15000, enableLog: true, - enableMock: true, + enableMock: false, // 客服配置 customerService: { corpId: 'ww51fc969e8b76af82', // 企业ID diff --git a/src/other_pages/message/index.scss b/src/other_pages/message/index.scss index ca3eacb..fdc71a9 100644 --- a/src/other_pages/message/index.scss +++ b/src/other_pages/message/index.scss @@ -14,7 +14,7 @@ position: sticky; top: 0; z-index: 100; - box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.06); + // box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.06); .navbar-content { height: 56px; diff --git a/src/services/httpService.ts b/src/services/httpService.ts index 225635a..d797fb7 100644 --- a/src/services/httpService.ts +++ b/src/services/httpService.ts @@ -120,7 +120,23 @@ class HttpService { // 业务状态码检查 if (data && typeof data === 'object') { - if (data.success === false || (data.code && data.code !== 0 && data.code !== 200)) { + + if (data.message === "用户不存在" || data.code === -2) { + tokenManager.clearTokens() + Taro.showToast({ + title: '登录已过期,请重新登录', + icon: 'none' + }) + Taro.reLaunch({ + url: '/pages/login/index' + }) + reject(new Error('用户不存在')) + return + } + + + + if ((data.code && data.code !== 0)) { if (showToast) { this.handleBusinessError(data) reject(new Error(data.message || '请求失败')) @@ -131,6 +147,8 @@ class HttpService { } } + + resolve(data) }) } @@ -201,19 +219,6 @@ class HttpService { let fullUrl = this.buildUrl(url, method === 'GET' ? params : undefined) - - // 后门id,用于调试 - let userid = this.getHashParam("userIdTest") - if (userid) { - if (fullUrl.indexOf("?") > -1) { - fullUrl += `&userIdTest45=${userid}` - } - else { - fullUrl += `?userIdTest45=${userid}` - } - } - - this.log('info', `发起请求: ${method} ${fullUrl}`, { data: method !== 'GET' ? data : undefined, params: method === 'GET' ? params : undefined diff --git a/src/services/loginService.ts b/src/services/loginService.ts index 60e3a72..5a3c74e 100644 --- a/src/services/loginService.ts +++ b/src/services/loginService.ts @@ -377,31 +377,7 @@ export const refresh_login_status = async (): Promise => { } }; -// 获取用户详细信息 -export const fetchUserProfile = async (): Promise< - ApiResponse -> => { - try { - const response = await httpService.post("user/detail"); - debugger; - return response; - } catch (error) { - console.error("获取用户信息失败:", error); - throw error; - } -}; - -// 更新用户信息 -export const updateUserProfile = async (payload: Partial) => { - try { - const response = await httpService.post("/user/update", payload); - return response; - } catch (error) { - console.error("更新用户信息失败:", error); - throw error; - } -}; // 更新用户手机号 export const updateUserPhone = async (payload: ChangePhoneParams) => { diff --git a/src/services/userService.ts b/src/services/userService.ts index 7e07a28..a4edc40 100644 --- a/src/services/userService.ts +++ b/src/services/userService.ts @@ -574,7 +574,7 @@ export class UserService { } } -// 从 loginService 移过来的用户相关方法 + // 获取用户详细信息 export const fetchUserProfile = async (): Promise> => { diff --git a/src/store/userStore.ts b/src/store/userStore.ts index de00e80..53a04e2 100644 --- a/src/store/userStore.ts +++ b/src/store/userStore.ts @@ -3,7 +3,7 @@ import { fetchUserProfile, updateUserProfile, UserInfoType, -} from "@/services/loginService"; +} from "@/services/userService"; export interface UserState { user: UserInfoType | {};