Browse Source

fix: 修复文件下载

梦辉 5 months ago
parent
commit
f2df7fc321

+ 3 - 4
src/subPages/pages/commitment/components/commitmentConfirmForm/index.vue

@@ -71,14 +71,13 @@ export default {
       return true;
     },
     afterRead(file) {
-      const formData = new FormData()
       uploadFile({
         uuid: uuidv4(),
-        file: formData
+        file: file
       }).then(res => {
         if (res.code === 0) {
-          this.formStates.fileList.push({
-            uuid: res.data,
+              this.formStates.fileList.push({
+                uuid: res.data,
             url: URL.createObjectURL(file.file)
           })
         }

+ 3 - 5
src/utils/fetch/requestHandler.js

@@ -31,9 +31,7 @@ export const handleRequest = (reqConfig) => {
             uni.uploadFile({
                 url: reqConfig.url,
                 formData: uploadParams.data,
-                header: {
-                    Token: uploadParams.header.Token
-                },
+                file: reqConfig.data.file.file,
                 success: function (res) {
                     resolve(JSON.parse(res.data));
                 },
@@ -51,8 +49,8 @@ export const handleRequest = (reqConfig) => {
             const url = reqConfig.url + '?' + Object.keys(reqConfig.data).map(key => key + '=' + reqConfig.data[key]).join('&');
             uni.downloadFile({
                 url,
-                header:{
-                  ...reqConfig.header
+                header: {
+                    ...reqConfig.header
                 },
                 success: function (res) {
                     resolve(res.tempFilePath);