From 4ecae531610d395b5fb948eee6051602b81d479d Mon Sep 17 00:00:00 2001 From: ray <1490493387@qq.com> Date: Wed, 14 Aug 2024 18:32:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20:sparkles:=20=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E4=BF=AE=E6=94=B9=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/user.ts | 21 ++++++- src/views/demo/curd/index.vue | 2 +- src/views/profile/index.vue | 98 +++++++++++++++++++++++++-------- src/views/system/user/index.vue | 2 +- 4 files changed, 97 insertions(+), 26 deletions(-) diff --git a/src/api/user.ts b/src/api/user.ts index 8b00d380..fd307dc0 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -74,10 +74,10 @@ class UserAPI { * @param id 用户ID * @param password 新密码 */ - static updatePassword(id: number, password: string) { + static resetPassword(id: number, password: string) { return request({ url: `${USER_BASE_URL}/${id}/password`, - method: "patch", + method: "put", params: { password: password }, }); } @@ -153,6 +153,15 @@ class UserAPI { data: data, }); } + + /** 修改个人中心用户密码 */ + static changePassword(data: PasswordChangeForm) { + return request({ + url: `${USER_BASE_URL}/password`, + method: "put", + data: data, + }); + } } export default UserAPI; @@ -292,3 +301,11 @@ export interface UserProfileForm { /** 邮箱 */ email?: string; } + +/** 修改密码表单 */ +export interface PasswordChangeForm { + /** 原密码 */ + oldPassword?: string; + /** 新密码 */ + newPassword?: string; +} diff --git a/src/views/demo/curd/index.vue b/src/views/demo/curd/index.vue index e648cbc4..6877cd03 100644 --- a/src/views/demo/curd/index.vue +++ b/src/views/demo/curd/index.vue @@ -158,7 +158,7 @@ function handleOperatClick(data: IOperatData) { ElMessage.warning("密码至少需要6位字符,请重新输入"); return false; } - UserAPI.updatePassword(data.row.id, value).then(() => { + UserAPI.resetPassword(data.row.id, value).then(() => { ElMessage.success("密码重置成功,新密码是:" + value); }); }); diff --git a/src/views/profile/index.vue b/src/views/profile/index.vue index a85dbf1f..c954c206 100644 --- a/src/views/profile/index.vue +++ b/src/views/profile/index.vue @@ -1,21 +1,62 @@