Przeglądaj źródła

恢复图片上传前压缩

lihongxiao 2 lat temu
rodzic
commit
5e0b8674a6
1 zmienionych plików z 202 dodań i 202 usunięć
  1. 202 202
      src/views/Letter/Letter.vue

+ 202 - 202
src/views/Letter/Letter.vue

@@ -5981,53 +5981,53 @@ export default {
        return false
       }
       this[imgurl].push(file)
-      let name=file.raw.name
-      var image = new Image();
-      image.src = window.URL.createObjectURL(file.raw);
-      that.carfrontImg =  image.src
-      image.onload = function(){
-        let aaa= that.base64ToFile(that.compress(image, 500, 400, 0.7),name)
-      const params = new FormData()
-       params.append("multipartFile", aaa);
-       params.append("type", "image");
-
-      that.$api.letter.uploadFile(params).then(res => {
+//       let name=file.raw.name
+//       var image = new Image();
+//       image.src = window.URL.createObjectURL(file.raw);
+//       that.carfrontImg =  image.src
+//       image.onload = function(){
+//         let aaa= that.base64ToFile(that.compress(image, 500, 400, 0.7),name)
+//       const params = new FormData()
+//        params.append("multipartFile", aaa);
+//        params.append("type", "image");
+
+//       that.$api.letter.uploadFile(params).then(res => {
+//         if (res.code == "200") {
+//           if (that[imageIdList].some(v => v.imageType == type)) {
+//             that[imageIdList].map(val => {
+//               if (val.imageType == type) {
+//                 val.imageId = res.data.id;
+//               }
+//             })
+//           } else {
+//             that[imageIdList].push({
+//               imageId: res.data.id,
+//               imageType: type,
+//             })
+//           }
+//         }
+//       });
+//     }
+      var file = file.raw;
+      const params = new FormData(); // 声明formData数据类型
+      params.append("multipartFile", file);
+      params.append("type", "image");
+      this.$api.letter.uploadFile(params).then(res => {
         if (res.code == "200") {
-          if (that[imageIdList].some(v => v.imageType == type)) {
-            that[imageIdList].map(val => {
+          if (this[imageIdList].some(v => v.imageType == type)) {
+            this[imageIdList].map(val => {
               if (val.imageType == type) {
                 val.imageId = res.data.id;
               }
             })
           } else {
-            that[imageIdList].push({
+            this[imageIdList].push({
               imageId: res.data.id,
               imageType: type,
             })
           }
         }
       });
-    }
-      // var file = file.raw;
-      // const params = new FormData(); // 声明formData数据类型
-      // params.append("multipartFile", file);
-      // params.append("type", "image");
-      // this.$api.letter.uploadFile(params).then(res => {
-      //   if (res.code == "200") {
-      //     if (this[imageIdList].some(v => v.imageType == type)) {
-      //       this[imageIdList].map(val => {
-      //         if (val.imageType == type) {
-      //           val.imageId = res.data.id;
-      //         }
-      //       })
-      //     } else {
-      //       this[imageIdList].push({
-      //         imageId: res.data.id,
-      //         imageType: type,
-      //       })
-      //     }
-      //   }
-      // });
 
     },
     handleRemove1(file, imageIdList, imgList) {
@@ -6092,62 +6092,62 @@ export default {
        this.$message.error('上传图片只能是 JPG、PNG 格式!')
        return false
       }
-      let name=file.raw.name
-      var image = new Image();
-      image.src = window.URL.createObjectURL(file.raw);
-      that.carfrontImg =  image.src
-      image.onload = function(){
-        let aaa= that.base64ToFile(that.compress(image, 500, 400, 0.7),name)
-
-      that.carfrontImg = image.src;
+//       let name=file.raw.name
+//       var image = new Image();
+//       image.src = window.URL.createObjectURL(file.raw);
+//       that.carfrontImg =  image.src
+//       image.onload = function(){
+//         let aaa= that.base64ToFile(that.compress(image, 500, 400, 0.7),name)
+
+//       that.carfrontImg = image.src;
+//       const params = new FormData(); // 声明formData数据类型
+//       params.append("multipartFile", aaa);
+//       params.append("type", "image");
+//       that.$api.letter.uploadFile(params).then(res => {
+//         if (res.code == "200") {
+//           that.CarFrontFile = aaa;//文件流
+//           if (that.imageList1.some(v => v.imageType == 'C01')) {
+//             that.imageList1.map(val => {
+//               if (val.imageType == 'C01') {
+//                 val.imageId = res.data.id;
+//               }
+//             })
+//           } else {
+//             that.imageList1.push({
+//               imageId: res.data.id,
+//               imageType: "C01",
+//             })
+//           }
+//         } else {
+//           that.$message({ message: res.msg, type: "warning" });
+//         }
+//       });
+//     }
+      var file = file.raw;
+      let files = window.URL.createObjectURL(file); //转临时路径
+      this.carfrontImg = files;
       const params = new FormData(); // 声明formData数据类型
-      params.append("multipartFile", aaa);
+      params.append("multipartFile", file);
       params.append("type", "image");
-      that.$api.letter.uploadFile(params).then(res => {
+      this.$api.letter.uploadFile(params).then(res => {
         if (res.code == "200") {
-          that.CarFrontFile = aaa;//文件流
-          if (that.imageList1.some(v => v.imageType == 'C01')) {
-            that.imageList1.map(val => {
+          this.CarFrontFile = file;//文件流
+          if (this.imageList1.some(v => v.imageType == 'C01')) {
+            this.imageList1.map(val => {
               if (val.imageType == 'C01') {
                 val.imageId = res.data.id;
               }
             })
           } else {
-            that.imageList1.push({
+            this.imageList1.push({
               imageId: res.data.id,
               imageType: "C01",
             })
           }
         } else {
-          that.$message({ message: res.msg, type: "warning" });
+          this.$message({ message: res.msg, type: "warning" });
         }
       });
-    }
-      // var file = file.raw;
-      // let files = window.URL.createObjectURL(file); //转临时路径
-      // this.carfrontImg = files;
-      // const params = new FormData(); // 声明formData数据类型
-      // params.append("multipartFile", file);
-      // params.append("type", "image");
-      // this.$api.letter.uploadFile(params).then(res => {
-      //   if (res.code == "200") {
-      //     this.CarFrontFile = file;//文件流
-      //     if (this.imageList1.some(v => v.imageType == 'C01')) {
-      //       this.imageList1.map(val => {
-      //         if (val.imageType == 'C01') {
-      //           val.imageId = res.data.id;
-      //         }
-      //       })
-      //     } else {
-      //       this.imageList1.push({
-      //         imageId: res.data.id,
-      //         imageType: "C01",
-      //       })
-      //     }
-      //   } else {
-      //     this.$message({ message: res.msg, type: "warning" });
-      //   }
-      // });
     },
     carbackChange(file) {
       let that=this
@@ -6161,61 +6161,61 @@ export default {
        this.$message.error('上传图片只能是 JPG、PNG 格式!')
        return false
       }
-      let name=file.raw.name
-      var image = new Image();
-      image.src = window.URL.createObjectURL(file.raw);
-      image.onload = function(){
-        let aaa= that.base64ToFile(that.compress(image, 500, 400, 0.7),name)
-      that.carbackImg = image.src;
+//       let name=file.raw.name
+//       var image = new Image();
+//       image.src = window.URL.createObjectURL(file.raw);
+//       image.onload = function(){
+//         let aaa= that.base64ToFile(that.compress(image, 500, 400, 0.7),name)
+//       that.carbackImg = image.src;
+//       const params = new FormData(); // 声明formData数据类型
+//       params.append("multipartFile", aaa);
+//       params.append("type", "image");
+//       that.$api.letter.uploadFile(params).then(res => {
+//         if (res.code == "200") {
+//           that.CarBackFile = aaa;//文件流
+//           if (that.imageList1.some(v => v.imageType == 'D01')) {
+//             that.imageList1.map(val => {
+//               if (val.imageType == 'D01') {
+//                 val.imageId = res.data.id;
+//               }
+//             })
+//           } else {
+//             that.imageList1.push({
+//               imageId: res.data.id,
+//               imageType: "D01",
+//             })
+//           }
+//         } else {
+//           that.$message({ message: res.msg, type: "warning" });
+//         }
+//       });
+//     }
+      //选择行驶证反面
+      var file = file.raw;
+      let files = window.URL.createObjectURL(file); //转临时路径
+      this.carbackImg = files;
       const params = new FormData(); // 声明formData数据类型
-      params.append("multipartFile", aaa);
+      params.append("multipartFile", file);
       params.append("type", "image");
-      that.$api.letter.uploadFile(params).then(res => {
+      this.$api.letter.uploadFile(params).then(res => {
         if (res.code == "200") {
-          that.CarBackFile = aaa;//文件流
-          if (that.imageList1.some(v => v.imageType == 'D01')) {
-            that.imageList1.map(val => {
+          this.CarBackFile = file;
+          if (this.imageList1.some(v => v.imageType == 'D01')) {
+            this.imageList1.map(val => {
               if (val.imageType == 'D01') {
                 val.imageId = res.data.id;
               }
             })
           } else {
-            that.imageList1.push({
+            this.imageList1.push({
               imageId: res.data.id,
               imageType: "D01",
             })
           }
         } else {
-          that.$message({ message: res.msg, type: "warning" });
+          this.$message({ message: res.msg, type: "warning" });
         }
       });
-    }
-      //选择行驶证反面
-      // var file = file.raw;
-      // let files = window.URL.createObjectURL(file); //转临时路径
-      // this.carbackImg = files;
-      // const params = new FormData(); // 声明formData数据类型
-      // params.append("multipartFile", file);
-      // params.append("type", "image");
-      // this.$api.letter.uploadFile(params).then(res => {
-      //   if (res.code == "200") {
-      //     this.CarBackFile = file;
-      //     if (this.imageList1.some(v => v.imageType == 'D01')) {
-      //       this.imageList1.map(val => {
-      //         if (val.imageType == 'D01') {
-      //           val.imageId = res.data.id;
-      //         }
-      //       })
-      //     } else {
-      //       this.imageList1.push({
-      //         imageId: res.data.id,
-      //         imageType: "D01",
-      //       })
-      //     }
-      //   } else {
-      //     this.$message({ message: res.msg, type: "warning" });
-      //   }
-      // });
     },
     userfrontChange(file) {
       let that =this
@@ -6229,64 +6229,64 @@ export default {
        this.$message.error('上传图片只能是 JPG、PNG 格式!')
        return false
       }
-      let name=file.raw.name
-      var image = new Image();
-      image.src = window.URL.createObjectURL(file.raw);
-      image.onload = function(){
-        let aaa= that.base64ToFile(that.compress(image, 500, 400, 0.7),name)
-      that.userfrontImg = image.src;
+//       let name=file.raw.name
+//       var image = new Image();
+//       image.src = window.URL.createObjectURL(file.raw);
+//       image.onload = function(){
+//         let aaa= that.base64ToFile(that.compress(image, 500, 400, 0.7),name)
+//       that.userfrontImg = image.src;
+//       const params = new FormData(); // 声明formData数据类型
+//       params.append("multipartFile", aaa);
+//       params.append("type", "image");
+//       that.$api.letter.uploadFile(params).then(res => {
+//         if (res.code == "200") {
+//           let type = 'C0' + that.userIndex;
+//           if (that['imageList' + that.userIndex].some(v => v.imageType == type)) {
+//             that['imageList' + that.userIndex].map(val => {
+//               if (val.imageType == type) {
+//                 val.imageId = res.data.id;
+//               }
+//             })
+//           } else {
+//             that['imageList' + that.userIndex].push({
+//               imageId: res.data.id,
+//               imageType: type,
+//             })
+//           }
+//           that[type + 'File'] = aaa;
+//         } else {
+//           that.$message({ message: res.msg, type: "warning" });
+//         }
+//       });
+//     }
+      //选择身份证正面
+      var file = file.raw;
+      let files = window.URL.createObjectURL(file); //转链接
+      this.userfrontImg = files;
       const params = new FormData(); // 声明formData数据类型
-      params.append("multipartFile", aaa);
+      params.append("multipartFile", file);
       params.append("type", "image");
-      that.$api.letter.uploadFile(params).then(res => {
+      this.$api.letter.uploadFile(params).then(res => {
         if (res.code == "200") {
-          let type = 'C0' + that.userIndex;
-          if (that['imageList' + that.userIndex].some(v => v.imageType == type)) {
-            that['imageList' + that.userIndex].map(val => {
+          let type = 'C0' + this.userIndex;
+          if (this['imageList' + this.userIndex].some(v => v.imageType == type)) {
+            this['imageList' + this.userIndex].map(val => {
               if (val.imageType == type) {
                 val.imageId = res.data.id;
               }
             })
           } else {
-            that['imageList' + that.userIndex].push({
+            this['imageList' + this.userIndex].push({
               imageId: res.data.id,
               imageType: type,
             })
           }
-          that[type + 'File'] = aaa;
+          this[type + 'File'] = file;
+
         } else {
-          that.$message({ message: res.msg, type: "warning" });
+          this.$message({ message: res.msg, type: "warning" });
         }
       });
-    }
-      //选择身份证正面
-      // var file = file.raw;
-      // let files = window.URL.createObjectURL(file); //转链接
-      // this.userfrontImg = files;
-      // const params = new FormData(); // 声明formData数据类型
-      // params.append("multipartFile", file);
-      // params.append("type", "image");
-      // this.$api.letter.uploadFile(params).then(res => {
-      //   if (res.code == "200") {
-      //     let type = 'C0' + this.userIndex;
-      //     if (this['imageList' + this.userIndex].some(v => v.imageType == type)) {
-      //       this['imageList' + this.userIndex].map(val => {
-      //         if (val.imageType == type) {
-      //           val.imageId = res.data.id;
-      //         }
-      //       })
-      //     } else {
-      //       this['imageList' + this.userIndex].push({
-      //         imageId: res.data.id,
-      //         imageType: type,
-      //       })
-      //     }
-      //     this[type + 'File'] = file;
-
-      //   } else {
-      //     this.$message({ message: res.msg, type: "warning" });
-      //   }
-      // });
     },
     userbackChange(file) {
       let that =this
@@ -6300,64 +6300,64 @@ export default {
        this.$message.error('上传图片只能是 JPG、PNG 格式!')
        return false
       }
-      let name=file.raw.name
-      var image = new Image();
-      image.src = window.URL.createObjectURL(file.raw);
-      image.onload = function(){
-        let aaa= that.base64ToFile(that.compress(image, 500, 400, 0.7),name)
-      that.userbackImg = image.src;
+//       let name=file.raw.name
+//       var image = new Image();
+//       image.src = window.URL.createObjectURL(file.raw);
+//       image.onload = function(){
+//         let aaa= that.base64ToFile(that.compress(image, 500, 400, 0.7),name)
+//       that.userbackImg = image.src;
+//       const params = new FormData(); // 声明formData数据类型
+//       params.append("multipartFile", aaa);
+//       params.append("type", "image");
+//       that.$api.letter.uploadFile(params).then(res => {
+//         if (res.code == "200") {
+//           let type = 'D0' + that.userIndex;
+//           if (that['imageList' + that.userIndex].some(v => v.imageType == type)) {
+//             that['imageList' + that.userIndex].map(val => {
+//               if (val.imageType == type) {
+//                 val.imageId = res.data.id;
+//               }
+//             })
+//           } else {
+//             that['imageList' + that.userIndex].push({
+//               imageId: res.data.id,
+//               imageType: type,
+//             })
+//           }
+//           that[type + 'File'] = aaa;
+//         } else {
+//           that.$message({ message: res.msg, type: "warning" });
+//         }
+//       });
+//     }
+      //选择身份证背面
+      var file = file.raw;
+      let files = window.URL.createObjectURL(file); //转链接
+      this.userbackImg = files;
       const params = new FormData(); // 声明formData数据类型
-      params.append("multipartFile", aaa);
+      params.append("multipartFile", file);
       params.append("type", "image");
-      that.$api.letter.uploadFile(params).then(res => {
+      this.$api.letter.uploadFile(params).then(res => {
         if (res.code == "200") {
-          let type = 'D0' + that.userIndex;
-          if (that['imageList' + that.userIndex].some(v => v.imageType == type)) {
-            that['imageList' + that.userIndex].map(val => {
+          let type = 'D0' + this.userIndex;
+          if (this['imageList' + this.userIndex].some(v => v.imageType == type)) {
+            this['imageList' + this.userIndex].map(val => {
               if (val.imageType == type) {
                 val.imageId = res.data.id;
               }
             })
+
           } else {
-            that['imageList' + that.userIndex].push({
+            this['imageList' + this.userIndex].push({
               imageId: res.data.id,
               imageType: type,
             })
           }
-          that[type + 'File'] = aaa;
+          this[type + 'File'] = file;
         } else {
-          that.$message({ message: res.msg, type: "warning" });
+          this.$message({ message: res.msg, type: "warning" });
         }
       });
-    }
-      //选择身份证背面
-      // var file = file.raw;
-      // let files = window.URL.createObjectURL(file); //转链接
-      // this.userbackImg = files;
-      // const params = new FormData(); // 声明formData数据类型
-      // params.append("multipartFile", file);
-      // params.append("type", "image");
-      // this.$api.letter.uploadFile(params).then(res => {
-      //   if (res.code == "200") {
-      //     let type = 'D0' + this.userIndex;
-      //     if (this['imageList' + this.userIndex].some(v => v.imageType == type)) {
-      //       this['imageList' + this.userIndex].map(val => {
-      //         if (val.imageType == type) {
-      //           val.imageId = res.data.id;
-      //         }
-      //       })
-
-      //     } else {
-      //       this['imageList' + this.userIndex].push({
-      //         imageId: res.data.id,
-      //         imageType: type,
-      //       })
-      //     }
-      //     this[type + 'File'] = file;
-      //   } else {
-      //     this.$message({ message: res.msg, type: "warning" });
-      //   }
-      // });
     },
     CarOCRdiscern() {
       //car识别