Prechádzať zdrojové kódy

Merge branch 'feature_20260506_增加照片上传进度UI效果' into uat(dev)

zhujindu 1 deň pred
rodič
commit
3f489ce83f
1 zmenil súbory, kde vykonal 33 pridanie a 24 odobranie
  1. 33 24
      src/components/uploadVNormalTaskPhoto.vue

+ 33 - 24
src/components/uploadVNormalTaskPhoto.vue

@@ -347,6 +347,7 @@ export default {
           this.requestThen(res);
         })
         .catch((error) => {
+          this.resetDemo2();
           this.requestCatch(error);
         });
     },
@@ -375,6 +376,7 @@ export default {
           }
         }
       } else {
+        this.resetDemo2();
         that.$toast('上传失败!');
       }
     },
@@ -390,32 +392,39 @@ export default {
       if (this.d2timer) {
         clearTimeout(this.d2timer);
       }
-      this.runD2(500, false, () => {
-        if (this.d2timer) {
-          clearTimeout(this.d2timer);
-        }
-        this.d2running = false;
-        this.d2count = 0;
-        this.uploadImgTotal = 0;
-        document.getElementById('d2ring').style.strokeDashoffset = 251.2;
-        document.getElementById('d2pct').textContent = '0%';
-        document.getElementById('d2sub').textContent = '上传中';
-        this.uploadImgFlag = false;
-        this.$toast('上传成功!');
-        let fileInfoList = [];
-        res.data.forEach((val) => {
-          fileInfoList.push({
-            fileUrl: val.url,
-            id: val.fileId,
-            type: 2,
+      try {
+        this.runD2(500, false, () => {
+          this.resetDemo2();
+          this.$toast('上传成功!');
+          let fileInfoList = [];
+          res.data.forEach((val) => {
+            fileInfoList.push({
+              fileUrl: val.url,
+              id: val.fileId,
+              type: 2,
+            });
+          });
+          this.$emit('newimgarr', {
+            fileInfoList: fileInfoList,
+            photoIdentifyType: this.photoIdentifyType,
+            source: 'H5',
           });
         });
-        this.$emit('newimgarr', {
-          fileInfoList: fileInfoList,
-          photoIdentifyType: this.photoIdentifyType,
-          source: 'H5',
-        });
-      });
+      } catch (error) {
+        this.resetDemo2();
+      }
+    },
+    resetDemo2() {
+      if (this.d2timer) {
+        clearTimeout(this.d2timer);
+      }
+      this.d2running = false;
+      this.d2count = 0;
+      this.uploadImgTotal = 0;
+      document.getElementById('d2ring').style.strokeDashoffset = 251.2;
+      document.getElementById('d2pct').textContent = '0%';
+      document.getElementById('d2sub').textContent = '上传中';
+      this.uploadImgFlag = false;
     },
     // 照片是否入库,1.照片识别三次不通过仍要上传,2.照片识别通过
     // isUpdate:是否更新店招照片,只有门店店招需要更新