scorpio 2 éve
szülő
commit
123a97e486
2 módosított fájl, 24 hozzáadás és 5 törlés
  1. 7 0
      src/api/dash/index.js
  2. 17 5
      src/views/dash/compoents/profile.vue

+ 7 - 0
src/api/dash/index.js

@@ -36,5 +36,12 @@ export default {
    */
   mpList() {
     return fetch('/blade-project-manage-v2/index/v2/v2/mp-list')
+  },
+  /**
+   * 头像更新
+   * @returns {Promise | Promise<unknown>}
+   */
+  updateAvatar() {
+    return fetch('/blade-user/submit')
   }
 }

+ 17 - 5
src/views/dash/compoents/profile.vue

@@ -99,8 +99,8 @@
         </div>
         <div class="mt-20 full-width flex flex-justify-end">
           <el-button type="primary" plain @click="show = false"
-            >取 消</el-button
-          >
+            >取 消
+          </el-button>
           <el-button type="primary" @click="uploadImage">确 定</el-button>
         </div>
       </div>
@@ -114,9 +114,10 @@ import { Cropper } from 'vue-advanced-cropper'
 import 'vue-advanced-cropper/dist/style.css'
 import api from '@/api/index.js'
 import website from '@/config/website.js'
-import { getToken } from '@/utils/auth.js'
+import { getToken, removeToken } from '@/utils/auth.js'
 import { Base64 } from 'js-base64'
 import uploadOffice from '@/components/upload-office/index.vue'
+import router from '@/router/index.js'
 
 export default {
   components: {
@@ -233,11 +234,22 @@ export default {
             method: 'POST',
             headers: this.headers,
             body: form
-          }).then(res => {
-            console.log(res)
+          }).then(response => {
+            const { status, data = {} } = response
+            if (status >= 200 && status <= 401) {
+              this.updateAvatar(data.data.filePath)
+            }
           })
         }, 'image/png')
       }
+    },
+    updateAvatar(avatar) {
+      const data = { id: this.user.info.userId, avatar }
+      this.$api.dash.updateAvatar(data).then(res => {
+        if (res.code === 200) {
+          console.log(res)
+        }
+      })
     }
   }
 }