Преглед на файлове

活检检测剩余时间

Michael Wang преди 5 години
родител
ревизия
57880d33f0
променени са 2 файла, в които са добавени 33 реда и са изтрити 23 реда
  1. 32 23
      src/features/OnlineExam/Examing/ExamingHome.vue
  2. 1 0
      src/features/OnlineExam/Examing/RemainTime.vue

+ 32 - 23
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -595,29 +595,38 @@ export default {
       // 仅在线上使用活体检测
       // if (process.env.NODE_ENV === "production" && faceVerifyMinute) {
       if (faceVerifyMinute) {
-        const enoughTimeForFaceId = this.remainTime // 如果remainTime取到了的话
-          ? this.remainTime / (60 * 1000) - 1 > faceVerifyMinute
-          : true;
-        if (!enoughTimeForFaceId) return;
-
-        this.faceIdMsgTimeout = setTimeout(() => {
-          // this.serverLog("debug/S-002001", "活体检测前抓拍");
-          this.toggleSnapNow();
-          this.$Message.info({
-            content: "30秒后开始活体检测",
-            duration: 15,
-            closable: true,
-          });
-        }, faceVerifyMinute * 60 * 1000 - 30 * 1000); // 活体检测提醒
-        this.faceIdDivTimeout = setTimeout(() => {
-          // this.serverLog("debug/S-003001", "准备弹出活体检测框");
-          if (identificationOfLivingBodyScheme === "S1") {
-            this.showFaceId = true;
-          } else if (identificationOfLivingBodyScheme === "S2") {
-            this.showFaceMotion = true;
-          }
-        }, faceVerifyMinute * 60 * 1000); // 定时做活体检测
-        // }, 1 * 1000); // 定时做活体检测
+        // 第二次开启活检时肯定有 this.remainTime 了。注意断点续考时没有这项检查
+        this.$nextTick(async () => {
+          await new Promise(r =>
+            setTimeout(() => {
+              r();
+            }, 10 * 1000)
+          );
+          console.log("活检定时");
+          const enoughTimeForFaceId = this.remainTime // 如果remainTime取到了的话
+            ? this.remainTime / (60 * 1000) - 1 > faceVerifyMinute
+            : true;
+          if (!enoughTimeForFaceId) return;
+
+          this.faceIdMsgTimeout = setTimeout(() => {
+            // this.serverLog("debug/S-002001", "活体检测前抓拍");
+            this.toggleSnapNow();
+            this.$Message.info({
+              content: "30秒后开始活体检测",
+              duration: 15,
+              closable: true,
+            });
+          }, faceVerifyMinute * 60 * 1000 - 30 * 1000); // 活体检测提醒
+          this.faceIdDivTimeout = setTimeout(() => {
+            // this.serverLog("debug/S-003001", "准备弹出活体检测框");
+            if (identificationOfLivingBodyScheme === "S1") {
+              this.showFaceId = true;
+            } else if (identificationOfLivingBodyScheme === "S2") {
+              this.showFaceMotion = true;
+            }
+          }, faceVerifyMinute * 60 * 1000); // 定时做活体检测
+          // }, 1 * 1000); // 定时做活体检测
+        });
       }
 
       // for test

+ 1 - 0
src/features/OnlineExam/Examing/RemainTime.vue

@@ -60,6 +60,7 @@ export default {
           if (this.remainTime === null) {
             // 仅当剩余考试时间没有被初始化才使用服务器时间。否则使用本机时间。
             this.remainTime = res.data;
+            console.log("初始化剩余时间");
           }
           this.heartbeatErrorNum = 0;
         } else {