Browse Source

修复头像上传失败、头像不回显的问题

Sanmu8 1 year ago
parent
commit
52d9d4465b
2 changed files with 22 additions and 2 deletions
  1. 11 1
      src/api/system/user.js
  2. 11 1
      src/views/system/user/profile/userAvatar.vue

+ 11 - 1
src/api/system/user.js

@@ -81,7 +81,7 @@ export function getUserProfile() {
 // 修改用户个人信息
 export function updateUserProfile(data) {
   return request({
-    url: '/system/user/profile',
+    url: '/system/user/profile/edit',
     method: 'post',
     data: data
   })
@@ -133,3 +133,13 @@ export function deptTreeSelect() {
     method: 'get'
   })
 }
+
+
+// 上传文件
+export function upload(data) {
+  return request({
+    url: '/common/upload/',
+    method: 'post',
+    data:data
+  })
+}

+ 11 - 1
src/views/system/user/profile/userAvatar.vue

@@ -55,7 +55,7 @@
 <script>
 import store from "@/store";
 import { VueCropper } from "vue-cropper";
-import { uploadAvatar } from "@/api/system/user";
+import { uploadAvatar,upload } from "@/api/system/user";
 
 export default {
   components: { VueCropper },
@@ -122,6 +122,16 @@ export default {
     // 上传图片
     uploadImg() {
       this.$refs.cropper.getCropBlob(data => {
+        // let formData = new FormData();
+        // formData.append("file", data);
+        // upload(formData).then(response => {
+        //   this.open = false;
+        //   this.options.img = response.url;
+        //   store.commit('SET_AVATAR', this.options.img);
+        //   this.$modal.msgSuccess("修改成功");
+        //   this.visible = false;
+          
+        // });
         let formData = new FormData();
         formData.append("avatarfile", data);
         uploadAvatar(formData).then(response => {