修改上传图片安全验证问题

This commit is contained in:
张成
2026-02-14 12:59:21 +08:00
parent 8688b6b82d
commit 64f0267457
54 changed files with 239 additions and 240 deletions

View File

@@ -351,7 +351,7 @@ export class UserService {
throw new Error(response.message || "获取用户信息失败");
}
} catch (error) {
console.error("获取用户信息失败:", error);
console.warn("获取用户信息失败:", error);
// 返回默认用户信息
return {} as UserInfo;
}
@@ -392,7 +392,7 @@ export class UserService {
throw new Error(response.message || "更新用户信息失败");
}
} catch (error) {
console.error("更新用户信息失败:", error);
console.warn("更新用户信息失败:", error);
throw error;
}
}
@@ -417,7 +417,7 @@ export class UserService {
throw new Error(response.message || "获取主办球局失败");
}
} catch (error) {
console.error("获取主办球局失败:", error);
console.warn("获取主办球局失败:", error);
// 返回符合ListContainer data格式的模拟数据
return [];
}
@@ -443,7 +443,7 @@ export class UserService {
throw new Error(response.message || "获取参与球局失败");
}
} catch (error) {
console.error("获取参与球局失败:", error);
console.warn("获取参与球局失败:", error);
// 返回符合ListContainer data格式的模拟数据
return [];
}
@@ -485,7 +485,7 @@ export class UserService {
throw new Error(response.message || "操作失败");
}
} catch (error) {
console.error("关注操作失败:", error);
console.warn("关注操作失败:", error);
throw error;
}
}
@@ -543,7 +543,7 @@ export class UserService {
throw new Error(response.message || "更新用户信息失败");
}
} catch (error) {
console.error("保存用户信息失败:", error);
console.warn("保存用户信息失败:", error);
throw error;
}
}
@@ -573,26 +573,16 @@ export class UserService {
throw new Error(response.message || "获取用户动态失败");
}
} catch (error) {
console.error("获取用户动态失败:", error);
console.warn("获取用户动态失败:", error);
return [];
}
}
// 上传头像
// 上传头像:仅在上传成功且 save 成功时返回 ossPath失败则抛出由调用方处理避免误调 user/update
static async upload_avatar(file_path: string): Promise<string> {
try {
// 先上传文件到服务器
const result = await uploadFiles.upload_oss_img(file_path);
await this.save_user_info({ avatar: result.ossPath });
// 使用新的响应格式中的file_url字段
return result.ossPath;
} catch (error) {
console.error("头像上传失败:", error);
// 如果上传失败,返回默认头像
return require("../static/userInfo/default_avatar.svg");
}
const result = await uploadFiles.upload_oss_img(file_path);
await this.save_user_info({ avatar: result.ossPath });
return result.ossPath;
}
// 解析用户手机号
@@ -612,7 +602,7 @@ export class UserService {
throw new Error(response.message || "获取手机号失败");
}
} catch (error) {
console.error("获取手机号失败:", error);
console.warn("获取手机号失败:", error);
return "";
}
}
@@ -628,7 +618,7 @@ export class UserService {
throw new Error(message || "获取职业树失败");
}
} catch (error) {
console.error("获取职业树失败:", error);
console.warn("获取职业树失败:", error);
return [];
}
}
@@ -644,7 +634,7 @@ export class UserService {
throw new Error(message || "获取城市树失败");
}
} catch (error) {
console.error("获取职业树失败:", error);
console.warn("获取职业树失败:", error);
return [];
}
}
@@ -665,7 +655,7 @@ export class UserService {
throw new Error(message || "注销账户失败");
}
} catch (error) {
console.error("注销账户失败:", error);
console.warn("注销账户失败:", error);
}
}
}
@@ -680,7 +670,7 @@ export const fetchUserProfile = async (): Promise<
const response = await httpService.post("user/detail");
return response;
} catch (error) {
console.error("获取用户信息失败:", error);
console.warn("获取用户信息失败:", error);
throw error;
}
};
@@ -695,7 +685,7 @@ export const checkNicknameChangeStatus = async (): Promise<
);
return response;
} catch (error) {
console.error("获取昵称修改状态失败:", error);
console.warn("获取昵称修改状态失败:", error);
throw error;
}
};
@@ -707,7 +697,7 @@ export const updateNickname = async (nickname: string) => {
});
return response;
} catch (error) {
console.error("昵称修改失败:", error);
console.warn("昵称修改失败:", error);
throw error;
}
};
@@ -718,7 +708,7 @@ export const updateUserProfile = async (payload: Partial<UserInfoType>) => {
const response = await httpService.post("/user/update", payload);
return response;
} catch (error) {
console.error("更新用户信息失败:", error);
console.warn("更新用户信息失败:", error);
throw error;
}
};
@@ -737,7 +727,7 @@ export const updateUserLocation = async (
});
return response;
} catch (error) {
console.error("更新用户坐标位置失败:", error);
console.warn("更新用户坐标位置失败:", error);
throw error;
}
};
@@ -774,13 +764,13 @@ export const handleCustomerService = async (): Promise<void> => {
console.log("打开客服成功:", res);
},
fail: (error) => {
console.error("打开客服失败:", error);
console.warn("打开客服失败:", error);
// 如果官方客服不可用,显示备用联系方式
showCustomerServiceFallback(customerService);
},
});
} catch (error) {
console.error("客服功能异常:", error);
console.warn("客服功能异常:", error);
// 备用方案:显示联系信息
showCustomerServiceFallback();
}
@@ -810,7 +800,7 @@ const showCustomerServiceFallback = (customerInfo?: any) => {
phoneNumber: customerInfo.phoneNumber,
});
} catch (error) {
console.error("拨打电话失败:", error);
console.warn("拨打电话失败:", error);
Taro.showToast({
title: "拨打电话失败",
icon: "none",
@@ -827,7 +817,7 @@ const showCustomerServiceFallback = (customerInfo?: any) => {
icon: "success",
});
} catch (error) {
console.error("复制邮箱失败:", error);
console.warn("复制邮箱失败:", error);
Taro.showToast({
title: "复制失败",
icon: "none",