test.vue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153
  1. <template>
  2. <div class="test">
  3. <Header @confirmExit="confirmExit"></Header>
  4. <div class="main">
  5. <div class="main-left">
  6. <div class="main-left-top">
  7. <div class="top-left" @click="getChooseStudent">
  8. <div class="top-left-center">
  9. <div class="pic" :class="{ 'pic2': faceCheckStu.student_id }" v-if="faceCheckStu.student_id"> <img
  10. :src="faceCheckStu.face_pic || faceCheckStu.logo_url" /></div>
  11. <div class="pic" v-else>
  12. <img src="@/assets/images/test/profilePicture.png" />
  13. </div>
  14. <div class="name" :class="{ 'name2': faceCheckStu.student_id }">
  15. {{ faceCheckStu.student_id ? faceCheckStu.name : "虚位以待" }}
  16. </div>
  17. </div>
  18. </div>
  19. <div class="top-right">
  20. <transition :enter-active-class="proxy?.animate.dialog.enter"
  21. :leave-active-class="proxy?.animate.dialog.leave">
  22. <div class="time" v-show="needStart && [42].includes(examState)">{{
  23. time.countdownNum
  24. }}</div>
  25. </transition>
  26. <div class="tips" v-if="examState == 41">
  27. <img v-if="parameter.gesture" src="@/assets/images/test/ready1.png" />
  28. <img v-if="!parameter.gesture" src="@/assets/images/test/ready2.png" />
  29. </div>
  30. <div class="complete" :class="{ 'complete2': needStart && [42].includes(examState) }"
  31. v-if="faceCheckStu.student_id && time.ready <= 0 && examState != 43">
  32. <div class="scoreBox" v-if="['basketballv1'].includes(parameter.project)">
  33. <div class="score">{{ currentResultObj.count || 0 }}</div>
  34. </div>
  35. <div class="scoreBox" v-else>
  36. <div class="score">{{ currentResultObj.count || 0 }}</div>
  37. <div class="unit" v-if="currentResultObj.count && !needStart">{{ unit }}</div>
  38. </div>
  39. <div class="fractionViolation">
  40. <div class="fraction">
  41. <div class="lable">得分:</div>
  42. <div class="value">{{ currentResultObj.score || "" }}</div>
  43. </div>
  44. <div class="violation">
  45. <div class="lable">{{ ['jumprope'].includes(parameter.project) ? '中断' : '犯规' }}</div>
  46. <div class="value">{{ currentResultObj.back_num || 0 }}</div>
  47. </div>
  48. </div>
  49. </div>
  50. <div class="foulBox" v-if="examState == 42 && backReason.length">
  51. <transition :enter-active-class="proxy?.animate.mask.enter"
  52. :leave-active-class="proxy?.animate.mask.leave">
  53. <div class="foul" v-show="backReasonStr ? true : false">
  54. <div class="lable">!</div>
  55. <div class="value">{{ backReasonStr }}</div>
  56. </div>
  57. </transition>
  58. </div>
  59. <div v-if="examState == 43 && time.ready">
  60. <div class="readyBox">
  61. <div class="value">{{ time.ready }}</div>
  62. <div class="lable">倒计时</div>
  63. </div>
  64. </div>
  65. <div v-if="examState == 43 && !time.ready && readyState">
  66. <div class="readyBoxBefore">
  67. <div class="item" v-if="parameter.gesture">
  68. <div><img src="@/assets/images/test/jushou.png" /></div>
  69. <div class="lable">
  70. <div>请举手开始</div>
  71. </div>
  72. </div>
  73. <div class="item" v-else>
  74. <div> <img src="@/assets/images/test/bujushou.png" /></div>
  75. <div class="lable">
  76. <div>请点击开始</div>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. <div class="btn" @click="getReady" v-if="needStart && examState == 43 && !time.ready && readyState">开 始
  82. </div>
  83. <!-- <div v-if="needStart"> -->
  84. <!-- <div class="btn" @click="getOpenOneTestAndStartFace" v-if="examState == 3 || examState == 40">开始识别</div> -->
  85. <!-- <div class="btn" @click="getStopFace" v-if="examState == 41 && !parameter.gesture">停止人脸识别</div> -->
  86. <!-- <div class="btn" @click="getStartOneTest" v-if="examState == 43">开始测试</div> -->
  87. <!-- <div @click="getRetestFace" v-if="examState == 43 || examState == 42">重新识别</div> -->
  88. <!-- </div> -->
  89. <!-- <div>当前状态:({{ examState == 3 ? "初始化完成" : examState == 40 ? "创建测试" : examState == 41 ? "正在人脸识别":examState == 43 ? "停止人脸识别" : examState == 42 ? "正在测试" : "请初始化" }})</div> -->
  90. <!-- <div @click="getAgain" v-if="examState == 42 || showTestAgain">再测一次</div> -->
  91. </div>
  92. <i></i>
  93. </div>
  94. <div class="main-left-bottom">
  95. <div class="bottom-left">
  96. <div class="tips"><img src="/src/assets/images/test/tips.png" /></div>
  97. <div class="pic"><img :src="'static/images/tips/' + parameter.project + '.png'" /></div>
  98. </div>
  99. <div class="bottom-right" v-html="dic.projectNote[parameter.project]">
  100. </div>
  101. </div>
  102. </div>
  103. <div class="main-right">
  104. <ReportList ref="reportListRef" :parameter="parameter" :showQRCode="true" />
  105. </div>
  106. </div>
  107. <FaceWindow ref="faceWindowRef" :faceCheckStu="faceCheckStu" :gesture="parameter.gesture" />
  108. <ChooseStudent ref="chooseStudentRef" @returnData="returnStudent" />
  109. </div>
  110. </template>
  111. <script setup name="TrainTest" lang="ts">
  112. import { initSpeech, speckText, speckCancel, chineseNumber } from '@/utils/speech'
  113. import { initWs, examEnds, openOneTest, startFace, stopFace, faceConfirmOnly, startOneTest, finishOneTest, closeOneTest, suspendFaceRecognitionChannels, resumeFaceRecognitionChannels } from '@/utils/ws'
  114. import dayjs from 'dayjs'
  115. import dataDictionary from "@/utils/dataDictionary"
  116. const { proxy } = getCurrentInstance() as any;
  117. const router = useRouter();
  118. const route = useRoute();
  119. const faceWindowRef = ref();
  120. const chooseStudentRef = ref();
  121. const reportListRef = ref();
  122. const myInfo: any = localStorage.getItem("userInfo");
  123. const dic: any = dataDictionary;
  124. const data = reactive<any>({
  125. timerManager: {},//计时器管理
  126. parameter: {},//参数
  127. time: {
  128. testTime: 60,//时长
  129. countdownNum: 0,//计时
  130. ready: 0,//预备
  131. },
  132. userInfo: {},//用户信息
  133. examState: 0,//当前状态
  134. resultId: null,//测试ID
  135. currentResultObj: {},//成绩
  136. faceCheckStu: {},//人脸信息
  137. unit: "",//单位
  138. backReason: [],//犯规项
  139. backReasonStr: "",//犯规提示
  140. needStart: false,//是否需要按钮
  141. showTestAgain: false,//再测一次按钮
  142. readyState: true,//倒计时按钮状态
  143. });
  144. const { timerManager, parameter, time, userInfo, examState, resultId, faceCheckStu, currentResultObj, unit, backReason, backReasonStr, needStart, showTestAgain, readyState } = toRefs(data);
  145. /**
  146. * 接收消息
  147. */
  148. const getMessage = (e: any) => {
  149. //console.log("WS响应:", e)
  150. //实时状态
  151. if (e.cmd === 'exam_status') {
  152. examState.value = e.data;
  153. }
  154. //工作站状态
  155. if (e.cmd === 'init_result') {
  156. }
  157. //测试违规
  158. if (e.cmd === 'warning_result') {
  159. }
  160. //后端播报语音
  161. if (e.cmd === 'return_audio_msg') {
  162. }
  163. //错误提示
  164. if (e.cmd === 'info_result') {
  165. proxy?.$modal.msgError(e.data.message);
  166. }
  167. //错误提示
  168. if (e.cmd === 'error_result') {
  169. proxy?.$modal.msgError(e.data.message);
  170. }
  171. //测试中违规提示
  172. if (e.cmd === 'warning_notify') {
  173. }
  174. //断线状态
  175. if (e.cmd === 'disconnect_request') {
  176. let message = e.data.message;
  177. if (message) {
  178. proxy?.$modal.msgError(`${message}`);
  179. speckText(message);
  180. }
  181. getExit();
  182. }
  183. //状态变更
  184. if (e.cmd === 'set_exam_state') {
  185. examState.value = e.data;
  186. if (e.data === 3) {
  187. initProject();
  188. }
  189. if (e.data === 40) {
  190. cleanData();
  191. }
  192. if (e.data == 41) {
  193. getFaceWindow(true);
  194. }
  195. if (e.data == 43) {
  196. }
  197. if (e.data == 42) {
  198. getClearTimer("readyTimer");
  199. time.value.ready = 0;
  200. }
  201. }
  202. //新建测试后返回信息,获取result_id
  203. if (e.cmd === 'open_one_test_ack') {
  204. resultId.value = e.data.result_id;
  205. }
  206. //人脸识别状态
  207. if (e.cmd === 'face_check_result') {
  208. let myData = e.data[0] || e.data;
  209. returnStudent(myData);
  210. }
  211. //测试结束结果
  212. if (e.cmd === 'oneresult') {
  213. if (e.data.length) {
  214. let data = e.data[0];
  215. getAchievement(data)
  216. }
  217. }
  218. //结果生成完成(视频图片)
  219. if (e.cmd === 'static_urls_finished') {
  220. }
  221. //选择学生或测试结束后返回的数据
  222. if (e.cmd === 'result_info') {
  223. }
  224. };
  225. /**
  226. * 开始识别
  227. */
  228. const getOpenOneTestAndStartFace = async () => {
  229. if (examState.value > 3) {
  230. await closeOneTest();
  231. }
  232. await openOneTest();
  233. await startFace();
  234. };
  235. /**
  236. * 停止人脸识别
  237. */
  238. const getStopFace = async () => {
  239. // 旧版识别成功直接43了这里先屏蔽
  240. // if (examState.value != 41) {
  241. // return false;
  242. // }
  243. getClearTimer("face");
  244. if (needStart.value) {
  245. let txt = parameter.value.gesture === true ? ",请举手开始测试" : ",请准备";
  246. speckText(faceCheckStu.value.name + txt);
  247. }
  248. await stopFace();
  249. if (faceCheckStu.value.student_id) {
  250. getFaceConfirmOnly();
  251. }
  252. };
  253. /**
  254. * 确定人脸信息
  255. */
  256. const getFaceConfirmOnly = (data?: any) => {
  257. if (data) {
  258. faceCheckStu.value = data;
  259. }
  260. faceConfirmOnly({
  261. result_id: resultId.value,
  262. student_id: faceCheckStu.value.student_id,
  263. gender: faceCheckStu.value.gender
  264. }, () => {
  265. faceWindowRef.value?.close();
  266. //不需要按钮的自动进入下一步
  267. if (needStart.value == false) {
  268. getStartOneTest();
  269. }
  270. });
  271. };
  272. /**
  273. * 重新识别
  274. */
  275. const getRetestFace = () => {
  276. proxy?.$modal.confirm("确定重新识别吗?").then(() => {
  277. if (needStart.value == false) {
  278. //自动流程项目重新识别直接返回3
  279. closeOneTest();
  280. } else {
  281. //手动流程项目重新识别43返回41,42返回3
  282. if (examState.value == 43) {
  283. cleanData();
  284. startFace();
  285. } else {
  286. closeOneTest();
  287. }
  288. }
  289. }).finally(() => {
  290. });
  291. };
  292. /**
  293. * 开始测试
  294. */
  295. const getStartOneTest = () => {
  296. if (examState.value != 43 || !faceCheckStu.value.student_id) {
  297. return false;
  298. }
  299. if (!faceCheckStu.value.student_id) {
  300. proxy?.$modal.msgWarning("请选择人员!");
  301. return false;
  302. }
  303. startOneTest(data == null, () => {
  304. //显示再测一次按钮
  305. showTestAgain.value = true;
  306. //停止播报;
  307. speckCancel();
  308. //计时项目才开
  309. if (needStart.value == true) {
  310. //时间为0的为正计时,大于0的为倒计时
  311. if (time.value.testTime == 0) {
  312. getCounting("+");
  313. } else {
  314. getCounting("-");
  315. }
  316. speckText("哨声");
  317. } else {
  318. speckText(faceCheckStu.value.name + ",请开始测试");
  319. }
  320. })
  321. };
  322. /**
  323. * 再测一次
  324. */
  325. const getAgain = async () => {
  326. //预存测试人员
  327. let student = JSON.parse(JSON.stringify(faceCheckStu.value));
  328. //测试中
  329. if (examState.value == 42) {
  330. await finishOneTest();
  331. }
  332. //其他状态
  333. if (examState.value > 3) {
  334. await closeOneTest();
  335. }
  336. //重新走一次流程
  337. await openOneTest();
  338. await startFace();
  339. await stopFace();
  340. getFaceConfirmOnly(student);
  341. };
  342. /**
  343. * 确认退出
  344. */
  345. const confirmExit = () => {
  346. proxy?.$modal.confirm("确定退出吗?").then(() => {
  347. getExit();
  348. }).finally(() => {
  349. });
  350. };
  351. /**
  352. * 退出
  353. */
  354. const getExit = () => {
  355. getClearTimer();//清除计时器
  356. examEnds();//通知工作站关闭
  357. speckCancel()//停止播报;
  358. router.push({ path: '/' });//跳转
  359. };
  360. /**
  361. * 清空定时任务
  362. */
  363. const getClearTimer = (data?: any) => {
  364. if (data) {
  365. //清除指定
  366. clearInterval(timerManager.value[data])
  367. timerManager.value[data] = null;
  368. } else {
  369. //清除全部
  370. for (let key in timerManager.value) {
  371. if (timerManager.value.hasOwnProperty(key)) {
  372. clearInterval(timerManager.value[key])
  373. timerManager.value[key] = null;
  374. }
  375. }
  376. }
  377. };
  378. /**
  379. * 选择学生
  380. */
  381. const getChooseStudent = () => {
  382. if (examState.value < 41) {
  383. proxy?.$modal.msgWarning("请等待");
  384. }
  385. if (examState.value == 41) {
  386. chooseStudentRef.value.open();
  387. //然后定时自动关闭
  388. setTimeout(() => {
  389. faceWindowRef.value.close();
  390. }, 3000)
  391. }
  392. if (examState.value == 43) {
  393. getRetestFace();
  394. }
  395. };
  396. /**
  397. * 返回被选学生
  398. */
  399. const returnStudent = (data: any) => {
  400. chooseStudentRef.value.close();
  401. faceCheckStu.value = data;
  402. faceWindowRef.value.open();
  403. //然后定时自动关闭
  404. setTimeout(() => {
  405. faceWindowRef.value.close();
  406. }, 1000)
  407. getStopFace();
  408. };
  409. /**
  410. * 清除历史记录
  411. */
  412. const cleanData = () => {
  413. time.value.countdownNum = time.value.testTime;
  414. showTestAgain.value = false;
  415. faceCheckStu.value = {};
  416. currentResultObj.value = {};
  417. backReason.value = [];
  418. };
  419. /**
  420. * 自动初始化项目
  421. */
  422. const initProject = () => {
  423. //停止计时
  424. getClearTimer("countdownTimer");
  425. //恢复倒计时按钮状态
  426. readyState.value = true;
  427. //自动项目定时进入下一步
  428. let time = 0;
  429. //控制新建测试的时间,第一次快,之后就慢
  430. if (!faceCheckStu.value.student_id) {
  431. time = 1000;
  432. } else {
  433. time = 6000;
  434. }
  435. setTimeout(() => {
  436. //再加一个判断以免和再测一次冲突
  437. if (examState.value == 3) {
  438. getOpenOneTestAndStartFace();
  439. }
  440. }, time)
  441. };
  442. /**
  443. * 时间转换
  444. */
  445. // const countdownNumFormat = computed(() => {
  446. // return time.value.countdownNum;
  447. // //return proxy?.$utils.timeFormat(time.value.countdownNum);
  448. // });
  449. /**
  450. * 倒计时
  451. */
  452. const getCounting = (type: string) => {
  453. timerManager.value.countdownTimer = setInterval(() => {
  454. //正计时
  455. if (type == "+") {
  456. time.value.countdownNum++;
  457. }
  458. //倒计时
  459. if (type == "-") {
  460. if (time.value.countdownNum <= 0) {
  461. getClearTimer("countdownTimer");
  462. } else {
  463. time.value.countdownNum--;
  464. }
  465. }
  466. }, 1000);
  467. };
  468. /**
  469. * 人脸窗口
  470. */
  471. const getFaceWindow = (data: boolean) => {
  472. let txt = parameter.value.gesture === true ? "请举手看摄像头人脸识别" : "请看摄像头进行人脸识别";
  473. speckText(txt);
  474. //data=true为弹出框,data=false为不要弹出框
  475. if (data) {
  476. faceWindowRef.value.open();
  477. //然后定时自动关闭
  478. setTimeout(() => {
  479. if (examState.value == 41 && faceWindowRef.value?.faceState == true) {
  480. faceWindowRef.value.close();
  481. }
  482. }, 3000)
  483. }
  484. //定时检查如果一直停留在人脸识别就提示
  485. timerManager.value.face = setInterval(() => {
  486. getClearTimer("face");
  487. if (examState.value == 41) {
  488. getFaceWindow(false);
  489. }
  490. }, 15000)
  491. };
  492. /**
  493. * 成绩
  494. */
  495. const getAchievement = (data: any) => {
  496. //console.log("成绩", data);
  497. let type = parameter.value.project;
  498. let count =
  499. data?.[dic.typeResultKey[type]]?.toFixed(0);
  500. if (["trijump", "solidball", "shotput", "longjump"].includes(type)) {
  501. count =
  502. data?.[dic.typeResultKey[type]]?.toFixed(2);
  503. count = Math.round(count) / 100;
  504. }
  505. if (["basketballv1"].includes(type)) {
  506. count = proxy?.$utils.runTime(data?.[dic.typeResultKey[type]], true, 1)
  507. }
  508. data.count = count || "0";
  509. data.score = data.score || "0";
  510. currentResultObj.value = data;
  511. //违规处理
  512. let arr = backReason.value;
  513. if (["situp", "pullup", "sidepullup", "jumprope", "jumpingjack", "jump", "longjump", "verticaljump"]
  514. .indexOf(type) > -1) {
  515. if (["pullup", "situp", "jumprope", "jumpingjack"].indexOf(type) > -1) {
  516. currentResultObj.value.back_num = data?.all_failed_num;
  517. }
  518. if (type === "sidepullup") {
  519. currentResultObj.value.back_num = data?.["0"]?.hip_failed_num;
  520. }
  521. if (['jump', 'longjump', 'verticaljump'].includes(type)) {
  522. if (data?.startline_check == 0) {
  523. let txt = "踩线违规";
  524. arr.push(txt)
  525. }
  526. if (data?.singleleg_jump_check == 0) {
  527. let txt = "单脚跳违规";
  528. arr.push(txt)
  529. }
  530. if (data?.outside_check == 0) {
  531. let txt = "跳出测试区违规";
  532. arr.push(txt)
  533. }
  534. }
  535. if (
  536. data?.elbow_check == false
  537. ) {
  538. let txt = "肘部违规";
  539. arr.push(txt);
  540. }
  541. if (
  542. ["situp", "pullup"].indexOf(type) > -1 &&
  543. data?.knee_check === false
  544. ) {
  545. let txt = "腿部违规";
  546. if (!arr.includes(txt)) {
  547. arr.push(txt);
  548. }
  549. }
  550. if (["situp"].indexOf(type) > -1 && data?.hand_check === false) {
  551. let txt = "手部违规";
  552. if (!arr.includes(txt)) {
  553. arr.push(txt);
  554. }
  555. }
  556. if (
  557. ["pullup"].indexOf(type) > -1 &&
  558. data?.["0"]?.elbow_check === false
  559. ) {
  560. let txt = "手部违规";
  561. if (!arr.includes(txt)) {
  562. arr.push(txt);
  563. }
  564. }
  565. if (["situp"].indexOf(type) > -1 && data?.["0"]?.back_check === false) {
  566. let txt = "背部违规";
  567. if (!arr.includes(txt)) {
  568. arr.push(txt);
  569. }
  570. }
  571. if (
  572. ["sidepullup", "situp"].indexOf(type) > -1 &&
  573. data?.["0"]?.hip_check === false
  574. ) {
  575. let txt = "臀部违规";
  576. if (!arr.includes(txt)) {
  577. arr.push(txt);
  578. }
  579. }
  580. }
  581. backReason.value = arr;
  582. if (data.isfinish) {
  583. if (['jump'].includes(type) && backReason.value.length) {
  584. speckText("请重新测试");
  585. return false;
  586. }
  587. if (["basketballv1"].includes(type)) {
  588. speckText(faceCheckStu?.value.name + "成绩为" + (chineseNumber(proxy?.$utils.runTime(count, false, 0,
  589. 1)) || 0) + ",请下一位准备!" || "");
  590. } else {
  591. speckText(faceCheckStu?.value.name + "成绩为" + (chineseNumber(count) || 0) + unit.value + ",请下一位准备!" || "");
  592. }
  593. reportListRef.value.getIniReportList();
  594. faceWindowRef.value.open("right");
  595. //然后定时自动关闭
  596. setTimeout(() => {
  597. faceWindowRef.value.close();
  598. }, 1000)
  599. }
  600. };
  601. /**
  602. * 准备开始
  603. */
  604. const getReady = () => {
  605. speckCancel();
  606. readyState.value = false;
  607. time.value.ready = 5;
  608. speckText(time.value.ready);
  609. timerManager.value.readyTimer = setInterval(() => {
  610. time.value.ready--;
  611. speckText(time.value.ready);
  612. if (time.value.ready == 0) {
  613. getClearTimer("readyTimer");
  614. getStartOneTest();
  615. }
  616. }, 1000);
  617. };
  618. /**
  619. * 输出犯规
  620. */
  621. watch(() => backReason.value.length, (v) => {
  622. backReasonStr.value = backReason.value[backReason.value.length - 1];
  623. setTimeout(() => {
  624. backReasonStr.value = "";
  625. }, 1500)
  626. }, { immediate: true });
  627. /**
  628. * 播报时间
  629. */
  630. watch(() => time.value.countdownNum, (newData) => {
  631. if (examState.value != 42) {
  632. return false;
  633. }
  634. if (newData >= 30) {
  635. if (newData % 30 == 0) {
  636. speckText(
  637. `还有${newData}秒`
  638. );
  639. }
  640. }
  641. if (newData == 10) {
  642. speckText("还有10秒");
  643. }
  644. if (newData <= 5) {
  645. speckText(newData);
  646. }
  647. }, { immediate: true });
  648. /**
  649. * 成绩整数播报
  650. */
  651. watch(() => currentResultObj, (newData: any, oldData: any) => {
  652. if (examState.value != 42 || newData.count <= 0) {
  653. return false;
  654. }
  655. let project = parameter.value.project;
  656. //引体向上比较慢所以都播报
  657. if (
  658. ["pullup"].includes(project) &&
  659. newData.count > 0 &&
  660. oldData.back_num == oldData.back_num
  661. ) {
  662. speckText(newData.count);
  663. }
  664. if (
  665. ["situp", "sidepullup", "jumprope", "jumpingjack"].includes(project) &&
  666. newData.count > 0 &&
  667. newData.count % 10 == 0 &&
  668. oldData.back_num == oldData.back_num
  669. ) {
  670. speckText(newData.count);
  671. }
  672. }, { immediate: true });
  673. onBeforeMount(() => {
  674. parameter.value = route.query;
  675. let project = parameter.value.project;
  676. let area = parameter.value.area;
  677. parameter.value.examId = `${project}_${area}`; //项目+区
  678. if (parameter.value.time) {
  679. time.value.testTime = parameter.value.time
  680. }
  681. time.value.countdownNum = time.value.testTime;
  682. userInfo.value = JSON.parse(myInfo);
  683. unit.value = dic.unit[project];
  684. if (parameter.value.gesture == 'true') {
  685. parameter.value.gesture = true
  686. } else {
  687. parameter.value.gesture = false
  688. }
  689. //需要开始按钮的项目
  690. if (["jumprope", "skiprope", "jumpingjack", "situp", "basketballv1"].includes(project)) {
  691. needStart.value = true;
  692. }
  693. //加载WS
  694. initWs({ parameter: parameter.value, testTime: time.value.testTime }, (data: any) => {
  695. getMessage(data);
  696. });
  697. initSpeech();
  698. })
  699. onUnmounted(() => {
  700. getExit();
  701. })
  702. </script>
  703. <style lang="scss" scoped>
  704. $topPadding: 5.19rem;
  705. $waiPadding: 6.51rem;
  706. .main {
  707. width: calc(100% - ($waiPadding * 2));
  708. height: 78vh;
  709. padding-top: 10rem;
  710. margin: 0 auto;
  711. display: flex;
  712. justify-content: space-between;
  713. overflow: hidden;
  714. .main-left {
  715. width: 71.5%;
  716. display: flex;
  717. flex-direction: column;
  718. justify-content: space-between;
  719. .main-left-top {
  720. display: flex;
  721. justify-content: space-between;
  722. height: 55.8%;
  723. position: relative;
  724. .top-left {
  725. width: 37.4%;
  726. height: 100%;
  727. border-radius: 1.6rem;
  728. background: radial-gradient(122% 126% at 97% 6%, #35FFC6 0%, #00FFE8 100%);
  729. text-align: center;
  730. display: flex;
  731. align-items: center;
  732. justify-content: center;
  733. cursor: pointer;
  734. .top-left-center {
  735. .pic {
  736. width: 22.3vh;
  737. height: 22.3vh;
  738. border-radius: 50%;
  739. display: flex;
  740. justify-content: center;
  741. align-items: center;
  742. overflow: hidden;
  743. margin: 0 auto 2vh auto;
  744. img {
  745. width: 100%;
  746. }
  747. }
  748. .pic2 {
  749. box-sizing: border-box;
  750. border: 0.44rem solid rgba(26, 41, 58, 0.6315);
  751. }
  752. .name {
  753. width: 100%;
  754. color: #1A293A;
  755. font-size: 2.21rem;
  756. }
  757. .name2 {
  758. padding: 0 0.3rem;
  759. border-radius: 1.1rem;
  760. background: radial-gradient(96% 96% at 2% 32%, #FFFFFF 0%, #FCFDFD 54%, #E1E4E7 100%);
  761. box-shadow: inset 0px 1px 0px 2px rgba(255, 255, 255, 0.9046), inset 0px 3px 6px 0px rgba(0, 0, 0, 0.0851);
  762. }
  763. }
  764. }
  765. .top-right {
  766. width: 62%;
  767. height: 100%;
  768. border-radius: 1.6rem;
  769. opacity: 1;
  770. background: #ffffff;
  771. box-sizing: border-box;
  772. border: 0.55rem solid #13ED84;
  773. display: flex;
  774. align-items: center;
  775. justify-content: center;
  776. flex-direction: column;
  777. position: relative;
  778. .time {
  779. width: 28vh;
  780. height: 28vh;
  781. line-height: 28vh;
  782. border-radius: 50%;
  783. color: #FF9402;
  784. font-size: 11vh;
  785. text-align: center;
  786. background-image: url("@/assets/images/test/time.png");
  787. background-position: center;
  788. background-repeat: no-repeat;
  789. background-size: 100% 100%;
  790. position: absolute;
  791. right: -1.5vh;
  792. top: -11vh;
  793. font-family: 'Saira-BlackItalic';
  794. }
  795. .tips {
  796. display: flex;
  797. justify-content: center;
  798. align-items: center;
  799. height: 100%;
  800. img {
  801. max-height: 80%;
  802. max-height: 80%;
  803. }
  804. }
  805. .complete {
  806. width: 100%;
  807. display: flex;
  808. justify-content: center;
  809. flex-direction: column;
  810. .scoreBox {
  811. height: 10vh;
  812. color: #1A293A;
  813. display: flex;
  814. align-items: center;
  815. justify-content: center;
  816. margin-bottom: 5vh;
  817. .score {
  818. font-size: 8.5rem;
  819. line-height: 8.5rem;
  820. font-family: 'Saira-BlackItalic';
  821. }
  822. .unit {
  823. font-size: 2rem;
  824. margin-left: 10px;
  825. }
  826. }
  827. .fractionViolation {
  828. height: 10vh;
  829. display: flex;
  830. align-items: center;
  831. justify-content: center;
  832. .fraction {
  833. height: 10vh;
  834. line-height: 10vh;
  835. border-radius: 5vh;
  836. display: flex;
  837. align-items: center;
  838. padding: 0 6%;
  839. background: linear-gradient(138deg, #38536C 21%, #1A293A 75%);
  840. box-shadow: inset 0px 1px 13px 0px rgba(255, 255, 255, 0.9452);
  841. .lable {
  842. font-size: 4vh;
  843. color: #13ED84;
  844. }
  845. .value {
  846. font-size: 7vh;
  847. color: #00FFE8;
  848. font-family: 'Saira-BlackItalic';
  849. min-width: 7vh;
  850. }
  851. }
  852. .violation {
  853. height: 6.1vh;
  854. line-height: 6.1vh;
  855. border-radius: 4vh;
  856. border: 0.25rem solid #ED7905;
  857. display: flex;
  858. align-items: center;
  859. margin-left: 11px;
  860. padding: 3px;
  861. box-sizing: content-box;
  862. .lable {
  863. font-size: 1.2rem;
  864. color: #ffffff;
  865. width: 6.1vh;
  866. height: 6.1vh;
  867. line-height: 6.1vh;
  868. background: #ED7905;
  869. border-radius: 50%;
  870. text-align: center;
  871. }
  872. .value {
  873. margin-left: 1.5vh;
  874. font-size: 3.2rem;
  875. color: #ED7905;
  876. font-family: 'Saira-BlackItalic';
  877. min-width: 6vh;
  878. }
  879. }
  880. }
  881. }
  882. .complete2 {
  883. padding-left: 20%;
  884. padding-top: 5vh;
  885. .scoreBox {
  886. margin-bottom: 3vh;
  887. justify-content: left;
  888. }
  889. .fractionViolation {
  890. justify-content: left;
  891. .fraction {
  892. padding: 0 8%;
  893. }
  894. }
  895. }
  896. .foulBox {
  897. height: calc(4.2vh + 0.5rem + 6px);
  898. overflow: hidden;
  899. display: flex;
  900. align-items: center;
  901. justify-content: center;
  902. padding-top: 3vh;
  903. .foul {
  904. height: 4.2vh;
  905. line-height: 4.2vh;
  906. border-radius: 3vh;
  907. border: 0.25rem solid #ED7905;
  908. display: flex;
  909. align-items: center;
  910. margin-left: 11px;
  911. padding: 3px;
  912. box-sizing: content-box;
  913. .lable {
  914. font-size: 2rem;
  915. color: #ffffff;
  916. width: 4.2vh;
  917. height: 4.2vh;
  918. line-height: 4.2vh;
  919. background: #ED7905;
  920. border-radius: 50%;
  921. text-align: center;
  922. }
  923. .value {
  924. margin-left: 1.5vh;
  925. font-size: 2rem;
  926. color: #ED7905;
  927. font-family: 'Saira-BlackItalic';
  928. min-width: 6vh;
  929. padding: 0 10px;
  930. }
  931. }
  932. }
  933. .readyBoxBefore {
  934. display: flex;
  935. justify-content: center;
  936. font-size: 2.5rem;
  937. color: #1A293A;
  938. padding-top: 4vh;
  939. line-height: 0;
  940. margin-bottom: 2vh;
  941. .item {
  942. display: flex;
  943. justify-content: center;
  944. .lable {
  945. display: flex;
  946. align-items: center;
  947. margin-left: 10px;
  948. }
  949. }
  950. img {
  951. height: 20vh;
  952. }
  953. }
  954. .readyBox {
  955. text-align: center;
  956. color: #1A293A;
  957. .value {
  958. font-size: 8.5rem;
  959. line-height: 8.5rem;
  960. font-family: 'Saira-BlackItalic';
  961. }
  962. .lable {
  963. font-size: 3.5rem;
  964. }
  965. }
  966. .btn {
  967. font-size: 2.21rem;
  968. color: #FFFFFF;
  969. text-align: center;
  970. width: 50%;
  971. line-height: 8vh;
  972. line-height: 8vh;
  973. border-radius: 15px;
  974. opacity: 1;
  975. background: radial-gradient(159% 126% at 5% 93%, #F99F02 0%, #ED7905 100%);
  976. box-shadow: 3px 6px 4px 1px rgba(0, 0, 0, 0.1874), inset 0px 1px 0px 2px rgba(255, 255, 255, 0.5577);
  977. cursor: pointer;
  978. }
  979. }
  980. i {
  981. width: 4vw;
  982. height: 4vw;
  983. display: block;
  984. position: absolute;
  985. top: 50%;
  986. left: 37.5%;
  987. margin-top: calc(4vw * -0.5);
  988. margin-left: calc(4vw * -0.5);
  989. background-image: url("@/assets/images/test/yuan.png");
  990. background-position: center;
  991. background-repeat: no-repeat;
  992. background-size: 100% 100%;
  993. border-radius: 50%;
  994. flex-shrink: 0;
  995. transition: all 0.5s;
  996. }
  997. }
  998. .main-left-bottom {
  999. display: flex;
  1000. justify-content: space-between;
  1001. height: calc(100% - 55.8% - 3vh);
  1002. overflow: hidden;
  1003. .bottom-left {
  1004. width: 58%;
  1005. padding-right: 1rem;
  1006. display: flex;
  1007. flex-direction: column;
  1008. .tips {
  1009. height: 2.8vh;
  1010. img {
  1011. height: 100%;
  1012. }
  1013. }
  1014. .pic {
  1015. text-align: center;
  1016. width: 100%;
  1017. height: 100%;
  1018. display: flex;
  1019. justify-content: center;
  1020. overflow: hidden;
  1021. img {
  1022. max-width: 100%;
  1023. max-height: 100%;
  1024. }
  1025. }
  1026. }
  1027. .bottom-right {
  1028. width: 41%;
  1029. height: 100%;
  1030. overflow-y: scroll;
  1031. color: #F9F9F9;
  1032. font-size: 1.1rem;
  1033. line-height: 1.6rem;
  1034. &::-webkit-scrollbar {
  1035. width: 10px;
  1036. }
  1037. &::-webkit-scrollbar-thumb {
  1038. border-width: 2px;
  1039. border-radius: 4px;
  1040. border-style: dashed;
  1041. border-color: transparent;
  1042. background-color: rgba(26, 62, 78, 0.9);
  1043. background-clip: padding-box;
  1044. }
  1045. &::-webkit-scrollbar-button:hover {
  1046. border-radius: 6px;
  1047. background: rgba(26, 62, 78, 1);
  1048. }
  1049. }
  1050. }
  1051. }
  1052. .main-right {
  1053. width: 27%;
  1054. border-radius: 1.6rem;
  1055. background: linear-gradient(29deg, #092941 -82%, #2A484B 94%);
  1056. box-shadow: inset 0px 1px 0px 2px rgba(255, 255, 255, 0.4);
  1057. display: flex;
  1058. flex-direction: column;
  1059. overflow: hidden;
  1060. }
  1061. }
  1062. </style>