瀏覽代碼

进入考试时抓拍,等待页面状态开始后进行

Michael Wang 6 年之前
父節點
當前提交
186afcbbf9
共有 1 個文件被更改,包括 29 次插入4 次删除
  1. 29 4
      src/features/OnlineExam/Examing/ExamingHome.vue

+ 29 - 4
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -134,10 +134,34 @@ export default {
     if (faceEnable.data) {
       this.faceEnable = true;
 
-      setTimeout(() => {
-        this.serverLog("debug/S-002001", "进入考试后5秒抓拍");
-        this.toggleSnapNow(); // 开启抓拍才在进入考试时抓拍一张
-      }, 5 * 1000); // 5秒钟后抓拍
+      // setTimeout(() => {
+      //   this.serverLog("debug/S-002001", "进入考试后60秒内抓拍");
+      //   this.toggleSnapNow(); // 开启抓拍才在进入考试时抓拍一张
+      // }, 60 * 1000); // 60内秒钟后抓拍
+
+      let initSnapshotTrialTimes = 0;
+      this.initSnapInterval = setInterval(() => {
+        if (this.exam || initSnapshotTrialTimes > 12) {
+          clearInterval(this.initSnapInterval);
+          this.serverLog(
+            "debug/S-002001",
+            "进入考试后60秒内抓拍" + `(${(initSnapshotTrialTimes + 1) * 5}秒)`
+          );
+          this.toggleSnapNow(); // 开启抓拍才在进入考试时抓拍一张
+        } else {
+          initSnapshotTrialTimes++;
+        }
+      }, 5 * 1000);
+
+      //       let initSnapshotTrialTimes = 0;
+      // const initSnapshot = setTimeout(() => {
+      //   if (this.exam || initSnapshotTrialTimes < 6) {
+      //     this.serverLog("debug/S-002001", "进入考试后60秒内抓拍");
+      //     this.toggleSnapNow(); // 开启抓拍才在进入考试时抓拍一张
+      //   } else {
+      //     setTimeout(() => initSnapshot(), 5 * 1000);
+      //   }
+      // }, 5 * 1000); // 60内秒钟后抓拍
 
       try {
         const snapshotInterval = await this.$http.get(
@@ -212,6 +236,7 @@ export default {
   beforeDestroy() {
     clearTimeout(this.timeoutTimeout);
     clearInterval(this.submitInterval);
+    clearInterval(this.initSnapInterval);
     clearInterval(this.snapInterval);
     clearTimeout(this.faceIdMsgTimeout);
     clearTimeout(this.faceIdDivTimeout);