|
@@ -20,7 +20,6 @@
|
|
:
|
|
:
|
|
examState ==
|
|
examState ==
|
|
43 ? "停止人脸识别" : examState == 42 ? "正在测试" : "请初始化" }})</div>
|
|
43 ? "停止人脸识别" : examState == 42 ? "正在测试" : "请初始化" }})</div>
|
|
- <!-- <div @click="getProcess">走一套流程</div> -->
|
|
|
|
<div @click="getChooseStudent" v-if="examState == 41 || (examState == 43 && !faceCheckStu.student_id)">2、选择学生</div>
|
|
<div @click="getChooseStudent" v-if="examState == 41 || (examState == 43 && !faceCheckStu.student_id)">2、选择学生</div>
|
|
<div @click="getRetestFace" v-if="examState == 43 || examState == 42">4、重新识别</div>
|
|
<div @click="getRetestFace" v-if="examState == 43 || examState == 42">4、重新识别</div>
|
|
<div v-if="needStart">
|
|
<div v-if="needStart">
|
|
@@ -37,7 +36,7 @@
|
|
|
|
|
|
<script setup name="TrainTest" lang="ts">
|
|
<script setup name="TrainTest" lang="ts">
|
|
import { initSpeech, speckText, speckCancel, chineseNumber } from '@/utils/speech'
|
|
import { initSpeech, speckText, speckCancel, chineseNumber } from '@/utils/speech'
|
|
-import { initWs, examEnds, openOneTest, startFace, stopFace, faceConfirmOnly, startOneTest, finishOneTest, closeOneTest, suspendFaceRecognitionChannels, resumeFaceRecognitionChannels } from '@/utils/ws'
|
|
|
|
|
|
+import { initWs, examEnds, openOneTest, startFace, stopFace, faceConfirmOnly, startOneTest, finishOneTest, closeOneTest, getNetWork, suspendFaceRecognitionChannels, resumeFaceRecognitionChannels } from '@/utils/ws'
|
|
import dataDictionary from "@/utils/dataDictionary"
|
|
import dataDictionary from "@/utils/dataDictionary"
|
|
const { proxy } = getCurrentInstance() as any;
|
|
const { proxy } = getCurrentInstance() as any;
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
@@ -47,8 +46,10 @@ const chooseStudentRef = ref();
|
|
const data = reactive<any>({
|
|
const data = reactive<any>({
|
|
timerManager: {},//计时器管理
|
|
timerManager: {},//计时器管理
|
|
parameter: {},//参数
|
|
parameter: {},//参数
|
|
- testTime: 60,//时长
|
|
|
|
- countdownNum: 0,//计时
|
|
|
|
|
|
+ time: {
|
|
|
|
+ testTime: 60,//时长
|
|
|
|
+ countdownNum: 0,//计时
|
|
|
|
+ },
|
|
userInfo: {},//用户信息
|
|
userInfo: {},//用户信息
|
|
examState: 0,//当前状态
|
|
examState: 0,//当前状态
|
|
resultId: null,//测试ID
|
|
resultId: null,//测试ID
|
|
@@ -58,7 +59,7 @@ const data = reactive<any>({
|
|
backReason: [],//犯规项
|
|
backReason: [],//犯规项
|
|
needStart: false,//是否需要按钮
|
|
needStart: false,//是否需要按钮
|
|
});
|
|
});
|
|
-const { timerManager, parameter, testTime, countdownNum, userInfo, examState, resultId, currentResultObj, unit, faceCheckStu, backReason, needStart } = toRefs(data);
|
|
|
|
|
|
+const { timerManager, parameter, time, userInfo, examState, resultId, currentResultObj, unit, faceCheckStu, backReason, needStart } = toRefs(data);
|
|
|
|
|
|
/**
|
|
/**
|
|
* 接收消息
|
|
* 接收消息
|
|
@@ -95,6 +96,9 @@ const getMessage = (e: any) => {
|
|
}
|
|
}
|
|
//断线状态
|
|
//断线状态
|
|
if (e.cmd === 'disconnect_request') {
|
|
if (e.cmd === 'disconnect_request') {
|
|
|
|
+ if (e.data.message) {
|
|
|
|
+ speckText(e.data.message);
|
|
|
|
+ }
|
|
getExit();
|
|
getExit();
|
|
}
|
|
}
|
|
//状态变更
|
|
//状态变更
|
|
@@ -107,7 +111,7 @@ const getMessage = (e: any) => {
|
|
cleanData();
|
|
cleanData();
|
|
}
|
|
}
|
|
if (e.data == 41) {
|
|
if (e.data == 41) {
|
|
- getFaceWindow();
|
|
|
|
|
|
+ getFaceWindow(true);
|
|
}
|
|
}
|
|
if (e.data == 43) {
|
|
if (e.data == 43) {
|
|
|
|
|
|
@@ -141,25 +145,6 @@ const getMessage = (e: any) => {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
-// /**
|
|
|
|
-// * 正常流程
|
|
|
|
-// */
|
|
|
|
-// const getProcess = () => {
|
|
|
|
-// if (examState.value == 3) {
|
|
|
|
-// openOneTest();
|
|
|
|
-// }
|
|
|
|
-// if (examState.value == 40) {
|
|
|
|
-// startFace();
|
|
|
|
-// }
|
|
|
|
-// if (examState.value == 41) {
|
|
|
|
-// getStopFace();
|
|
|
|
-// }
|
|
|
|
-// if (examState.value == 43) {
|
|
|
|
-// getStartOneTest();
|
|
|
|
-// }
|
|
|
|
-// };
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 开始识别
|
|
* 开始识别
|
|
*/
|
|
*/
|
|
@@ -169,8 +154,7 @@ const getOpenOneTestAndStartFace = () => {
|
|
}
|
|
}
|
|
timerManager.value.startFace = setInterval(() => {
|
|
timerManager.value.startFace = setInterval(() => {
|
|
if (examState.value == 40) {
|
|
if (examState.value == 40) {
|
|
- clearInterval(timerManager.value.startFace)
|
|
|
|
- timerManager.value.startFace = null;
|
|
|
|
|
|
+ getClearTimer("startFace");
|
|
startFace();
|
|
startFace();
|
|
}
|
|
}
|
|
}, 250);
|
|
}, 250);
|
|
@@ -195,7 +179,7 @@ const getFaceConfirmOnly = () => {
|
|
student_id: faceCheckStu.value.student_id,
|
|
student_id: faceCheckStu.value.student_id,
|
|
gender: faceCheckStu.value.gender
|
|
gender: faceCheckStu.value.gender
|
|
}, () => {
|
|
}, () => {
|
|
- faceWindowRef?.value.close();
|
|
|
|
|
|
+ faceWindowRef.value?.close();
|
|
//不需要按钮的自动进入下一步
|
|
//不需要按钮的自动进入下一步
|
|
if (needStart.value == false) {
|
|
if (needStart.value == false) {
|
|
getStartOneTest();
|
|
getStartOneTest();
|
|
@@ -232,8 +216,14 @@ const getStartOneTest = () => {
|
|
startOneTest(() => {
|
|
startOneTest(() => {
|
|
//计时项目才开
|
|
//计时项目才开
|
|
if (needStart.value == true) {
|
|
if (needStart.value == true) {
|
|
- getCountdown();
|
|
|
|
|
|
+ //时间为0的为正计时,大于0的为倒计时
|
|
|
|
+ if (time.value.testTime == 0) {
|
|
|
|
+ getCounting("+");
|
|
|
|
+ } else {
|
|
|
|
+ getCounting("-");
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
|
|
+ speckCancel()//停止播报;
|
|
speckText(faceCheckStu.value.name + ",请开始测试");
|
|
speckText(faceCheckStu.value.name + ",请开始测试");
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -268,8 +258,7 @@ const getRetest = () => {
|
|
faceCheckStu.value = student;
|
|
faceCheckStu.value = student;
|
|
getFaceConfirmOnly();
|
|
getFaceConfirmOnly();
|
|
//停止自动执行
|
|
//停止自动执行
|
|
- clearInterval(timerManager.value.retest)
|
|
|
|
- timerManager.value.retest = null;
|
|
|
|
|
|
+ getClearTimer("retest");
|
|
}
|
|
}
|
|
}, 250);
|
|
}, 250);
|
|
};
|
|
};
|
|
@@ -297,11 +286,18 @@ const getExit = () => {
|
|
/**
|
|
/**
|
|
* 清空定时任务
|
|
* 清空定时任务
|
|
*/
|
|
*/
|
|
-const getClearTimer = () => {
|
|
|
|
- for (let key in timerManager.value) {
|
|
|
|
- if (timerManager.value.hasOwnProperty(key)) {
|
|
|
|
- clearInterval(timerManager.value[key])
|
|
|
|
- timerManager.value[key] = null;
|
|
|
|
|
|
+const getClearTimer = (data?: any) => {
|
|
|
|
+ if (data) {
|
|
|
|
+ //清除指定
|
|
|
|
+ clearInterval(timerManager.value[data])
|
|
|
|
+ timerManager.value[data] = null;
|
|
|
|
+ } else {
|
|
|
|
+ //清除全部
|
|
|
|
+ for (let key in timerManager.value) {
|
|
|
|
+ if (timerManager.value.hasOwnProperty(key)) {
|
|
|
|
+ clearInterval(timerManager.value[key])
|
|
|
|
+ timerManager.value[key] = null;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -328,7 +324,7 @@ const returnStudent = (data: any) => {
|
|
* 清除历史记录
|
|
* 清除历史记录
|
|
*/
|
|
*/
|
|
const cleanData = () => {
|
|
const cleanData = () => {
|
|
- countdownNum.value = testTime.value;
|
|
|
|
|
|
+ time.value.countdownNum = time.value.testTime;
|
|
faceCheckStu.value = {};
|
|
faceCheckStu.value = {};
|
|
currentResultObj.value = {};
|
|
currentResultObj.value = {};
|
|
backReason.value = [];
|
|
backReason.value = [];
|
|
@@ -339,10 +335,11 @@ const cleanData = () => {
|
|
*/
|
|
*/
|
|
const initProject = () => {
|
|
const initProject = () => {
|
|
//停止计时
|
|
//停止计时
|
|
- getStopCountdown();
|
|
|
|
|
|
+ getClearTimer("countdownTimer");
|
|
//自动项目定时进入下一步
|
|
//自动项目定时进入下一步
|
|
if (needStart.value == false) {
|
|
if (needStart.value == false) {
|
|
let time = 0;
|
|
let time = 0;
|
|
|
|
+ //控制新建测试的时间,第一次快,之后就慢
|
|
if (!faceCheckStu.value.student_id) {
|
|
if (!faceCheckStu.value.student_id) {
|
|
time = 1000;
|
|
time = 1000;
|
|
} else {
|
|
} else {
|
|
@@ -361,44 +358,52 @@ const initProject = () => {
|
|
* 时间转换
|
|
* 时间转换
|
|
*/
|
|
*/
|
|
const countdownNumFormat = computed(() => {
|
|
const countdownNumFormat = computed(() => {
|
|
- return proxy?.$utils.timeFormat(countdownNum.value);
|
|
|
|
|
|
+ return proxy?.$utils.timeFormat(time.value.countdownNum);
|
|
});
|
|
});
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 计时
|
|
|
|
|
|
+ * 倒计时
|
|
*/
|
|
*/
|
|
-const getCountdown = () => {
|
|
|
|
|
|
+const getCounting = (type: string) => {
|
|
timerManager.value.countdownTimer = setInterval(() => {
|
|
timerManager.value.countdownTimer = setInterval(() => {
|
|
- if (countdownNum.value <= 0) {
|
|
|
|
- getStopCountdown();
|
|
|
|
- } else {
|
|
|
|
- countdownNum.value--;
|
|
|
|
|
|
+ //正计时
|
|
|
|
+ if (type == "+") {
|
|
|
|
+ time.value.countdownNum++;
|
|
|
|
+ }
|
|
|
|
+ //倒计时
|
|
|
|
+ if (type == "-") {
|
|
|
|
+ if (time.value.countdownNum <= 0) {
|
|
|
|
+ getClearTimer("countdownTimer");
|
|
|
|
+ } else {
|
|
|
|
+ time.value.countdownNum--;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}, 1000);
|
|
}, 1000);
|
|
};
|
|
};
|
|
|
|
|
|
-/**
|
|
|
|
- * 停止计时
|
|
|
|
-*/
|
|
|
|
-const getStopCountdown = () => {
|
|
|
|
- clearInterval(timerManager.value.countdownTimer);
|
|
|
|
- timerManager.value.countdownTimer = null;
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 人脸窗口
|
|
* 人脸窗口
|
|
*/
|
|
*/
|
|
-const getFaceWindow = () => {
|
|
|
|
|
|
+const getFaceWindow = (data: boolean) => {
|
|
let txt = parameter.value.gesture ? "请举手看摄像头人脸识别" : "请看摄像头进行人脸识别";
|
|
let txt = parameter.value.gesture ? "请举手看摄像头人脸识别" : "请看摄像头进行人脸识别";
|
|
speckText(txt);
|
|
speckText(txt);
|
|
- faceWindowRef.value.open();
|
|
|
|
- //然后定时自动关闭
|
|
|
|
- setTimeout(() => {
|
|
|
|
- if (examState.value == 41 && faceWindowRef.value.faceState == true) {
|
|
|
|
- faceWindowRef?.value.close();
|
|
|
|
|
|
+ //data=true为弹出框,data=false为不要弹出框
|
|
|
|
+ if (data) {
|
|
|
|
+ faceWindowRef.value.open();
|
|
|
|
+ //然后定时自动关闭
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ if (examState.value == 41 && faceWindowRef.value.faceState == true) {
|
|
|
|
+ faceWindowRef.value?.close();
|
|
|
|
+ }
|
|
|
|
+ }, 3000)
|
|
|
|
+ }
|
|
|
|
+ //定时检查如果一直停留在人脸识别就提示
|
|
|
|
+ timerManager.value.face = setInterval(() => {
|
|
|
|
+ getClearTimer("face");
|
|
|
|
+ if (examState.value == 41) {
|
|
|
|
+ getFaceWindow(false);
|
|
}
|
|
}
|
|
- }, 3000)
|
|
|
|
-
|
|
|
|
|
|
+ }, 15000)
|
|
};
|
|
};
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -489,7 +494,6 @@ const getAchievement = (data: any) => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
backReason.value = arr;
|
|
backReason.value = arr;
|
|
-
|
|
|
|
if (data.isfinish) {
|
|
if (data.isfinish) {
|
|
if (['jump'].includes(type) && backReason.value.length) {
|
|
if (['jump'].includes(type) && backReason.value.length) {
|
|
speckText("请重新测试");
|
|
speckText("请重新测试");
|
|
@@ -497,7 +501,6 @@ const getAchievement = (data: any) => {
|
|
}
|
|
}
|
|
speckText(faceCheckStu?.value.name + "成绩为" + (chineseNumber(count) || 0) + unit.value + ",请下一位准备!" || "");
|
|
speckText(faceCheckStu?.value.name + "成绩为" + (chineseNumber(count) || 0) + unit.value + ",请下一位准备!" || "");
|
|
}
|
|
}
|
|
-
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
@@ -507,9 +510,9 @@ onMounted(() => {
|
|
let area = parameter.value.area;
|
|
let area = parameter.value.area;
|
|
parameter.value.examId = `${project}_${area}`; //项目+区
|
|
parameter.value.examId = `${project}_${area}`; //项目+区
|
|
if (parameter.value.time) {
|
|
if (parameter.value.time) {
|
|
- testTime.value = parameter.value.time
|
|
|
|
|
|
+ time.value.testTime = parameter.value.time
|
|
}
|
|
}
|
|
- countdownNum.value = testTime.value;
|
|
|
|
|
|
+ time.value.countdownNum = time.value.testTime;
|
|
let myInfo: any = localStorage.getItem("userInfo");
|
|
let myInfo: any = localStorage.getItem("userInfo");
|
|
userInfo.value = JSON.parse(myInfo);
|
|
userInfo.value = JSON.parse(myInfo);
|
|
let dic: any = dataDictionary;
|
|
let dic: any = dataDictionary;
|
|
@@ -524,9 +527,12 @@ onMounted(() => {
|
|
needStart.value = true;
|
|
needStart.value = true;
|
|
}
|
|
}
|
|
//加载WS
|
|
//加载WS
|
|
- initWs({ parameter: parameter.value, testTime: testTime.value }, (data: any) => {
|
|
|
|
|
|
+ initWs({ parameter: parameter.value, testTime: time.value.testTime }, (data: any) => {
|
|
getMessage(data);
|
|
getMessage(data);
|
|
});
|
|
});
|
|
|
|
+ getNetWork(() => {
|
|
|
|
+ getExit();
|
|
|
|
+ });
|
|
initSpeech();
|
|
initSpeech();
|
|
})
|
|
})
|
|
|
|
|