Browse Source

修复bug

chenxiong 3 years ago
parent
commit
f78c9d0ce6

+ 15 - 0
common/httpList/course.js

@@ -120,6 +120,21 @@ export default {
 			data:data
 		})
 	},
+	faceCertificationIDCardOCR(data) {
+		return myRequest({
+			url: '/face/certification/IDCardOCR',
+			method: 'post',
+			data:data
+		})
+	},
+	
+	faceCertificationCompareFace(data) {
+		return myRequest({
+			url: '/face/certification/CompareFace',
+			method: 'post',
+			data:data
+		})
+	},
 	
 	
 	

+ 3 - 0
common/methodTool.js

@@ -132,6 +132,7 @@ export default {
 							height: '35%',
 							success:async rest => {
 								const waitUpload = await self.uploadFile(rest.tempFilePath, 0);
+						console.log(waitUpload,'waitUpload')
 								resolve(waitUpload);
 							}
 						});
@@ -143,11 +144,13 @@ export default {
 							height: '50%',
 							success: async rest => {
 								const waitUpload = await self.uploadFile(rest.tempFilePath, 0);
+						console.log(waitUpload,'waitUpload')
 								resolve(waitUpload);
 							}
 						});
 					} else {
 						const waitUpload = await self.uploadFile(url, 0);
+						console.log(waitUpload,'waitUpload')
 						resolve(waitUpload);
 						// console.log('无需压缩', url);
 						// resolve(url);

+ 2 - 2
components/course/courseChapter.vue

@@ -215,12 +215,12 @@ export default {
 					let chapterTrue = rows[i].chapterId == chapterId;
 					if(moduleTrue && chapterTrue) {
 						isStop = true;
-						if(rows[i].sectionType != 2) {
+						if(rows[i].sectionType != 2) {//忽略直播
 							newRows.push(rows[i])
 						}
 					} else {
 						if(!isStop) {
-							if(rows[i].sectionType != 2) {
+							if(rows[i].sectionType != 2) { //忽略直播
 								newRows.push(rows[i])
 							}
 							

+ 48 - 3
pages2/class/questionBank.vue

@@ -813,10 +813,55 @@ export default {
 				});
 			});
 		},
+		/**
+		 * 人脸匹配
+		 */
+		faceRecognition() {
+			return new Promise(resolve => {
+				let fileSystem = uni.getFileSystemManager();
+				fileSystem.readFile({
+				  filePath: `${this.avatarUrl}`,
+				  encoding: 'base64',
+				  position: 0,
+				  success:(res) => {
+					  console.log(res)
+					  let base64 = 'data:image/jpg;base64,' + res.data;
+					  
+					  this.$api.faceCertificationCompareFace({
+						  imageA:base64,
+						  orderGoodsId:this.orderGoodsId,
+						  gradeId:this.gradeId
+					  }).then(res => {
+						  resolve(res.data.data)
+					  })
+				  },
+				  fail(err) {
+					console.error(err,'err')
+				  }
+				})
+			})
+		},
 		async submitPhoto() {
-			const waitYS = await this.imageInfos();
-			this.postStudyRecord(); //提交记录
-			this.photoPopup = false;
+			let compareFaceData = await this.faceRecognition();
+			
+			if(compareFaceData == 0) {
+				uni.showToast({
+				  title:'人脸匹配不通过,请重新拍照上传',
+				  icon:'none',
+				  duration:2000,
+				})
+				
+				this.uploadLock = false;
+				this.openPhoto();
+				return;
+			}
+			
+			if(compareFaceData >= 80) {
+				
+				const waitYS = await this.imageInfos();
+				this.postStudyRecord(); //提交记录
+				this.photoPopup = false;
+			}
 		},
 		//确认拍照
 		takePhoto() {

+ 67 - 6
pages2/verify/input.vue

@@ -170,6 +170,15 @@
 							<u-upload
 								:show-progress="false"
 								:max-size="2097152"
+								:ref="
+									item.fieldKey === 'recent_photos'
+										? 'recent_photos'
+										: item.fieldKey === 'idcard_face_photo'
+										? 'idcard_face_photo'
+										: item.fieldKey === 'idcard_national_photo'
+										? 'idcard_national_photo'
+										: ''
+								"
 								@on-list-change="
 									item.fieldKey === 'recent_photos'
 										? changePhotoListHeader1($event)
@@ -302,6 +311,7 @@ import Handwriting from '@/common/signature.js';
 export default {
 	data() {
 		return {
+			gradeId:0,
 			errorType: ['message'],
 			agreementModal:true,
 			goodsData:{},
@@ -509,6 +519,7 @@ export default {
 	async onLoad(option) {
 		this.orderGoodsId = Number(option.orderGoodsId)
 		this.goodsId = Number(option.id);
+		this.gradeId = Number(option.gradeId)
 		await this.getGoodsDetail()
 		this.getInfo();
 	},
@@ -742,6 +753,32 @@ export default {
 			this.openVerify = true;
 			this.resultForm(1);
 		},
+		faceCertificationIDCardOCR(cardSide,url) {
+			return new Promise(resolve => {
+				let fileSystem = uni.getFileSystemManager();
+				fileSystem.readFile({
+				  filePath: url,
+				  encoding: 'base64',
+				  position: 0,
+				  success:(res) => {
+					  console.log(res)
+					  let base64 = 'data:image/jpg;base64,' + res.data;
+					  console.log(base64)
+					  this.$api.faceCertificationIDCardOCR({
+					  	cardSide:cardSide,  //1人像  2 国徽
+					  	cardImageBase64:base64,
+					  	gradeId:this.gradeId
+					  }).then(res => {
+					  	resolve(res)
+					  })
+				  },
+				  fail(err) {
+					console.error(err,'err')
+				  }
+				})
+				
+			})
+		},
 		async changePhotoListHeader1(lists, name) {
 			console.log(lists)
 			if (lists.length) {
@@ -761,12 +798,24 @@ export default {
 			});
 		},
 		async changePhotoListHeader2(lists, name) {
-			console.log(lists)
 			if (lists.length) {
 				this.fileList2 = lists;
-				console.log(lists,'lists2')
 				if (lists[0].url.indexOf('//tmp') !== -1 || lists[0].url.indexOf('//temp') !== -1) {
-					this.$set(this.form, 'idcard_face_photo', await this.$method.imageInfos(lists[0].url));
+					let url = lists[0].url
+					this.$refs.idcard_face_photo[0].remove(0)
+					let res = await this.faceCertificationIDCardOCR(1,url);
+					
+					if(res.data.code == 500) {
+						uni.showToast({
+							icon:'none',
+							title:'请上传正确清晰的身份证人像面照片'
+						})
+						return;
+					}
+					this.$refs.idcard_face_photo[0].lists = [{
+						url:this.$method.splitImgHost(res.data.data.IdImgPath)
+					}]; 
+					this.$set(this.form, 'idcard_face_photo', res.data.data.IdImgPath,1000);
 				}
 			} else {
 				this.fileList2 = [];
@@ -777,12 +826,24 @@ export default {
 			});
 		},
 		async changePhotoListHeader3(lists, name) {
-			console.log(lists)
 			if (lists.length) {
 				this.fileList3 = lists;
-				console.log(lists,'lists3')
 				if (lists[0].url.indexOf('//tmp') !== -1 || lists[0].url.indexOf('//temp') !== -1) {
-					this.$set(this.form, 'idcard_national_photo', await this.$method.imageInfos(lists[0].url));
+					console.log('//tem')
+					let url = lists[0].url
+					this.$refs.idcard_national_photo[0].remove(0)
+					let res = await this.faceCertificationIDCardOCR(2,url);
+					if(res.data.code == 500) {
+						uni.showToast({
+							icon:'none',
+							title:'请上传正确清晰的身份证国徽面照片'
+						})
+						return;
+					}
+					this.$refs.idcard_national_photo[0].lists = [{
+						url:this.$method.splitImgHost(res.data.data.IdImgPath)
+					}]; 
+					this.$set(this.form, 'idcard_national_photo', this.$method.splitImgHost(res.data.data.IdImgPath,1000));
 				}
 			} else {
 				this.fileList3 = [];

+ 55 - 25
pages3/polyv/detail.vue

@@ -383,7 +383,8 @@ export default {
 														if (resultst.confirm) {
 															self.$navTo.togo('/pages2/verify/input', {
 																id: self.goodsId,
-																orderGoodsId:self.orderGoodsId
+																orderGoodsId:self.orderGoodsId,
+																gradeId:self.gradeId
 															});
 														}
 														if (resultst.cancel) {
@@ -400,7 +401,8 @@ export default {
 														if (resultst.confirm) {
 															self.$navTo.togo('/pages2/verify/input', {
 																id: self.goodsId,
-																orderGoodsId:self.orderGoodsId
+																orderGoodsId:self.orderGoodsId,
+																gradeId:self.gradeId
 															});
 														}
 														if (resultst.cancel) {
@@ -423,7 +425,8 @@ export default {
 																	if (resultst.confirm) {
 																		self.$navTo.togo('/pages2/verify/input2', {
 																			id: self.goodsId,
-																			orderGoodsId:self.orderGoodsId
+																			orderGoodsId:self.orderGoodsId,
+																			gradeId:self.gradeId
 																		});
 																	}
 																	if (resultst.cancel) {
@@ -440,7 +443,8 @@ export default {
 																	if (resultst.confirm) {
 																		self.$navTo.togo('/pages2/verify/input2', {
 																			id: self.goodsId,
-																			orderGoodsId:self.orderGoodsId
+																			orderGoodsId:self.orderGoodsId,
+																			gradeId:self.gradeId
 																		});
 																	}
 																	if (resultst.cancel) {
@@ -1526,6 +1530,14 @@ export default {
 				  success:(res) => {
 					  console.log(res)
 					  let base64 = 'data:image/jpg;base64,' + res.data;
+					  
+					  this.$api.faceCertificationCompareFace({
+						  imageA:base64,
+						  orderGoodsId:this.orderGoodsId,
+						  gradeId:this.gradeId
+					  }).then(res => {
+						  resolve(res.data.data)
+					  })
 				  },
 				  fail(err) {
 					console.error(err,'err')
@@ -1540,30 +1552,48 @@ export default {
 			}
 			this.uploadLock = true;
 			
-			const waitYS = await this.imageInfos();
-			this.postCoursePhotoRecord().then(res => {
-				this.photoHistoryList.push(this.photoIndex)
-				this.postStudyRecord(); //提交记录
-				//恢复播放
-				
-				uni.setKeepScreenOn({
-				    keepScreenOn: false
-				});
-				this.photoPopup = false;
-				this.uploadLock = false;
-				this.enableAutoRotation = true;
-				var polyvPlayerContext = this.selectComponent('#playerVideo');
-				if (polyvPlayerContext != null) {
-					polyvPlayerContext.play();
-				}
-			}).catch(err => {
+			let compareFaceData = await this.faceRecognition();
+			
+			if(compareFaceData == 0) {
 				uni.showToast({
-					title: '上传接口报错,请重新拍照上传' + err,
-					icon: 'none'
-				});
+				  title:'人脸匹配不通过,请重新拍照上传',
+				  icon:'none',
+				  duration:2000,
+				})
+				
 				this.uploadLock = false;
 				this.openPhoto();
-			})
+				return;
+			}
+			
+			if(compareFaceData >= 80) {
+				const waitYS = await this.imageInfos();
+				this.postCoursePhotoRecord().then(res => {
+					this.photoHistoryList.push(this.photoIndex)
+					this.postStudyRecord(); //提交记录
+					//恢复播放
+					
+					uni.setKeepScreenOn({
+					    keepScreenOn: false
+					});
+					this.photoPopup = false;
+					this.uploadLock = false;
+					this.enableAutoRotation = true;
+					var polyvPlayerContext = this.selectComponent('#playerVideo');
+					if (polyvPlayerContext != null) {
+						polyvPlayerContext.play();
+					}
+				}).catch(err => {
+					uni.showToast({
+						title: '上传接口报错,请重新拍照上传' + err,
+						icon: 'none'
+					});
+					this.uploadLock = false;
+					this.openPhoto();
+				})
+			}
+			
+			
 				
 			
 		},