xiangyang vor 1 Monat
Ursprung
Commit
624ee0d6d9
2 geänderte Dateien mit 14 neuen und 8 gelöschten Zeilen
  1. 1 1
      admin/src/service/cdnapi.js
  2. 13 7
      admin/src/views/RoleManagement.vue

+ 1 - 1
admin/src/service/cdnapi.js

@@ -6,7 +6,7 @@ const cdnService = axios.create({
     withCredentials: false, // 跨域请求时是否需要使用凭证
     headers: {
         Accept: 'application/json',
-        'Content-Type': 'application/json',
+        'Content-Type': 'multipart/form-data;',
         'accessToken': 'rcOBHJ0Hb8h5xgM/CWtNd8RBhA6WS4OPyJcxrxk4xPZtzeh5PtRXVDA7Um0NZA6NQmnbnZgWB0nNPb8iCrneQj4badFveWLrFq4LrySto3pIo/Zg1dJubbwmu3Vr1LCbSYyVIFrrgt9PXiA85kb9g38FSG3KTSi3AEY/UgjLNLBtH2+91YXKEy2KRZV3v75f',
     },
     // 超时

+ 13 - 7
admin/src/views/RoleManagement.vue

@@ -290,16 +290,22 @@ export default {
     };
   },
   methods: {
-    handlePhotoUpload(file) {
+    async handlePhotoUpload(file) {
       // cdnService.uploadVoice(file);
-      this.file = file;
+      // this.file = file;
       let formData = {
-        file: this.file.raw
+        file: file.raw
       }
-      let response = cdnService.upload(formData);
-      console.log(response.data);
-      // this.photoFileName = file.name;
-      // todo 实际项目中应上传文件到服务器
+
+      cdnService.upload(formData).then(res => {
+        if (res.data.code === 0) {
+          this.photo = res.data.data;
+        }else {
+          this.photo = '';
+        }
+        console.log(res.data.data);
+        console.log(this.photo);
+      });
     },
     handleVoiceUpload(file) {