|
@@ -1,26 +1,29 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <!-- <Transition :enter-active-class="proxy?.animate.mask.enter" :leave-active-class="proxy?.animate.mask.leave">
|
|
|
+ <Transition :enter-active-class="proxy?.animate.mask.enter" :leave-active-class="proxy?.animate.mask.leave">
|
|
|
<div class="mask" v-show="faceState"></div>
|
|
|
- </Transition> -->
|
|
|
- <Transition :enter-active-class="proxy?.animate.face.enter" :leave-active-class="proxy?.animate.face.leave">
|
|
|
+ </Transition>
|
|
|
+ <Transition :enter-active-class="proxy?.animate.rankingWindow.enter"
|
|
|
+ :leave-active-class="proxy?.animate.rankingWindow.leave">
|
|
|
<div class="confirmDiaBg" v-show="faceState">
|
|
|
- <div class="confirmDiaWindow">
|
|
|
- <div class="confirmDiaWindow-con">
|
|
|
- <div class="pic" :class="{ 'pic2': faceCheckStu.student_id }" v-if="faceCheckStu.student_id"> <img
|
|
|
- :src="faceCheckStu.student_icon" /></div>
|
|
|
- <div class="pic" v-else>
|
|
|
- <div class="shine">
|
|
|
- <img src="@/assets/images/common/shine.png" />
|
|
|
+ <div>
|
|
|
+ <div class="confirmDiaWindow">
|
|
|
+ <div class="confirmDiaWindow-con">
|
|
|
+ <div class="pic" :class="{ 'pic2': faceCheckStu.student_id }" v-if="faceCheckStu.student_id"> <img
|
|
|
+ :src="faceCheckStu.student_icon" /></div>
|
|
|
+ <div class="pic" v-else>
|
|
|
+ <div class="shine">
|
|
|
+ <img src="@/assets/images/common/shine.png" />
|
|
|
+ </div>
|
|
|
+ <img src="@/assets/images/test/profilePicture.png" />
|
|
|
+ </div>
|
|
|
+ <div class="name" :class="{ 'name2': faceCheckStu.student_id }">
|
|
|
+ 请看摄像头进行人脸识别
|
|
|
</div>
|
|
|
- <img src="@/assets/images/test/profilePicture.png" />
|
|
|
- </div>
|
|
|
- <div class="name" :class="{ 'name2': faceCheckStu.student_id }">
|
|
|
- 请看摄像头进行人脸识别
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div @click="getCloseFace" class="close"></div>
|
|
|
</div>
|
|
|
- <div @click="getCloseFace">关闭</div>
|
|
|
</div>
|
|
|
</Transition>
|
|
|
</div>
|
|
@@ -28,79 +31,108 @@
|
|
|
</template>
|
|
|
<script setup lang="ts">
|
|
|
import { useWebSocket } from '@/utils/faceWs';
|
|
|
-const { faceWs, startDevice, checkFace, openFace, terminateFace, suspendFace, resumeFace, getFace } = useWebSocket();
|
|
|
const { proxy } = getCurrentInstance() as any;
|
|
|
+const router = useRouter();
|
|
|
+const { faceWs, startDevice, checkFace, openFace, terminateFace, suspendFace, resumeFace, getFaceState } = useWebSocket();
|
|
|
|
|
|
const data = reactive<any>({
|
|
|
- faceCheckStu: {},
|
|
|
+ faceCheckStu: {},//人脸信息
|
|
|
faceState: false,//人脸识别窗口状态
|
|
|
direction: "",//动画方向
|
|
|
parameter: {},//参数
|
|
|
- deviceInfo: {},
|
|
|
+ deviceInfo: {},//设备信息
|
|
|
});
|
|
|
|
|
|
const { faceCheckStu, faceState, direction, parameter, deviceInfo } = toRefs(data);
|
|
|
|
|
|
onBeforeMount(() => {
|
|
|
- //加载手势WS
|
|
|
+})
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+})
|
|
|
+
|
|
|
+/**
|
|
|
+ * 初始化
|
|
|
+ */
|
|
|
+const getInit = async () => {
|
|
|
faceWs((e: any) => {
|
|
|
if (e?.wksid) {
|
|
|
//获取设备信息
|
|
|
getDevice();
|
|
|
}
|
|
|
-
|
|
|
- //接收设备信息
|
|
|
+ //接收设备信息并发送请求
|
|
|
if (e?.device_info) {
|
|
|
deviceInfo.value = e.device_info;
|
|
|
+ getCheckFace();
|
|
|
+ }
|
|
|
+ if (e?.cmd == 'check_facecontroller_available') {
|
|
|
+ let handcontroller_id = deviceInfo.value.handcontroller_id;
|
|
|
+ if (e?.code != 0) {
|
|
|
+ proxy?.$modal.msgError(`人脸识别模块不可用`);
|
|
|
+ } else {
|
|
|
+ //查看人脸识别状态,如果不处于关闭就先关闭再重新启动(可能会APP退出然后工作站还在运行的可能性)
|
|
|
+ getFaceState(handcontroller_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (e?.cmd == 'get_facecontroller_state') {
|
|
|
let handcontroller_id = deviceInfo.value.handcontroller_id;
|
|
|
- getCheckGrades();
|
|
|
- openFace();
|
|
|
+ //state说明: 0:关闭,3:空闲,36:工作中
|
|
|
+ if ([3, 36].includes(e.state)) {
|
|
|
+ terminateFace(handcontroller_id);
|
|
|
+ proxy?.$modal.msgWarning(`请重新人脸识别`);
|
|
|
+ } else {
|
|
|
+ openFace(handcontroller_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (e?.data) {
|
|
|
+ //返回人脸信息然后跳转
|
|
|
+ let id = e.data.student_id;
|
|
|
+ let name = e.data.student_name;
|
|
|
+ let pic = e.data.student_icon;
|
|
|
+ if (!id) {
|
|
|
+ proxy?.$modal.msgWarning(`缺少参数`);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let obj = { id, name, pic }
|
|
|
+ router.push({ path: '/score', query: obj });
|
|
|
}
|
|
|
});
|
|
|
-})
|
|
|
+};
|
|
|
|
|
|
/**
|
|
|
* 获取设备信息
|
|
|
*/
|
|
|
const getDevice = async () => {
|
|
|
let deviceid = localStorage.getItem('deviceid') || '';
|
|
|
- if (deviceid) {
|
|
|
- startDevice({ deviceid: deviceid });
|
|
|
- } else {
|
|
|
- proxy?.$modal.msgError(`缺少设备信息请重新登录!`);
|
|
|
- await proxy?.$http.common.logout({}).then((res: any) => { });
|
|
|
- proxy?.$modal?.closeLoading();
|
|
|
- //清空缓存
|
|
|
- // localStorage.clear();
|
|
|
- localStorage.removeItem('token');
|
|
|
- localStorage.removeItem('userInfo');
|
|
|
- //跳转
|
|
|
- router.push({ path: '/login/qrcode' });
|
|
|
+ if (!deviceid) {
|
|
|
+ proxy?.$modal.msgError(`请重新登录绑定设备号后使用`);
|
|
|
+ return false;
|
|
|
}
|
|
|
+ startDevice({ deviceid: deviceid });
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 查成绩
|
|
|
*/
|
|
|
-const getCheckGrades = () => {
|
|
|
- const deviceid: any = localStorage.getItem('deviceid');
|
|
|
- if (!deviceid) {
|
|
|
- proxy?.$modal.msgWarning('没有设备号,请重新登录');
|
|
|
- return false;
|
|
|
- }
|
|
|
+const getCheckFace = () => {
|
|
|
let handcontroller_id = deviceInfo.value.handcontroller_id;
|
|
|
- checkFace(handcontroller_id)
|
|
|
+ //检查是否支持人脸识别
|
|
|
+ checkFace(handcontroller_id);
|
|
|
};
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 关闭人脸识别
|
|
|
*/
|
|
|
const getCloseFace = () => {
|
|
|
let handcontroller_id = deviceInfo.value.handcontroller_id;
|
|
|
- closeFace(handcontroller_id)
|
|
|
+ terminateFace(handcontroller_id);
|
|
|
+ faceState.value = false;
|
|
|
};
|
|
|
|
|
|
+//暴露给父组件用
|
|
|
+defineExpose({
|
|
|
+ getInit
|
|
|
+})
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
.mask {
|
|
@@ -109,7 +141,7 @@ const getCloseFace = () => {
|
|
|
width: 100vw;
|
|
|
top: 0;
|
|
|
left: 0;
|
|
|
- background: rgba(0, 0, 0, 0.3);
|
|
|
+ background: rgba(0, 0, 0, 0.8);
|
|
|
z-index: 998;
|
|
|
}
|
|
|
|
|
@@ -125,8 +157,8 @@ const getCloseFace = () => {
|
|
|
z-index: 999;
|
|
|
|
|
|
.confirmDiaWindow {
|
|
|
- width: 23.5%;
|
|
|
- height: 43.4%;
|
|
|
+ width: 30vh;
|
|
|
+ height: 43vh;
|
|
|
border-radius: 1.6rem;
|
|
|
opacity: 1;
|
|
|
background: radial-gradient(122% 126% at 97% 6%, #35FFC6 0%, #00FFE8 100%);
|
|
@@ -134,12 +166,12 @@ const getCloseFace = () => {
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
|
- position: fixed;
|
|
|
+ margin-bottom: 20px;
|
|
|
|
|
|
.confirmDiaWindow-con {
|
|
|
.pic {
|
|
|
- width: 22.3vh;
|
|
|
- height: 22.3vh;
|
|
|
+ width: 25vh;
|
|
|
+ height: 25vh;
|
|
|
border-radius: 50%;
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
@@ -153,7 +185,7 @@ const getCloseFace = () => {
|
|
|
left: -5vh;
|
|
|
top: 0;
|
|
|
width: 5vh;
|
|
|
- height: 22.3vh;
|
|
|
+ height: 25vh;
|
|
|
animation: shineani 3s infinite;
|
|
|
-webkit-animation: shineani 3s infinite;
|
|
|
z-index: 1;
|
|
@@ -177,7 +209,7 @@ const getCloseFace = () => {
|
|
|
.name {
|
|
|
width: 100%;
|
|
|
color: #1A293A;
|
|
|
- font-size: 1.9rem;
|
|
|
+ font-size: 2.5vh;
|
|
|
}
|
|
|
|
|
|
.name2 {
|
|
@@ -188,6 +220,10 @@ const getCloseFace = () => {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ .close {
|
|
|
+ margin: 0 auto;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@keyframes shineani {
|