feat: ✨ 个人中心手机号和邮箱绑定
This commit is contained in:
@@ -146,9 +146,9 @@ class UserAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 修改个人中心用户信息 */
|
/** 修改个人中心用户信息 */
|
||||||
static updateProfile(id: number, data: UserProfileForm) {
|
static updateProfile(data: UserProfileForm) {
|
||||||
return request({
|
return request({
|
||||||
url: `${USER_BASE_URL}/${id}/profile`,
|
url: `${USER_BASE_URL}/profile`,
|
||||||
method: "put",
|
method: "put",
|
||||||
data: data,
|
data: data,
|
||||||
});
|
});
|
||||||
@@ -176,6 +176,24 @@ class UserAPI {
|
|||||||
params: { contact: contact, contactType: contactType },
|
params: { contact: contact, contactType: contactType },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 绑定个人中心用户手机 */
|
||||||
|
static bindMobile(data: MobileBindingForm) {
|
||||||
|
return request({
|
||||||
|
url: `${USER_BASE_URL}/mobile`,
|
||||||
|
method: "put",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 丙丁个人中心用户邮箱 */
|
||||||
|
static bindEmail(data: EmailBindingForm) {
|
||||||
|
return request({
|
||||||
|
url: `${USER_BASE_URL}/email`,
|
||||||
|
method: "put",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UserAPI;
|
export default UserAPI;
|
||||||
@@ -335,17 +353,17 @@ export interface PasswordChangeForm {
|
|||||||
confirmPassword?: string;
|
confirmPassword?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 手机绑定表单 */
|
/** 修改手机表单 */
|
||||||
export interface MobileBindingForm {
|
export interface MobileBindingForm {
|
||||||
/** 新手机号 */
|
/** 手机号 */
|
||||||
mobile?: string;
|
mobile?: string;
|
||||||
/** 验证码 */
|
/** 验证码 */
|
||||||
code?: string;
|
code?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 邮箱绑定表单 */
|
/** 修改邮箱表单 */
|
||||||
export interface EmailBindingForm {
|
export interface EmailBindingForm {
|
||||||
/** 新邮箱 */
|
/** 邮箱 */
|
||||||
email?: string;
|
email?: string;
|
||||||
/** 验证码 */
|
/** 验证码 */
|
||||||
code?: string;
|
code?: string;
|
||||||
|
|||||||
@@ -451,7 +451,7 @@ const handleSendVerificationCode = async (contactType: string) => {
|
|||||||
*/
|
*/
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (dialog.type === DialogType.ACCOUNT) {
|
if (dialog.type === DialogType.ACCOUNT) {
|
||||||
UserAPI.updateProfile(userProfileForm.id, userProfileForm).then(() => {
|
UserAPI.updateProfile(userProfileForm).then(() => {
|
||||||
ElMessage.success("账号资料修改成功");
|
ElMessage.success("账号资料修改成功");
|
||||||
dialog.visible = false;
|
dialog.visible = false;
|
||||||
loadUserProfile();
|
loadUserProfile();
|
||||||
@@ -465,10 +465,18 @@ const handleSubmit = async () => {
|
|||||||
ElMessage.success("密码修改成功");
|
ElMessage.success("密码修改成功");
|
||||||
dialog.visible = false;
|
dialog.visible = false;
|
||||||
});
|
});
|
||||||
} else if (dialog.type === "mobile") {
|
} else if (dialog.type === DialogType.MOBILE) {
|
||||||
//await UserAPI.bindMobile(mobileBindingForm.value);
|
UserAPI.bindMobile(mobileBindingForm).then(() => {
|
||||||
} else if (dialog.type === "email") {
|
ElMessage.success("手机号绑定成功");
|
||||||
//await UserAPI.bindEmail(emailBindingForm.value);
|
dialog.visible = false;
|
||||||
|
loadUserProfile();
|
||||||
|
});
|
||||||
|
} else if (dialog.type === DialogType.EMAIL) {
|
||||||
|
UserAPI.bindEmail(emailBindingForm).then(() => {
|
||||||
|
ElMessage.success("邮箱绑定成功");
|
||||||
|
dialog.visible = false;
|
||||||
|
loadUserProfile();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -488,7 +496,7 @@ const handleFileChange = async (event: Event) => {
|
|||||||
// 更新用户头像
|
// 更新用户头像
|
||||||
userProfile.value.avatar = data.url;
|
userProfile.value.avatar = data.url;
|
||||||
// 更新用户信息
|
// 更新用户信息
|
||||||
await UserAPI.updateProfile(userProfile.value.id, {
|
await UserAPI.updateProfile(userProfile.value.id as number, {
|
||||||
avatar: data.url,
|
avatar: data.url,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user