瀏覽代碼

Merge remote-tracking branch 'origin/dev' into dev

LiChengjin 3 月之前
父節點
當前提交
2578db8c96
共有 1 個文件被更改,包括 82 次插入58 次删除
  1. 82 58
      subpkg_checkin/addGuest/addGuest.vue

+ 82 - 58
subpkg_checkin/addGuest/addGuest.vue

@@ -32,6 +32,9 @@
 		<!-- #ifdef MP-ALIPAY -->
 		<!-- 支付宝在上传完身份证照片后会跳转到人脸检测页面 -->
 		<view class="step-one" v-else-if="step==='uploadCard' && !shootCard">
+			<view class="tips" v-if="!name">
+				<u-text align="center" color="#333333" text="根据《治安管理处罚法》要求所有入住宾客和访客必须一人一证实名登记"></u-text>
+			</view>
 			<view class="upload-container">
 				<image :src="idCardFrontPicPath" mode="aspectFit" @click="handleUploadFront" :style="imageStyle">
 				</image>
@@ -47,7 +50,7 @@
 				@close="handleSheetClose" />
 		</view>
 		<view class="shoot-id-card" v-if="shootCard">
-			<camera id="card-camera" flash="off" device-position="back" @ready="cameraContext" :style="[cameraStyle]" />
+			<camera id="card-camera" flash="off" device-position="back" @ready="cameraContext" :style="[cardCameraStyle]" />
 			<cover-image :src="frontSelect ? '/static/identity_info.png' : '/static/national_emblem.png'"
 				:style="[cardCameraStyle]"></cover-image>
 			<view class="camera-btn">
@@ -299,12 +302,12 @@
 					margin: "0 auto"
 				},
 				frontPassed: false,
+				idCardFrontBase64: null,
+				idCardBackBase64: null,
 				backPassed: false,
 				checkPicTips: "身份核验中....",
 				screenWidth: 0,
-				navBarHight: 0,
-				faceAreaLineHeight: 0,
-				faceAreaTipsHeight: 0,
+				faceCheckCamTopGap: 0,
 				showTips: true,
 				isCheckingFace: false,
 				faceCheckSucceed: false,
@@ -349,13 +352,7 @@
 				style.width = imgWidth + 'px'
 				style.height = imgWidth + 'px'
 				style.left = "16px"
-				let top = 0
-				if (this.faceAreaTipsHeight && this.faceAreaLineHeight && this.navBarHight) {
-					top = this.faceAreaTipsHeight + this.faceAreaLineHeight + this.navBarHight + 2
-					// console.log("顶部距离", top);
-				}
-				// console.log("computed");
-				style.top = top + "px"
+				style.top = this.faceCheckCamTopGap + "px"
 				return style
 			}
 			// #endif
@@ -911,7 +908,7 @@
 					method: "POST",
 					data: ocrData
 				})
-				console.log("ocrRes", ocrRes);
+				// console.log("ocrRes", ocrRes);
 				if (!ocrRes.success) {
 					uni.showModal({
 						content: '身份证信息识别失败,请重新选择照片或拍照上传。',
@@ -953,11 +950,13 @@
 					this.idCardInfoInPage.birth = data.birth
 					this.idCardInfoInPage.address = data.address
 					this.idCardInfoInPage.idNumber = data.cardNum
+					this.idCardFrontBase64 = imgBase64
 					this.frontPassed = true
 				} else if (_ocrType === ocrType.emblem) {
 					this.idCardInfoInPage.issuingAuthority = data.issuingAuthority
 					this.idCardInfoInPage.issuingDate = data.issuingDate
 					this.idCardInfoInPage.expiryDate = data.expiryDate
+					this.idCardBackBase64 = imgBase64
 					this.backPassed = true
 				}
 				my.hideLoading()
@@ -990,13 +989,14 @@
 				this.showTips = false
 				this.isCheckingFace = true
 
+				let succeedImgBase64
 				while (!this.faceCheckSucceed) {
-					// console.log("开始takePhoto进行人脸检测");
+					// console.log("开始takePhoto进行人脸检测", this.faceCheckCam);
 
 					const photo = await this.faceCheckCam.takePhoto({
 						quality: 'normal',
 					})
-					// console.log("完成takePhoto", this.photo.tempImagePath);
+					// console.log("完成takePhoto", photo.tempImagePath);
 					const { data: photoBase64 } = await this.fileSystem.readFile({
 						filePath: photo.tempImagePath,
 						encoding: "base64"
@@ -1012,12 +1012,13 @@
 						// console.log("checkPicRes.data", checkPicRes.data.msg.split("原因:")[1]);
 						this.checkPicTips = checkPicRes.data.msg.split("原因:")[1] + "请将面部完整放入拍摄区域。"
 					} else {
+						succeedImgBase64 = photoBase64
 						this.faceCheckSucceed = checkPicRes.data.success
 					}
 					setTimeout(() => {}, 100)
 				}
 				// 进行云极人证比对
-				await this.afterSuccessCheckPicAlipay(photoBase64)
+				await this.afterSuccessCheckPicAlipay(succeedImgBase64)
 			},
 			async afterSuccessCheckPicAlipay(photoBase64) {
 				if (this.userInfo.skipIdMatching === true) {
@@ -1070,43 +1071,42 @@
 						title: '正在身份核验,请稍后',
 					});
 					let yunjiFaceCheckInfo = {
-						idNo: that.idNumber,
-						name: that.name,
-						image: mybase64,
+						idNo: this.idNumber,
+						name: this.name,
+						image: photoBase64,
 					};
 					let checkRes = await uni.$http.post(
 						'/faceVerification/yunjiVerification',
 						yunjiFaceCheckInfo
 					);
 
-					if (checkRes.data.success === true) {
+					if (checkRes.data.success) {
 						let infoFromIdCard = {}
-						that.infoList.forEach(info => {
-							infoFromIdCard[info] = that.idCardInfoInPage[info]
+						this.infoList.forEach(info => {
+							infoFromIdCard[info] = this.idCardInfoInPage[info]
 						})
 						let currentCheckinInfo = {
-							name: that.name,
-							idNumber: that.idNumber,
-							faceData: mybase64,
-							phone: that.phone,
+							name: this.name,
+							idNumber: this.idNumber,
+							faceData: photoBase64,
+							phone: this.phone,
 							...infoFromIdCard
 						}
 						//更新local storage 中的入住信息
-						let checkinInfoToUpdate = that.checkinInfo
+						let checkinInfoToUpdate = this.checkinInfo
 						checkinInfoToUpdate.push(currentCheckinInfo)
-						that.updateCheckinInfo(checkinInfoToUpdate)
+						this.updateCheckinInfo(checkinInfoToUpdate)
 						//更新local storage 中的身份证信息
-						let idCardInfoToUpdate = that.idCardInfo
-						idCardInfoToUpdate.push(that.idCardInfoInPage)
-						that.updateIdCardInfo(idCardInfoToUpdate)
+						let idCardInfoToUpdate = this.idCardInfo
+						idCardInfoToUpdate.push(this.idCardInfoInPage)
+						this.updateIdCardInfo(idCardInfoToUpdate)
 						//如果上传过照片则更新服务器中的身份证信息
-						if (that.idCardFrontDetectInfo.detected && that.idCardBackDetectInfo
-							.detected) {
+						if (this.frontPassed && this.backPassed) {
 							uni.$http.post('/idCardInfo', {
-								...that.idCardInfoInPage,
-								birthday: that.idCardInfoInPage.birth,
-								idCardFrontBase64: that.idCardFrontPicPath.split(',')[1],
-								idCardBackBase64: that.idCardBackPicPath.split(',')[1]
+								...this.idCardInfoInPage,
+								birthday: this.idCardInfoInPage.birth,
+								idCardFrontBase64: this.idCardFrontBase64,
+								idCardBackBase64: this.idCardBackBase64
 							})
 						}
 						if (this.isMainCustomer) {
@@ -1131,16 +1131,8 @@
 						}), 1000)
 					} else {
 						uni.hideLoading()
-						uni.showModal({
-							content: '身份核验失败,请重试',
-							showCancel: false,
-							success: function(res) {
-								if (res.confirm) {
-									console.log('用户点击确定');
-									that.initData();
-								}
-							},
-						});
+						this.isCheckingFace = false
+						this.checkPicTips = "身份核验失败,请重新进行"
 					}
 				}
 			},
@@ -1554,7 +1546,10 @@
 			const menuButton = await uni.getMenuButtonBoundingClientRect()
 			// 身份证拍照相机top距navBar底部10px
 			this.cardCamTopGap = menuButton.top + menuButton.height + 8 + 10
-			this.navBarHight = menuButton.top + menuButton.height + 8
+
+			const factor = this.screenWidth / 750
+			const tipsHight = 106 * factor
+			this.faceCheckCamTopGap = menuButton.top + menuButton.height + 8 + tipsHight
 
 			this.fileSystem = my.getFileSystemManager();
 			// #endif
@@ -1575,17 +1570,6 @@
 			}
 		},
 		// #endif
-
-		// #ifdef MP-ALIPAY
-		async beforeMount() {
-			let faceAreaTipsSize = await uni.$u.getRect('.face-area--tips')
-			// console.log("faceAreaTipsSize", faceAreaTipsSize);
-			this.faceAreaTipsHeight = faceAreaTipsSize.height
-			let faceAreaLineSize = await uni.$u.getRect('.face-area--line')
-			this.faceAreaLineHeight = faceAreaLineSize.height
-			// console.log("faceAreaLineSize", faceAreaLineSize);
-		}
-		// #endif
 	}
 </script>
 
@@ -1669,7 +1653,14 @@
 			}
 
 			.step-two {
+				display: flex;
+				flex-direction: column;
+				width: 100%;
+				height: 100%;
+
 				.face-area {
+					display: flex;
+					flex-direction: column;
 					background-color: #FFFFFF;
 					border-radius: 50rpx;
 					overflow: hidden;
@@ -1677,6 +1668,7 @@
 					.face-area--tips {
 						display: flex;
 						padding: 10rpx 20rpx;
+						height: 60rpx;
 						align-items: flex-end;
 
 						.face-area--tips--title {
@@ -1695,6 +1687,7 @@
 						border-bottom: solid 6rpx #9e97c3;
 					}
 
+					// #ifdef MP-WEIXIN
 					.camera-container {
 						width: 80%;
 						height: 80vw;
@@ -1711,7 +1704,32 @@
 							// box-sizing: border-box;
 						}
 					}
+					// #endif
+
+					// #ifdef MP-ALIPAY
+					.camera-container {
+						width: 100%;
+						display: flex;
+						align-items: center;
+						justify-content: center;
+						padding-bottom: 30rpx;
+
+						cover-image {
+							margin: 0;
+							padding: 0;
+							position: absolute;
+						}
+					}
 
+					.check-pic-result {
+						width: 100%;
+						padding: 10rpx 20rpx;
+						display: flex;
+						justify-content: center;
+						box-sizing: border-box;
+						color: red;
+					}
+					// #endif
 				}
 
 				.precautions {
@@ -1766,6 +1784,12 @@
 						}
 					}
 				}
+
+				// #ifdef MP-ALIPAY
+				.btn {
+					margin: 20rpx;
+				}
+				// #endif
 			}
 
 			// #ifdef MP-ALIPAY