xuqiang 4 лет назад
Родитель
Сommit
7eb8280fe9
1 измененных файлов с 37 добавлено и 18 удалено
  1. 37 18
      src/main/h5/src/views/expert/expertAdd.vue

+ 37 - 18
src/main/h5/src/views/expert/expertAdd.vue

@@ -109,7 +109,6 @@
         :color="$colors.prim"
         block
         round
-        :disabled="!canSubmit"
         >提交</van-button
       >
     </div>
@@ -211,25 +210,20 @@ export default {
       });
   },
   methods: {
-    afterRead(file, fileList, detail) {
+    uploadImg(file, detail) {
       console.log(file);
-      console.log(fileList);
-      this.$toast.loading({
-        message: "加载中...",
-        forbidClick: true
-      });
       this.$http
         .post("/upload/base64", {
           base64: file.content
         })
         .then(res => {
+          console.log(res);
           this.$toast.clear();
           let imgs =
             detail.name === "big"
               ? [...this.form.img]
               : [...this.submitList[detail.name].img];
           imgs.push(res);
-          console.log(detail);
           if (detail.name === "big") {
             this.form.img = imgs;
           } else {
@@ -237,6 +231,20 @@ export default {
           }
         });
     },
+    afterRead(file, fileList, detail) {
+      this.$toast.loading({
+        message: "加载中...",
+        forbidClick: true
+      });
+      if (file instanceof Array) {
+        file.map(v => {
+          // console.log(v);
+          this.uploadImg(v);
+        });
+      } else {
+        this.uploadImg(file);
+      }
+    },
     beforeDelete(file, detail) {
       let submitForm = {};
       if (detail.name === "big") {
@@ -257,18 +265,29 @@ export default {
       }
     },
     beforeRead(file) {
-      console.log(file);
-      return new Promise(resolve => {
-        // compressorjs 默认开启 checkOrientation 选项
-        // 会将图片修正为正确方向
-        new Compressor(file, {
-          success: resolve,
-          error(err) {
-            console.log(err.message);
-          }
+      if (file instanceof Array) {
+        //判断是否是数组
+        file.forEach(v => {
+          console.log(v);
         });
-      });
+      } else {
+        console.log("单个图片");
+      }
+      return true;
     },
+    // beforeRead(file) {
+    //   console.log(file);
+    //   return new Promise(resolve => {
+    //     // compressorjs 默认开启 checkOrientation 选项
+    //     // 会将图片修正为正确方向
+    //     new Compressor(file, {
+    //       success: resolve,
+    //       error(err) {
+    //         console.log(err.message);
+    //       }
+    //     });
+    //   });
+    // },
     save() {
       let form = { ...this.form };
       this.$toast.loading({