Sfoglia il codice sorgente

使用原生手机拍照,优化企业微信拍照模糊问题

zhujindu 8 mesi fa
parent
commit
a96c4c8af3
1 ha cambiato i file con 36 aggiunte e 2 eliminazioni
  1. 36 2
      src/components/uploadVNormal.vue

+ 36 - 2
src/components/uploadVNormal.vue

@@ -135,13 +135,47 @@ export default {
     // 原生H5拍照图片
     // url: base64
     getImg(base64) {
+      if (this.objectType == '' || this.objectType == null) {
+        this.$toast('请选择类型!');
+        return;
+      }
       // 图片名称:用户名-时间戳
       let username = localStorage.getItem('nickName');
       let imgName = username + '-' + new Date().getTime();
       uploadAliOss(base64, imgName)
         .then((res) => {
-          debugger;
-          addH5Photo();
+          if (res.url && res.url.indexOf('http') != -1) {
+            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) => {})
+              .catch((error) => {});
+          }
         })
         .catch((err) => {
           console.log('err:' + err);