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

feature_20250811_拜访拍照任务连拍

zhujindu пре 3 месеци
родитељ
комит
bb674e9f4e
2 измењених фајлова са 129 додато и 126 уклоњено
  1. 63 60
      src/components/uploadVNormal copy.vue
  2. 66 66
      src/components/uploadVNormal.vue

+ 63 - 60
src/components/uploadVNormal copy.vue

@@ -127,15 +127,10 @@ export default {
       default: '0',
     },
     photoIdentifyType: {
-      // 图匠识别目的(1:店招内容识别(不能连拍和多选),3:调色机识别(不能连拍和多选),6:陈列SKU图片识别(不需要图匠实时识别))
+      // 图匠识别目的(1:店招内容识别,2:门店代码识别,3:调色机识别,4:更换店招,6:陈列SKU图片识别)
       type: String,
       default: '',
     },
-    continuousShoot: {
-      // 是否允许连拍/相册多选 1:允许;0:不允许
-      type: String,
-      default: '0',
-    },
   },
   computed: {
     ...mapState({
@@ -157,7 +152,6 @@ export default {
       fileUrl: '',
       imageWhiteStoreData: null,
       imageWhiteStoreFlag: false,
-      localIdsArr: [],
     };
   },
   methods: {
@@ -176,6 +170,40 @@ export default {
           if (res.url && res.url.indexOf('http') != -1) {
             this.fileUrl = res.url;
             this.uploadImagev();
+            // var form = {
+            //   fileUrl: res.url,
+            //   collectionItemId: this.collectionId,
+            //   objectType: this.objectType,
+            //   storeGroupId: this.storeGroupId,
+            //   taskId: this.taskId,
+            //   visitsId: localStorage.getItem('visitId'),
+            //   visitModel: this.visitModel,
+            //   visitSource: '1',
+            //   locationRemark: '',
+            //   parentCollectionId: this.parentCollectionId || '',
+            //   secondCollectionId: this.secondCollectionId || '',
+            //   firstCollectionId: this.firstCollectionId || '',
+            //   fourthCollectionId: this.fourthCollectionId || '',
+            //   thirdCollectionId: this.thirdCollectionId || '',
+            //   deviceCode: this.deviceCode, //设备编号
+            //   putInCode: this.putInCode, //投放编号
+            // };
+            // this.controller = null;
+            // // 需要图匠校验的添加参数和loading
+            // if (this.photoIdentifyType) {
+            //   form.photoIdentifyType = this.photoIdentifyType;
+            //   this.progress();
+            //   this.controller = new AbortController(); //取消请求
+            // } else {
+            //   this.toastLoading(0, '上传中...', true);
+            // }
+            // addH5Photo(form, this.controller ? this.controller.signal : null)
+            //   .then((res) => {
+            //     this.requestThen(res);
+            //   })
+            //   .catch((error) => {
+            //     this.requestCatch(error);
+            //   });
           }
         })
         .catch((err) => {
@@ -211,7 +239,7 @@ export default {
       let that = this;
       let wx = this.wx;
       let qiyeData;
-      this.addressesRemark = '';
+      let addressesRemark = '';
       const instance = axios.create();
       instance.defaults.headers.common['userId'] = localStorage.getItem('loginName');
       instance
@@ -247,10 +275,10 @@ export default {
                   geocoder.getAddress({ location: location }).then(
                     function (result) {
                       var addresses = result.result.formatted_addresses;
-                      that.addressesRemark = addresses.recommend;
+                      addressesRemark = addresses.recommend;
                     },
                     function (err) {
-                      that.addressesRemark = '';
+                      addressesRemark = '';
                     }
                   );
                 },
@@ -262,61 +290,38 @@ export default {
               });
               console.log(that.pictureSource);
               let sourceType = that.pictureSource == '1' ? ['album', 'camera'] : ['camera'];
-              let count = 1;
-              // 1:店招内容识别(不能连拍和多选),3:调色机识别(不能连拍和多选)
-              if (that.photoIdentifyType != 1 && that.photoIdentifyType != 3) {
-                count = that.continuousShoot == '1' ? 5 : 1; //是否允许连拍/相册多选 最多5张
-              }
               wx.chooseImage({
-                count: count,
+                count: 1,
                 sizeType: ['original'], // 可以指定是原图还是压缩图,默认二者都有
                 sourceType: sourceType, // 可以指定来源是相册还是相机,默认二者都有
                 defaultCameraMode: 'normal', //表示进入拍照界面的默认模式,目前有normal与batch两种选择,normal表示普通单拍模式,batch表示连拍模式,不传该参数则为normal模式。从3.0.26版本开始支持front和batch_front两种值,其中front表示默认为前置摄像头单拍模式,batch_front表示默认为前置摄像头连拍模式。(注:用户进入拍照界面仍然可自由切换两种模式)
                 isSaveToAlbum: 0, //整型值,0表示拍照时不保存到系统相册,1表示自动保存,默认值是1
                 success: function (res) {
-                  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);
-                  //   },
-                  // });
+                  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);
+                    },
+                  });
                 },
               });
             });
           }
         });
     },
-    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() {
+    uploadImagev(addressesRemark = '') {
       // 初始化重置 图匠校验
       this.resetProgress();
       this.close();
@@ -341,6 +346,7 @@ export default {
       if (that.thirdCollectionId != null && that.thirdCollectionId != 'null') {
         thirdCollectionId = that.thirdCollectionId;
       }
+      this.addressesRemark = addressesRemark;
       var form = {
         mediaId: '',
         fileUrl: '',
@@ -351,7 +357,7 @@ export default {
         visitsId: localStorage.getItem('visitId'),
         visitModel: that.visitModel,
         visitSource: '1',
-        locationRemark: that.addressesRemark,
+        locationRemark: addressesRemark,
         parentCollectionId: parentCollectionId,
         secondCollectionId: secondCollectionId,
         firstCollectionId: firstCollectionId,
@@ -362,16 +368,13 @@ export default {
       };
       // 0=企业微信,1=H5相机
       if (this.userInfo.photoMethod == '0') {
-        form.mediaId = this.localIdsArr; //	string	图片素材id
+        form.mediaId = this.mediaId; //	string	图片素材id
       } else {
         form.fileUrl = this.fileUrl; //	string	图片素材id
       }
       this.controller = null;
       // 需要图匠校验的添加参数和loading
-      if (
-        this.photoIdentifyType &&
-        (this.photoIdentifyType == '1' || this.photoIdentifyType == '3')
-      ) {
+      if (this.photoIdentifyType && this.photoIdentifyType != '6') {
         form.photoIdentifyType = this.photoIdentifyType;
         this.progress();
         this.controller = new AbortController(); //取消请求
@@ -475,7 +478,7 @@ export default {
         };
         // 0=企业微信,1=H5相机
         if (this.userInfo.photoMethod == '0') {
-          form.mediaId = this.localIdsArr; //	string	图片素材id
+          form.mediaId = this.mediaId; //	string	图片素材id
         } else {
           form.fileUrl = this.fileUrl; //	string	图片素材id
         }

+ 66 - 66
src/components/uploadVNormal.vue

@@ -127,10 +127,15 @@ export default {
       default: '0',
     },
     photoIdentifyType: {
-      // 图匠识别目的(1:店招内容识别,2:门店代码识别,3:调色机识别,4:更换店招,6:陈列SKU图片识别)
+      // 图匠识别目的(1:店招内容识别(不能连拍和多选),3:调色机识别(不能连拍和多选),6:陈列SKU图片识别(不需要图匠实时识别))
       type: String,
       default: '',
     },
+    continuousShoot: {
+      // 是否允许连拍/相册多选 1:允许;0:不允许
+      type: String,
+      default: '0',
+    },
   },
   computed: {
     ...mapState({
@@ -152,6 +157,7 @@ export default {
       fileUrl: '',
       imageWhiteStoreData: null,
       imageWhiteStoreFlag: false,
+      localIdsArr: [],
     };
   },
   methods: {
@@ -170,40 +176,6 @@ export default {
           if (res.url && res.url.indexOf('http') != -1) {
             this.fileUrl = res.url;
             this.uploadImagev();
-            // var form = {
-            //   fileUrl: res.url,
-            //   collectionItemId: this.collectionId,
-            //   objectType: this.objectType,
-            //   storeGroupId: this.storeGroupId,
-            //   taskId: this.taskId,
-            //   visitsId: localStorage.getItem('visitId'),
-            //   visitModel: this.visitModel,
-            //   visitSource: '1',
-            //   locationRemark: '',
-            //   parentCollectionId: this.parentCollectionId || '',
-            //   secondCollectionId: this.secondCollectionId || '',
-            //   firstCollectionId: this.firstCollectionId || '',
-            //   fourthCollectionId: this.fourthCollectionId || '',
-            //   thirdCollectionId: this.thirdCollectionId || '',
-            //   deviceCode: this.deviceCode, //设备编号
-            //   putInCode: this.putInCode, //投放编号
-            // };
-            // this.controller = null;
-            // // 需要图匠校验的添加参数和loading
-            // if (this.photoIdentifyType) {
-            //   form.photoIdentifyType = this.photoIdentifyType;
-            //   this.progress();
-            //   this.controller = new AbortController(); //取消请求
-            // } else {
-            //   this.toastLoading(0, '上传中...', true);
-            // }
-            // addH5Photo(form, this.controller ? this.controller.signal : null)
-            //   .then((res) => {
-            //     this.requestThen(res);
-            //   })
-            //   .catch((error) => {
-            //     this.requestCatch(error);
-            //   });
           }
         })
         .catch((err) => {
@@ -239,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
@@ -275,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 = '';
                     }
                   );
                 },
@@ -290,38 +262,61 @@ export default {
               });
               console.log(that.pictureSource);
               let sourceType = that.pictureSource == '1' ? ['album', 'camera'] : ['camera'];
+              let count = 1;
+              // 1:店招内容识别(不能连拍和多选),3:调色机识别(不能连拍和多选) 需要实时识别的不支持连拍和多选
+              if (that.photoIdentifyType != 1 && that.photoIdentifyType != 3) {
+                count = that.continuousShoot == '1' ? 5 : 1; //是否允许连拍/相册多选 最多5张
+              }
               wx.chooseImage({
-                count: 1,
+                count: count,
                 sizeType: ['original'], // 可以指定是原图还是压缩图,默认二者都有
                 sourceType: sourceType, // 可以指定来源是相册还是相机,默认二者都有
                 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();
@@ -346,9 +341,8 @@ export default {
       if (that.thirdCollectionId != null && that.thirdCollectionId != 'null') {
         thirdCollectionId = that.thirdCollectionId;
       }
-      this.addressesRemark = addressesRemark;
       var form = {
-        mediaId: '',
+        mediaIds: '',
         fileUrl: '',
         collectionItemId: that.collectionId,
         objectType: that.objectType,
@@ -357,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,
@@ -368,13 +362,16 @@ export default {
       };
       // 0=企业微信,1=H5相机
       if (this.userInfo.photoMethod == '0') {
-        form.mediaId = this.mediaId; //	string	图片素材id
+        form.mediaIds = 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(); //取消请求
@@ -397,7 +394,10 @@ export default {
         this.requestTimeOut(res);
       } else if (res.code == 200) {
         // 图匠校验结果返回
-        if (this.photoIdentifyType && this.photoIdentifyType != '6') {
+        if (
+          this.photoIdentifyType &&
+          (this.photoIdentifyType == '1' || this.photoIdentifyType == '3')
+        ) {
           // 重置loaidng状态
           this.resetProgress();
           this.imageAIVerifyFlag = true;
@@ -459,7 +459,7 @@ export default {
     confirmUpload(res) {
       if (this.photoIdentifyType && this.photoIdentifyType != '6') {
         var form = {
-          mediaId: '',
+          mediaIds: '',
           fileUrl: '',
           visitSource: '1', //	Long	拜访模式
           storeGroupId: this.storeGroupId, //	string	门店任务组,多个用逗号隔开
@@ -478,7 +478,7 @@ export default {
         };
         // 0=企业微信,1=H5相机
         if (this.userInfo.photoMethod == '0') {
-          form.mediaId = this.mediaId; //	string	图片素材id
+          form.mediaIds = this.localIdsArr; //	string	图片素材id
         } else {
           form.fileUrl = this.fileUrl; //	string	图片素材id
         }