Explorar o código

Merge branch 'feature_20250819_图像识别连拍' into dev(uat)

zhujindu hai 4 meses
pai
achega
d5692e8e9c
Modificáronse 2 ficheiros con 114 adicións e 54 borrados
  1. 111 54
      src/components/uploadVNormal.vue
  2. 3 0
      src/views/agentList/visitTask.vue

+ 111 - 54
src/components/uploadVNormal.vue

@@ -101,7 +101,7 @@ export default {
       default: '',
     },
     photoIdentifyType: {
-      // 图匠识别目的(1:店招内容识别,2:门店代码识别,3:调色机识别,4:更换店招)
+      // 图匠识别目的(1:店招内容识别(不能连拍和多选),3:调色机识别(不能连拍和多选),6:陈列SKU图片识别(不需要图匠实时识别))
       type: String,
       default: '',
     },
@@ -110,6 +110,11 @@ export default {
       type: String,
       default: '0',
     },
+    continuousShoot: {
+      // 是否允许连拍/相册多选 1:允许;0:不允许
+      type: String,
+      default: '0',
+    },
   },
   data() {
     return {
@@ -123,6 +128,7 @@ export default {
       meidaId: '', //当前上传图片id
       addressesRemark: '', //当前位置信息
       controller: null, //取消请求状态
+      localIdsArr: [],
     };
   },
   methods: {
@@ -147,7 +153,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
@@ -183,10 +189,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 = '';
                     }
                   );
                 },
@@ -198,33 +204,56 @@ 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表示默认为前置摄像头连拍模式。(注:用户进入拍照界面仍然可自由切换两种模式)
+                defaultCameraMode: count == 1 ? 'normal' : 'batch', //表示进入拍照界面的默认模式,目前有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: 1, // 默认为1,显示进度提示
-                    success: function (res) {
-                      that.uploadImagev(res.serverId, addressesRemark);
-                    },
-                  });
+                  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: 1, // 默认为1,显示进度提示
+                  //   success: function (res) {
+                  //     that.uploadImagev(res.serverId, addressesRemark);
+                  //   },
+                  // });
                 },
               });
             });
           }
         });
     },
-    uploadImagev(meidaId, 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();
@@ -249,10 +278,8 @@ export default {
       if (that.thirdCollectionId != null && that.thirdCollectionId != 'null') {
         thirdCollectionId = that.thirdCollectionId;
       }
-      this.meidaId = meidaId;
-      this.addressesRemark = addressesRemark;
       var form = {
-        mediaId: meidaId,
+        mediaIds: this.localIdsArr,
         collectionItemId: that.collectionId,
         objectType: that.objectType,
         storeGroupId: that.storeGroupId,
@@ -260,7 +287,7 @@ export default {
         visitsId: localStorage.getItem('visitId'),
         visitModel: that.visitModel,
         visitSource: '1',
-        locationRemark: addressesRemark,
+        locationRemark: that.addressesRemark,
         parentCollectionId: parentCollectionId,
         secondCollectionId: secondCollectionId,
         firstCollectionId: firstCollectionId,
@@ -271,7 +298,10 @@ export default {
       };
       this.controller = null;
       // 需要图匠校验的添加参数和loading
-      if (this.photoIdentifyType) {
+      if (
+        this.photoIdentifyType &&
+        (this.photoIdentifyType == '1' || this.photoIdentifyType == '3')
+      ) {
         form.photoIdentifyType = this.photoIdentifyType;
         this.progress();
         this.controller = new AbortController(); //取消请求
@@ -280,41 +310,67 @@ export default {
       }
       addstorePhoto(form, this.controller ? this.controller.signal : null)
         .then((res) => {
-          this.toastLoading().clear();
-          if (res.code == -1) {
-            // 图匠图片校验接口超时
-            this.requestTimeOut(res);
-          } else if (res.code == 200) {
-            // 图匠校验结果返回
-            if (this.photoIdentifyType) {
-              // 重置loaidng状态
-              this.resetProgress();
-              this.imageAIVerifyFlag = true;
-              this.imageAIVerifyData = res.data;
-            } else {
-              // 正常流程
-              this.normalFlow(res);
-            }
-          } else {
-            this.resetProgress();
-            that.$toast('上传失败!');
-          }
+          this.requestThen(res);
         })
         .catch((error) => {
-          if (error.message === 'canceled') {
-            this.$toast('取消上传');
-            console.log('请求被取消:', error.message);
-          }
-          this.resetProgress();
+          this.requestCatch(error);
         });
     },
+    // 公用请求then
+    requestThen(res) {
+      this.toastLoading().clear();
+      if (res.code == -1) {
+        // 图匠图片校验接口超时
+        this.requestTimeOut(res);
+      } else if (res.code == 200) {
+        // 图匠校验结果返回
+        if (
+          this.photoIdentifyType &&
+          (this.photoIdentifyType == '1' || this.photoIdentifyType == '3')
+        ) {
+          // 重置loaidng状态
+          this.resetProgress();
+          this.imageAIVerifyFlag = true;
+          this.imageAIVerifyData = res.data[0];
+        } else {
+          // 正常流程
+          // 图像识别白名单用户弹出框提示
+          // if (res.data[0].whiteStore) {
+          //   this.imageWhiteStoreFlag = true;
+          //   this.imageWhiteStoreData = res.data[0];
+          // } else {
+          this.normalFlow(res);
+          // }
+        }
+      } else {
+        this.resetProgress();
+        that.$toast('上传失败!');
+      }
+    },
+    // 公用请求catch
+    requestCatch(error) {
+      if (error.message === 'canceled') {
+        this.$toast('取消上传');
+        console.log('请求被取消:', error.message);
+      }
+      this.resetProgress();
+    },
     // 正常流程
     normalFlow(res) {
       this.$toast('上传成功!');
+      let fileInfoList = [];
+      res.data.forEach((val) => {
+        fileInfoList.push({
+          fileUrl: val.url,
+          id: val.fileId,
+          type: 2,
+        });
+      });
       this.$emit('newimgarr', {
-        fileUrl: res.data.url,
-        id: res.data.fileId,
-        type: 2,
+        fileInfoList: fileInfoList,
+        // fileUrl: res.data.url,
+        // id: res.data.fileId,
+        // type: 2,
         photoIdentifyType: this.photoIdentifyType,
       });
     },
@@ -342,7 +398,7 @@ export default {
     confirmUpload(res) {
       if (this.photoIdentifyType) {
         var form = {
-          mediaId: this.meidaId, //	string	图片素材id
+          mediaIds: this.meidaId, //	string	图片素材id
           visitSource: '1', //	Long	拜访模式
           storeGroupId: this.storeGroupId, //	string	门店任务组,多个用逗号隔开
           visitsId: localStorage.getItem('visitId'), //	string	拜访id
@@ -364,7 +420,8 @@ export default {
         addPhotoToDB(form).then((resData) => {
           if (resData.code == 200) {
             console.log(resData);
-            res.data.fileId = resData.data.fileId;
+            res.data.fileId = resData.data[0].fileId;
+            res.data = [res.data];
             this.normalFlow(res);
           }
         });

+ 3 - 0
src/views/agentList/visitTask.vue

@@ -2678,6 +2678,7 @@
             @typeshow="typeshow"
             :photoIdentifyType="photoIdentifyType"
             :pictureSource="pictureSource"
+            :continuousShoot="continuousShoot"
             ref="uploadVNormal"></upload-img>
         </template>
       </van-cell>
@@ -2844,6 +2845,7 @@ export default {
       pictureSource: '0',
       inspectionType: '',
       competitortableData: [],
+      continuousShoot: '0',
     };
   },
   watch: {
@@ -3823,6 +3825,7 @@ export default {
       this.thirdCollectionId = val.thirdCollectionId;
       this.fourthCollectionId = val.fourthCollectionId;
       this.pictureSource = val.pictureSource; //是否允许从相册选择图片
+      this.continuousShoot = val.continuousShoot; //是否允许从相册选择图片
       this.indeximg = index;
       this.childIndex = childIndex;
       this.childIndex1 = childIndex1;