Ver Fonte

头像更改及密码更改问题,剔除驳回问题更改

qinhb há 6 meses atrás
pai
commit
bb09a3f619
2 ficheiros alterados com 19 adições e 4 exclusões
  1. 15 0
      src/api/system/user/index.ts
  2. 4 4
      src/views/login/userCenter.vue

+ 15 - 0
src/api/system/user/index.ts

@@ -81,6 +81,21 @@ export function updateUser(id: number, data: any) {
   });
 }
 
+export function updateBaseInfo(id: number, data: any) {
+  return request({
+    url: "/api/v1/sys/user/updateBaseInfo",
+    method: "post",
+    data: { id: id, ...data },
+  });
+}
+export function updateHeadImg(id: number, data: any) {
+  return request({
+    url: "/api/v1/sys/user/updateHeadImg",
+    method: "post",
+    data: { id: id, ...data },
+  });
+}
+
 /**
  * 修改用户密码
  *

+ 4 - 4
src/views/login/userCenter.vue

@@ -57,7 +57,7 @@
 </template>
 
 <script setup lang="ts">
-import { getUserDetailApi, updateUser } from "@/api/system/user/index";
+import { getUserDetailApi,updateHeadImg,updateBaseInfo} from "@/api/system/user/index";
 import { useUserStoreHook } from "@/store/modules/user";
 import SingleUpload from "@/components/Upload/SingleUpload.vue";
 
@@ -78,7 +78,7 @@ const show = () => {
 defineExpose({ show });
 
 const uploadHeadFinish = () => {
-  updateUser(userStore.user.userId, { avatar: headUrl.value }).then(() => {
+  updateHeadImg(userStore.user.userId, { avatar: headUrl.value }).then(() => {
     ElMessage.success("头像上传成功");
   });
 };
@@ -109,8 +109,8 @@ const rules = reactive({
 const submitForm = () => {
   passwordFormRef.value.validate((valid: boolean) => {
     if (valid) {
-      updateUser(userStore.user.userId, {
-        password: passwordForm.value.password,
+      updateBaseInfo(userStore.user.userId, {
+        password: passwordForm.value.password,oldPassword: passwordForm.value.oldPassword
       }).then(() => {
         ElMessage.success("密码修改成功");
         visible.value = false;