修复登陆问题

This commit is contained in:
张成
2025-10-05 11:23:20 +08:00
parent d334831876
commit 2548e15ac4
6 changed files with 25 additions and 44 deletions

View File

@@ -24,11 +24,11 @@ const envConfigs: Record<EnvType, EnvConfig> = {
// 开发环境
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

View File

@@ -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;

View File

@@ -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

View File

@@ -377,31 +377,7 @@ export const refresh_login_status = async (): Promise<boolean> => {
}
};
// 获取用户详细信息
export const fetchUserProfile = async (): Promise<
ApiResponse<UserInfoType>
> => {
try {
const response = await httpService.post("user/detail");
debugger;
return response;
} catch (error) {
console.error("获取用户信息失败:", error);
throw error;
}
};
// 更新用户信息
export const updateUserProfile = async (payload: Partial<UserInfoType>) => {
try {
const response = await httpService.post("/user/update", payload);
return response;
} catch (error) {
console.error("更新用户信息失败:", error);
throw error;
}
};
// 更新用户手机号
export const updateUserPhone = async (payload: ChangePhoneParams) => {

View File

@@ -574,7 +574,7 @@ export class UserService {
}
}
// 从 loginService 移过来的用户相关方法
// 获取用户详细信息
export const fetchUserProfile = async (): Promise<ApiResponse<UserInfoType>> => {

View File

@@ -3,7 +3,7 @@ import {
fetchUserProfile,
updateUserProfile,
UserInfoType,
} from "@/services/loginService";
} from "@/services/userService";
export interface UserState {
user: UserInfoType | {};