This commit is contained in:
shijing 2022-04-22 15:34:57 +08:00
parent c76a039bbb
commit 20654838fe
3 changed files with 21 additions and 19 deletions

View File

@ -1,11 +1,11 @@
<template> <template>
<div class="faceLoginWrap"> <div class="faceLoginWrap">
<div style="height: 500px;"> <div style="height:fit-content;">
<div class="video-box"> <div class="video-box">
<video id="video" width="500" height="500" preload autoplay loop muted></video> <video id="video" width="600" preload autoplay muted></video>
<canvas id="canvas" width="500" height="500"></canvas> <canvas id="canvas" width="600" height="500"></canvas>
</div> </div>
<canvas id="screenshotCanvas" width="500" height="500"></canvas> <canvas id="screenshotCanvas" width="600" height="500"></canvas>
</div> </div>
</div> </div>
</template> </template>
@ -118,22 +118,20 @@
ctx.drawImage(video, 0, 0, canvas.width, canvas.height); ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
let base64Img = canvas.toDataURL('image/jpeg'); let base64Img = canvas.toDataURL('image/jpeg');
let img = base64Img.split(',')[1]; let img = base64Img.split(',')[1];
let imgData = {base64: img}; let imgData = {base64: img,tolerance:0.42};
clockRecord(imgData).then((res) => { clockRecord(imgData).then((res) => {
debugger;
if (res.code === 200 && res.data.id) { if (res.code === 200 && res.data.id) {
this.$message.success(res.data.name + '签到成功!'); this.$message.success(res.data.name + '签到成功!');
setTimeout(() => { setTimeout(() => {
that.uploadLock = false; that.uploadLock = false;
}, 3000) }, 5000)
} else { } else {
// 打开锁
that.uploadLock = false; that.uploadLock = false;
this.$message.error(res.msg);
} }
}).catch(() => { }).catch(() => {
// 打开锁 // 打开锁
that.uploadLock = false; that.uploadLock = false;
// this.$message.error('面部识别失败请重新验证');
}); });
}, },
closeCamera() { closeCamera() {
@ -157,8 +155,8 @@
} }
.video-box { .video-box {
width: 500px; width: 600px;
height: 500px; height: fit-content;
margin: auto; margin: auto;
position: relative; position: relative;
} }
@ -176,4 +174,3 @@
left: 0; left: 0;
} }
</style> </style>

View File

@ -80,12 +80,16 @@ service.interceptors.response.use(
} }
} else if (res.code >= 400) { } else if (res.code >= 400) {
Message({ if(res.msg.indexOf('请调整位置')>-1){
message: res.msg || '请求出错', return;
type: 'error', }else{
duration: 3 * 1000 Message({
}) message: res.msg || '请求出错',
return Promise.reject(new Error(res.msg || '请求出错')) type: 'error',
duration: 3 * 1000
})
return Promise.reject(new Error(res.msg || '请求出错'))
}
} }
}, },
error => { error => {

View File

@ -77,6 +77,7 @@
import faceLogin from '@/components/faceLogin/tracking.vue' import faceLogin from '@/components/faceLogin/tracking.vue'
export default { export default {
name: "Login", name: "Login",
inject:['reload'],
components:{ components:{
faceLogin faceLogin
}, },
@ -182,11 +183,11 @@
//人脸登录 //人脸登录
takePhoto(){ takePhoto(){
this.limitedPhoto = true; this.limitedPhoto = true;
this.openTheCamera();
}, },
/*关闭相机*/ /*关闭相机*/
closeCamera () { closeCamera () {
debugger; debugger;
this.reload();
this.$refs.faceTracking.closeCamera(); this.$refs.faceTracking.closeCamera();
// this.thisVideo.srcObject.getTracks()[0].stop(); // this.thisVideo.srcObject.getTracks()[0].stop();
}, },