소스 검색

解决企业认证和更换管理员申诉上传图片时点击取消按钮页面一直加载的问题

hangb 7 년 전
부모
커밋
8b05e8049b
2개의 변경된 파일61개의 추가작업 그리고 53개의 파일을 삭제
  1. 32 28
      components/appeal/ChangeManagerAppeal.vue
  2. 29 25
      components/certification/EnterpriseCertification.vue

+ 32 - 28
components/appeal/ChangeManagerAppeal.vue

@@ -476,38 +476,42 @@
       upload (e) {
         this.isShowLoading = true
         let file = e.target.files[0]
-        if (file.size > 5 * 1024 * 1024) {
-          this.uploadFileChecked = false
-          this.isShowLoading = false
-        } else {
-          let param = new FormData()
-          param.append('image', file, file.name)
-          let config = {
-            headers: {'Content-Type': 'multipart/form-data'}
-          }
+        if (file) {
+          if (file.size > 5 * 1024 * 1024) {
+            this.uploadFileChecked = false
+            this.isShowLoading = false
+          } else {
+            let param = new FormData()
+            param.append('image', file, file.name)
+            let config = {
+              headers: {'Content-Type': 'multipart/form-data'}
+            }
 //          图片上传接口
-          this.$http.post('/api/userspace/upload', param, config)
-            .then(response => {
-              this.isShowLoading = false
-              if (response.data.success) {
-                let path = response.data.content
-                if (path.slice(path.lastIndexOf('.')).toLowerCase() === '.pdf') {
-                  this.isPdf = true
+            this.$http.post('/api/userspace/upload', param, config)
+              .then(response => {
+                this.isShowLoading = false
+                if (response.data.success) {
+                  let path = response.data.content
+                  if (path.slice(path.lastIndexOf('.')).toLowerCase() === '.pdf') {
+                    this.isPdf = true
+                  } else {
+                    this.isPdf = false
+                  }
+                  this.changeManager.businessCodeImage = response.data.content
+                  this.uploadFileChecked = true
                 } else {
-                  this.isPdf = false
+                  this.uploadFileChecked = false
+                  return Promise.reject(response.data)
                 }
-                this.changeManager.businessCodeImage = response.data.content
-                this.uploadFileChecked = true
-              } else {
-                this.uploadFileChecked = false
-                return Promise.reject(response.data)
-              }
-            }).catch(err => {
-              console.log(err)
+              }).catch(err => {
+                console.log(err)
               // this.$message.error(err.errMsg)
-              this.isShowLoading = false
-              this.uploadFileChecked = false
-            })
+                this.isShowLoading = false
+                this.uploadFileChecked = false
+              })
+          }
+        } else {
+          this.isShowLoading = false
         }
       },
 //      地址选择

+ 29 - 25
components/certification/EnterpriseCertification.vue

@@ -328,32 +328,36 @@
       upload (e) {
         this.isShowLoading = true
         let file = e.target.files[0]
-        if (file.size > 5 * 1024 * 1024) {
-          this.uploadFileChecked = false
-          this.isShowLoading = false
-        } else {
-          let param = new FormData()
-          param.append('image', file, file.name)
-          let config = {
-            headers: {'Content-Type': 'multipart/form-data'}
-          }
+        if (file) {
+          if (file.size > 5 * 1024 * 1024) {
+            this.uploadFileChecked = false
+            this.isShowLoading = false
+          } else {
+            let param = new FormData()
+            param.append('image', file, file.name)
+            let config = {
+              headers: {'Content-Type': 'multipart/form-data'}
+            }
 //          图片上传接口
-          this.$http.post('/api/userspace/upload', param, config)
-            .then(response => {
-              this.isShowLoading = false
-              let path = response.data.content
-              if (path.slice(path.lastIndexOf('.')).toLowerCase() === '.pdf') {
-                this.isPdf = true
-              } else {
-                this.isPdf = false
-              }
-              this.enterprise.businessCodeImage = response.data.content
-              this.uploadFileChecked = true
-            }, err => {
-              this.isShowLoading = false
-              console.log(err)
-              this.uploadFileChecked = false
-            })
+            this.$http.post('/api/userspace/upload', param, config)
+              .then(response => {
+                this.isShowLoading = false
+                let path = response.data.content
+                if (path.slice(path.lastIndexOf('.')).toLowerCase() === '.pdf') {
+                  this.isPdf = true
+                } else {
+                  this.isPdf = false
+                }
+                this.enterprise.businessCodeImage = response.data.content
+                this.uploadFileChecked = true
+              }, err => {
+                this.isShowLoading = false
+                console.log(err)
+                this.uploadFileChecked = false
+              })
+          }
+        } else {
+          this.isShowLoading = false
         }
       },
 //      地址选择