修复登陆问题
This commit is contained in:
@@ -24,11 +24,11 @@ const envConfigs: Record<EnvType, EnvConfig> = {
|
|||||||
// 开发环境
|
// 开发环境
|
||||||
development: {
|
development: {
|
||||||
name: '开发环境',
|
name: '开发环境',
|
||||||
apiBaseURL: 'https://sit.light120.com',
|
// apiBaseURL: 'https://sit.light120.com',
|
||||||
// apiBaseURL: 'http://localhost:9098',
|
apiBaseURL: 'http://localhost:9098',
|
||||||
timeout: 15000,
|
timeout: 15000,
|
||||||
enableLog: true,
|
enableLog: true,
|
||||||
enableMock: true,
|
enableMock: false,
|
||||||
// 客服配置
|
// 客服配置
|
||||||
customerService: {
|
customerService: {
|
||||||
corpId: 'ww51fc969e8b76af82', // 企业ID
|
corpId: 'ww51fc969e8b76af82', // 企业ID
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
z-index: 100;
|
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 {
|
.navbar-content {
|
||||||
height: 56px;
|
height: 56px;
|
||||||
|
|||||||
@@ -120,7 +120,23 @@ class HttpService {
|
|||||||
|
|
||||||
// 业务状态码检查
|
// 业务状态码检查
|
||||||
if (data && typeof data === 'object') {
|
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) {
|
if (showToast) {
|
||||||
this.handleBusinessError(data)
|
this.handleBusinessError(data)
|
||||||
reject(new Error(data.message || '请求失败'))
|
reject(new Error(data.message || '请求失败'))
|
||||||
@@ -131,6 +147,8 @@ class HttpService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resolve(data)
|
resolve(data)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -201,19 +219,6 @@ class HttpService {
|
|||||||
|
|
||||||
let fullUrl = this.buildUrl(url, method === 'GET' ? params : undefined)
|
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}`, {
|
this.log('info', `发起请求: ${method} ${fullUrl}`, {
|
||||||
data: method !== 'GET' ? data : undefined,
|
data: method !== 'GET' ? data : undefined,
|
||||||
params: method === 'GET' ? params : undefined
|
params: method === 'GET' ? params : undefined
|
||||||
|
|||||||
@@ -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) => {
|
export const updateUserPhone = async (payload: ChangePhoneParams) => {
|
||||||
|
|||||||
@@ -574,7 +574,7 @@ export class UserService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从 loginService 移过来的用户相关方法
|
|
||||||
|
|
||||||
// 获取用户详细信息
|
// 获取用户详细信息
|
||||||
export const fetchUserProfile = async (): Promise<ApiResponse<UserInfoType>> => {
|
export const fetchUserProfile = async (): Promise<ApiResponse<UserInfoType>> => {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
fetchUserProfile,
|
fetchUserProfile,
|
||||||
updateUserProfile,
|
updateUserProfile,
|
||||||
UserInfoType,
|
UserInfoType,
|
||||||
} from "@/services/loginService";
|
} from "@/services/userService";
|
||||||
|
|
||||||
export interface UserState {
|
export interface UserState {
|
||||||
user: UserInfoType | {};
|
user: UserInfoType | {};
|
||||||
|
|||||||
Reference in New Issue
Block a user