Explorar el Código

fix:认证上传照片过大时添加提示

sunjh hace 5 años
padre
commit
aaefaaae08

+ 11 - 2
src/components/authen/AgencyAuthentication.vue

@@ -318,13 +318,22 @@ export default {
       }
       formData.append('file', param.file)
       Http.upload(Apis.FILE.UPLOAD_IMAGE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
-        console.log('上传成功')
+        this.hideLoading()
         this.authentication.agencyPhoto = res.data
         console.log(res.data)
         notify('success', '上传成功')
         this.$refs['authentication'].validateField('agencyPhoto');
       }).catch(error => {
-        notify('error', error.data)
+        this.hideLoading()
+        try {
+          if (error.response.status === 413){
+            notify('error', '文件过大,请选择小于20M的图片')
+          }else if (error.response.status === 500){
+            notify('error', '上传文件发生错误,请稍后重试')
+          }
+        }catch (e) {
+          notify('error', error.data)
+        }
       })
     },
     //设置服务类型

+ 9 - 1
src/components/authen/AgencyAuthenticationCreate.vue

@@ -295,7 +295,15 @@ export default {
         this.$refs['authentication'].validateField('agencyPhoto');
       }).catch(error => {
         this.hideLoading()
-        notify('error', error.data)
+        try {
+          if (error.response.status === 413){
+            notify('error', '文件过大,请选择小于20M的图片')
+          }else if (error.response.status === 500){
+            notify('error', '上传文件发生错误,请稍后重试')
+          }
+        }catch (e) {
+          notify('error', error.data)
+        }
       })
     },
     //设置服务类型

+ 10 - 2
src/components/authen/EnterpriseAuthentication.vue

@@ -277,8 +277,16 @@ export default {
         console.log(res.data)
         notify('success', '上传成功')
       }).catch(error => {
-        this.hideLoading();
-        notify('error', error.data)
+        this.hideLoading()
+        try {
+          if (error.response.status === 413){
+            notify('error', '文件过大,请选择小于20M的图片')
+          }else if (error.response.status === 500){
+            notify('error', '上传文件发生错误,请稍后重试')
+          }
+        }catch (e) {
+          notify('error', error.data)
+        }
       })
     },
     //

+ 9 - 1
src/components/authen/EnterpriseAuthenticationCreate.vue

@@ -250,7 +250,15 @@ export default {
         this.$refs['authentication'].validateField('businessLicensePhoto')
       }).catch(error => {
         this.hideLoading()
-        notify('error', error.data)
+        try {
+          if (error.response.status === 413){
+            notify('error', '文件过大,请选择小于20M的图片')
+          }else if (error.response.status === 500){
+            notify('error', '上传文件发生错误,请稍后重试')
+          }
+        }catch (e) {
+          notify('error', error.data)
+        }
       })
     },
     //

+ 9 - 1
src/components/authen/IndividualAuthentication.vue

@@ -270,7 +270,15 @@ export default {
 
       }).catch(error => {
         this.hideLoading()
-        notify('error', error.data)
+        try {
+          if (error.response.status === 413){
+            notify('error', '文件过大,请选择小于20M的图片')
+          }else if (error.response.status === 500){
+            notify('error', '上传文件发生错误,请稍后重试')
+          }
+        }catch (e) {
+          notify('error', error.data)
+        }
       })
     },
     //

+ 9 - 3
src/components/authen/IndividualAuthenticationCreate.vue

@@ -222,14 +222,20 @@ export default {
       formData.append('file', param.file)
       Http.upload(Apis.FILE.UPLOAD_IMAGE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
         this.hideLoading()
-        console.log('上传成功')
         this.authentication.IDCardPhoto = res.data
-        console.log(res.data)
         notify('success', '上传成功')
         this.$refs['authentication'].validateField('IDCardPhoto');
       }).catch(error => {
         this.hideLoading()
-        notify('error', error.data)
+        try {
+          if (error.response.status === 413){
+            notify('error', '文件过大,请选择小于20M的图片')
+          }else if (error.response.status === 500){
+            notify('error', '上传文件发生错误,请稍后重试')
+          }
+        }catch (e) {
+          notify('error', error.data)
+        }
       })
     },
     //