|
|
@@ -93,12 +93,19 @@ const _sfc_main = {
|
|
|
common_vendor.index.showLoading({ title: "保存中..." });
|
|
|
try {
|
|
|
let uploadedAvatarUrl = currentAvatarPath;
|
|
|
- if (currentAvatarPath !== originalAvatar.value && !avatarUrl.value.startsWith("/static/") && !avatarUrl.value.startsWith("http")) {
|
|
|
+ const isTempPath = avatarUrl.value.startsWith("http://tmp/") || avatarUrl.value.startsWith("wxfile://") || avatarUrl.value.includes("/tmp/wx");
|
|
|
+ const needUpload = currentAvatarPath !== originalAvatar.value && !avatarUrl.value.startsWith("/static/") && (!avatarUrl.value.startsWith("http") || isTempPath);
|
|
|
+ if (needUpload) {
|
|
|
try {
|
|
|
+ console.log("[编辑资料] 开始上传头像:", avatarUrl.value);
|
|
|
uploadedAvatarUrl = await uploadAvatar(avatarUrl.value);
|
|
|
+ console.log("[编辑资料] 头像上传成功:", uploadedAvatarUrl);
|
|
|
} catch (e) {
|
|
|
- console.warn("头像上传失败,使用默认头像:", e.message);
|
|
|
- uploadedAvatarUrl = "/static/images/head.png";
|
|
|
+ console.error("[编辑资料] 头像上传失败:", e.message);
|
|
|
+ common_vendor.index.hideLoading();
|
|
|
+ common_vendor.index.showToast({ title: "头像上传失败", icon: "none" });
|
|
|
+ saving.value = false;
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
await utils_api.updateUserProfile({
|
|
|
@@ -112,7 +119,8 @@ const _sfc_main = {
|
|
|
common_vendor.index.hideLoading();
|
|
|
common_vendor.index.showToast({ title: "保存成功", icon: "success" });
|
|
|
setTimeout(() => {
|
|
|
- common_vendor.index.navigateBack();
|
|
|
+ const pages = getCurrentPages();
|
|
|
+ pages.length > 1 ? common_vendor.index.navigateBack() : common_vendor.index.switchTab({ url: "/pages/mine/mine" });
|
|
|
}, 1500);
|
|
|
} catch (error) {
|
|
|
console.error("保存失败:", error);
|