Преглед изворни кода

feature_20250811_拜访拍照任务连拍

zhujindu пре 3 месеци
родитељ
комит
0ad1337e8a
1 измењених фајлова са 48 додато и 27 уклоњено
  1. 48 27
      src/components/uploadVNormal.vue

+ 48 - 27
src/components/uploadVNormal.vue

@@ -157,6 +157,7 @@ export default {
       fileUrl: '',
       imageWhiteStoreData: null,
       imageWhiteStoreFlag: false,
+      localIdsArr: [],
     };
   },
   methods: {
@@ -210,7 +211,7 @@ export default {
       let that = this;
       let wx = this.wx;
       let qiyeData;
-      let addressesRemark = '';
+      this.addressesRemark = '';
       const instance = axios.create();
       instance.defaults.headers.common['userId'] = localStorage.getItem('loginName');
       instance
@@ -246,10 +247,10 @@ export default {
                   geocoder.getAddress({ location: location }).then(
                     function (result) {
                       var addresses = result.result.formatted_addresses;
-                      addressesRemark = addresses.recommend;
+                      that.addressesRemark = addresses.recommend;
                     },
                     function (err) {
-                      addressesRemark = '';
+                      that.addressesRemark = '';
                     }
                   );
                 },
@@ -273,31 +274,49 @@ export default {
                 defaultCameraMode: 'normal', //表示进入拍照界面的默认模式,目前有normal与batch两种选择,normal表示普通单拍模式,batch表示连拍模式,不传该参数则为normal模式。从3.0.26版本开始支持front和batch_front两种值,其中front表示默认为前置摄像头单拍模式,batch_front表示默认为前置摄像头连拍模式。(注:用户进入拍照界面仍然可自由切换两种模式)
                 isSaveToAlbum: 0, //整型值,0表示拍照时不保存到系统相册,1表示自动保存,默认值是1
                 success: function (res) {
-                  var localIds = '';
-                  if (res.localIds != undefined) {
-                    localIds = res.localIds[0];
-                  } else {
-                    localIds = res.localId;
-                  }
-                  wx.uploadImage({
-                    localId: localIds, // 需要上传的图片的本地ID,由chooseImage接口获得
-                    isShowProgressTips: 0, // 默认为1,显示进度提示
-                    success: function (res) {
-                      that.mediaId = res.serverId;
-                      that.uploadImagev(addressesRemark);
-                    },
-                    fail: (err) => {
-                      that.$toast(err.errMsg);
-                      that.$toast(err.errCode);
-                    },
-                  });
+                  let localIds = res.localIds;
+                  that.localIdsArr = [];
+                  that.syncUpload(localIds);
+                  // var localIds = '';
+                  // if (res.localIds != undefined) {
+                  //   localIds = res.localIds[0];
+                  // } else {
+                  //   localIds = res.localId;
+                  // }
+                  // wx.uploadImage({
+                  //   localId: localIds, // 需要上传的图片的本地ID,由chooseImage接口获得
+                  //   isShowProgressTips: 0, // 默认为1,显示进度提示
+                  //   success: function (res) {
+                  //     that.mediaId = res.serverId;
+                  //     that.uploadImagev(addressesRemark);
+                  //   },
+                  //   fail: (err) => {
+                  //     that.$toast(err.errMsg);
+                  //     that.$toast(err.errCode);
+                  //   },
+                  // });
                 },
               });
             });
           }
         });
     },
-    uploadImagev(addressesRemark = '') {
+    syncUpload(localIds) {
+      if (!localIds.length) {
+        this.uploadImagev();
+      } else {
+        var localId = localIds.pop();
+        wx.uploadImage({
+          localId: localId,
+          isShowProgressTips: 1, // 默认为1,显示进度提示
+          success: (res) => {
+            this.localIdsArr.push(res.serverId);
+            this.syncUpload(localIds);
+          },
+        });
+      }
+    },
+    uploadImagev() {
       // 初始化重置 图匠校验
       this.resetProgress();
       this.close();
@@ -322,7 +341,6 @@ export default {
       if (that.thirdCollectionId != null && that.thirdCollectionId != 'null') {
         thirdCollectionId = that.thirdCollectionId;
       }
-      this.addressesRemark = addressesRemark;
       var form = {
         mediaId: '',
         fileUrl: '',
@@ -333,7 +351,7 @@ export default {
         visitsId: localStorage.getItem('visitId'),
         visitModel: that.visitModel,
         visitSource: '1',
-        locationRemark: addressesRemark,
+        locationRemark: that.addressesRemark,
         parentCollectionId: parentCollectionId,
         secondCollectionId: secondCollectionId,
         firstCollectionId: firstCollectionId,
@@ -344,13 +362,16 @@ export default {
       };
       // 0=企业微信,1=H5相机
       if (this.userInfo.photoMethod == '0') {
-        form.mediaId = this.mediaId; //	string	图片素材id
+        form.mediaId = this.localIdsArr; //	string	图片素材id
       } else {
         form.fileUrl = this.fileUrl; //	string	图片素材id
       }
       this.controller = null;
       // 需要图匠校验的添加参数和loading
-      if (this.photoIdentifyType && this.photoIdentifyType != '6') {
+      if (
+        this.photoIdentifyType &&
+        (this.photoIdentifyType == '1' || this.photoIdentifyType == '3')
+      ) {
         form.photoIdentifyType = this.photoIdentifyType;
         this.progress();
         this.controller = new AbortController(); //取消请求
@@ -454,7 +475,7 @@ export default {
         };
         // 0=企业微信,1=H5相机
         if (this.userInfo.photoMethod == '0') {
-          form.mediaId = this.mediaId; //	string	图片素材id
+          form.mediaId = this.localIdsArr; //	string	图片素材id
         } else {
           form.fileUrl = this.fileUrl; //	string	图片素材id
         }