谢杰标 2 éve
szülő
commit
6c3cb3cb0d
3 módosított fájl, 212 hozzáadás és 66 törlés
  1. 36 30
      common/httpList/oss.js
  2. 8 1
      common/methodTool.js
  3. 168 35
      pages2/verify/input.vue

+ 36 - 30
common/httpList/oss.js

@@ -1,31 +1,37 @@
-import {
-	myRequest
-} from '../request.js'
+import { myRequest } from "../request.js";
 export default {
-	//回调
-	aliyuncallback(data) {
-		return myRequest({
-			url: '/aliyun/oss/callback',
-			method: 'post',
-			data: data
-		})
-	},
-	//policy获得
-	aliyunpolicy(data) {
-		return myRequest({
-			url: '/aliyun/oss/policy',
-			method: 'get',
-			data: data,
-			// noToken: true
-		})
-	},
-	//上传图片
-	aliyunpolicyupload(data) {
-		return myRequest({
-			url: '/aliyun/oss/upload',
-			method: 'post',
-			data: data
-			// noToken: true
-		})
-	},
-}
+  //回调
+  aliyuncallback(data) {
+    return myRequest({
+      url: "/aliyun/oss/callback",
+      method: "post",
+      data: data,
+    });
+  },
+  //policy获得
+  aliyunpolicy(data) {
+    return myRequest({
+      url: "/aliyun/oss/policy",
+      method: "get",
+      data: data,
+      // noToken: true
+    });
+  },
+  //上传图片
+  aliyunpolicyupload(data) {
+    return myRequest({
+      url: "/aliyun/oss/upload",
+      method: "post",
+      data: data,
+      // noToken: true
+    });
+  },
+  aliyunUpload(url, data) {
+    return myRequest({
+      url: url,
+      method: "post",
+      data,
+	  noToken: true
+    });
+  },
+};

+ 8 - 1
common/methodTool.js

@@ -275,7 +275,14 @@ export default {
   uploadFile(options, int) {
     return new Promise((resolve, reject) => {
       var self = this;
-      if (options.indexOf("//tmp") === -1 && options.indexOf("//temp") === -1) {
+      // #ifdef MP-WEIXIN
+      const isJPG =
+        options.indexOf("//tmp") !== -1 || options.indexOf("//temp") !== -1;
+      // #endif
+      // #ifdef H5
+      const isJPG = true;
+      // #endif
+      if (!isJPG) {
         resolve(options);
         return;
       }

+ 168 - 35
pages2/verify/input.vue

@@ -245,6 +245,15 @@
                 文件大小≤2M
               </text>
               <!-- :max-size="2097152" -->
+              <!-- @on-list-change="
+                  item.fieldKey === 'recent_photos'
+                    ? changePhotoListHeader1($event)
+                    : item.fieldKey === 'idcard_face_photo'
+                    ? changePhotoListHeader2($event)
+                    : item.fieldKey === 'idcard_national_photo'
+                    ? changePhotoListHeader3($event)
+                    : ''
+                " -->
               <u-upload
                 :show-progress="false"
                 :ref="
@@ -256,15 +265,7 @@
                     ? 'idcard_national_photo'
                     : ''
                 "
-                @on-list-change="
-                  item.fieldKey === 'recent_photos'
-                    ? changePhotoListHeader1($event)
-                    : item.fieldKey === 'idcard_face_photo'
-                    ? changePhotoListHeader2($event)
-                    : item.fieldKey === 'idcard_national_photo'
-                    ? changePhotoListHeader3($event)
-                    : ''
-                "
+                @on-list-change="changePhotoListHeader($event, item.fieldKey)"
                 :auto-upload="false"
                 custom-btn="true"
                 :action="action"
@@ -510,7 +511,7 @@ export default {
       showTableDown: false,
       gradeId: 0,
       errorType: ["message"],
-      agreementModal: true,
+      agreementModal: false,
       goodsData: {},
       itemStyle: {
         marginTop: "20px",
@@ -725,6 +726,7 @@ export default {
       veryIdName: "",
       disName: false, // 姓名是否禁止输入
       disCard: false, // 身份证是否禁止输入
+      auto: "180rpx",
     };
   },
   created() {
@@ -734,7 +736,7 @@ export default {
     this.orderGoodsId = Number(option.orderGoodsId);
     this.goodsId = Number(option.id);
     this.gradeId = Number(option.gradeId);
-
+    !this.userInfo && this.$api.refreshUserInfo();
     await this.getInfo();
     await this.getGoodsDetail();
   },
@@ -1017,12 +1019,12 @@ export default {
         uni.downloadFile({
           url: this.$method.splitImgHost(this.form.idcard_face_photo),
           success: async (res) => {
+            console.log(res, 999);
             if (res.statusCode === 200) {
               let resData = await this.faceCertificationIDCardOCR(
                 1,
                 res.tempFilePath
               );
-
               if (!resData.data.data) {
                 uni.showModal({
                   title: "提示",
@@ -1330,6 +1332,7 @@ export default {
           .catch((err) => {});
       }
     },
+    
     clearWord() {
       this.$set(this.form, "commitment_seal", "");
       this.titleName = "";
@@ -1378,7 +1381,7 @@ export default {
           0
         );
       }
-
+      console.log(data,789)
       this.uploadDatas(data);
     },
     //验证表单
@@ -1450,6 +1453,91 @@ export default {
         });
       });
     },
+    h5FaceCertificationIDCardOCR(cardSide, file) {
+      return new Promise((resolve) => {
+        var reader = new FileReader();
+        // 将文件加载进入
+        reader.readAsDataURL(file);
+        reader.onload = (e) => {
+          // 转换完成输出该文件base64编码
+          let base64 = e.target.result;
+          this.$api
+            .faceCertificationIDCardOCR({
+              cardSide: cardSide, //1人像  2 国徽
+              cardImageBase64: base64,
+              gradeId: this.gradeId,
+            })
+            .then((res) => {
+              resolve(res);
+            });
+        };
+      });
+    },
+    async changePhotoListHeader(lists, key) {
+      const map = {
+        recent_photos: 1,
+        idcard_face_photo: 2,
+        idcard_national_photo: 3,
+      };
+      const index = map[key];
+      if (lists.length) {
+        this["fileList" + index] = lists;
+        // #ifdef MP-WEIXIN
+        const isJPG =
+          lists[0].url.indexOf("//tmp") !== -1 ||
+          lists[0].url.indexOf("//temp") !== -1;
+        // #endif
+        // #ifdef H5
+        const isJPG =
+          lists[0].file.type === "image/jpeg" ||
+          lists[0].file.type === "image/png" ||
+          lists[0].file.type === "image/jpg";
+        // #endif
+
+        if (isJPG) {
+          let size = lists[0].file.size;
+          if (size < 2 * 1024 * 1024) {
+            if (index == 1) {
+              let url = lists[0].url;
+              // #ifdef MP-WEIXIN
+              url = await this.$method.imageInfos(url);
+              // #endif
+              // #ifdef H5
+              url = await this.$method.uploadFile(url, 0);
+              // #endif
+              this.$set(this.form, "recent_photos", url);
+            } else {
+              // #ifdef MP-WEIXIN
+              let url = lists[0].url;
+              // #endif
+              // #ifdef H5
+              let url = lists[0].file;
+              // #endif
+              this.$refs[key][0].remove(0);
+              let titleMsg =
+                "请上传正确清晰的身份证" +
+                (index == 2 ? "人像" : "国徽") +
+                "面照片";
+              this.checkIdCard(index - 1, url, titleMsg, key);
+            }
+          } else {
+            uni.showModal({
+              title: "提示",
+              content: "上传图片大小不能超过 2MB!",
+              showCancel: false,
+            });
+            return;
+          }
+        }
+      } else {
+        this.fileList3 = [];
+        this.$set(this.form, "idcard_national_photo", "");
+      }
+      this.openVerify = false;
+      this.$nextTick(function () {
+        this.resultForm();
+      });
+    },
     async changePhotoListHeader1(lists, name) {
       if (lists.length) {
         this.fileList1 = lists;
@@ -1574,19 +1662,38 @@ export default {
     async changePhotoListHeader3(lists, name) {
       if (lists.length) {
         this.fileList3 = lists;
-        if (
+        // #ifdef MP-WEIXIN
+        const isJPG =
           lists[0].url.indexOf("//tmp") !== -1 ||
-          lists[0].url.indexOf("//temp") !== -1
-        ) {
-          console.log("//tem");
+          lists[0].url.indexOf("//temp") !== -1;
+        // #endif
+        // #ifdef H5
+        const isJPG =
+          lists[0].file.type === "image/jpeg" ||
+          lists[0].file.type === "image/png" ||
+          lists[0].file.type === "image/jpg";
+        // #endif
+
+        if (isJPG) {
+          console.log("//tem", lists[0]);
+          // #ifdef MP-WEIXIN
           let url = lists[0].url;
+          // #endif
+          // #ifdef H5
+          let url = lists[0].file;
+          // #endif
           let size = lists[0].file.size;
           this.$refs.idcard_national_photo[0].remove(0);
-
           let titleMsg = "请上传正确清晰的身份证国徽面照片";
           if (size < 2 * 1024 * 1024) {
             this.checkIdCard(2, url, titleMsg, "idcard_national_photo");
           } else {
+            uni.showModal({
+              title: "提示",
+              content: "上传图片大小不能超过 2MB!",
+              showCancel: false,
+            });
+            return;
             // 需要压缩
             let canvasId = "zipCanvas";
             let imagePath = url; //原图的路径
@@ -1614,7 +1721,12 @@ export default {
       });
     },
     async checkIdCard(cardSide, url, titleMsg, paramType) {
+      // #ifdef MP-WEIXIN
       let res = await this.faceCertificationIDCardOCR(cardSide, url);
+      // #endif
+      // #ifdef H5
+      let res = await this.h5FaceCertificationIDCardOCR(cardSide, url);
+      // #endif
 
       if (res.data.code == 500) {
         uni.showToast({
@@ -1623,6 +1735,22 @@ export default {
         });
         return;
       }
+      let { IdName, IdNum } = res.data.data;
+      if (IdName != this.form.name || IdNum != this.form.idcard) {
+        // uni.showModal({
+        //   content:
+        //     IdName != this.form.name
+        //       ? "输入的姓名和身份证人像面照片姓名不匹配,请联系客服"
+        //       : "输入的身份证号和身份证人像面照片身份证号不匹配,请联系客服",
+        //   showCancel: false,
+        //   success: (resultst) => {
+        //     if (resultst.confirm) {
+        //       uni.navigateBack();
+        //     }
+        //   },
+        // });
+        // return;
+      }
       this.$refs[paramType][0].lists = [
         {
           url: this.$method.splitImgHost(res.data.data.IdImgPath),
@@ -1709,7 +1837,7 @@ export default {
           });
           console.log(self.isRequired, "self.isRequired ");
           this.$nextTick(() => {
-            this.agreementModal = true;
+            // this.agreementModal = true;
           });
           self.$api
             .getbaseprofiletpgetInfo({
@@ -1750,8 +1878,7 @@ export default {
                                 if (ajson[k].value) {
                                   self.fileList1 = [
                                     {
-                                      url:
-                                        baseUrls + ajson[k].value,
+                                      url: baseUrls + ajson[k].value,
                                     },
                                   ];
                                 }
@@ -1760,8 +1887,7 @@ export default {
                                 if (ajson[k].value) {
                                   self.fileList2 = [
                                     {
-                                      url:
-                                        baseUrls + ajson[k].value,
+                                      url: baseUrls + ajson[k].value,
                                     },
                                   ];
                                 }
@@ -1770,8 +1896,7 @@ export default {
                                 if (ajson[k].value) {
                                   self.fileList3 = [
                                     {
-                                      url:
-                                        baseUrls + ajson[k].value,
+                                      url: baseUrls + ajson[k].value,
                                     },
                                   ];
                                 }
@@ -1845,23 +1970,17 @@ export default {
                     } else if (k === "recent_photos") {
                       self.$set(self.form, k, arrays[k].value);
                       if (arrays[k].value) {
-                        self.fileList1 = [
-                          { url: baseUrls + arrays[k].value },
-                        ];
+                        self.fileList1 = [{ url: baseUrls + arrays[k].value }];
                       }
                     } else if (k === "idcard_face_photo") {
                       self.$set(self.form, k, arrays[k].value);
                       if (arrays[k].value) {
-                        self.fileList2 = [
-                          { url: baseUrls + arrays[k].value },
-                        ];
+                        self.fileList2 = [{ url: baseUrls + arrays[k].value }];
                       }
                     } else if (k === "idcard_national_photo") {
                       self.$set(self.form, k, arrays[k].value);
                       if (arrays[k].value) {
-                        self.fileList3 = [
-                          { url: baseUrls + arrays[k].value },
-                        ];
+                        self.fileList3 = [{ url: baseUrls + arrays[k].value }];
                       }
                     } else if (k === "name") {
                       self.$set(
@@ -1912,7 +2031,7 @@ export default {
       });
     },
     bindPickerChange(key, e) {
-      this.$set(this.form, key, e.detail.value);
+      this.$set(this.form, key, e.detail.value + "");
       this.openVerify = false;
       this.$nextTick(function () {
         this.resultForm();
@@ -2017,6 +2136,20 @@ page {
   color: #ff3b30;
   font-size: 24rpx;
 }
+// /deep/ .u-input {
+//   text-align: right !important;
+// }
+.picker {
+  flex: 1;
+}
+/deep/ .u-form-item--right {
+  .u-input__input {
+    text-align: right;
+  }
+  uni-picker {
+    flex: 1;
+  }
+}
 .collapse-item {
   color: #666;
   font-size: 24rpx;