yangg 3 долоо хоног өмнө
parent
commit
af14c75342

+ 66 - 19
pages/identity-verify/identity-verify.vue

@@ -296,42 +296,57 @@ export default {
       progressColor: '#05dc8b', // 进度条颜色
       progressBgColor: 'rgba(0, 0, 0,0.3)', // 进度条背景色
       parentQuestion: '', // 添加父问题存储
+      screenCaptureCount: 0, // 添加截屏次数记录
     }
   },
   mounted() {
-    /* this.fetchData() */
-    this.fetchQuestions(); // 添加获取问题数据的方法调用
-    this.fetchFollowUpQuestions(); // 添加获取追问问题的方法调用
+    this.fetchQuestions();
+    this.fetchFollowUpQuestions();
     this.checkAudioPermission();
     this.initCamera();
     this.checkIOSCameraRecordPermission();
-    
-    // 添加防御性检查,避免渲染错误
     this.checkAndFixRenderingIssues();
-    
-    // 添加音频测试
     setTimeout(() => {
       if (this.cameraStream && !this.useMiniProgramCameraComponent) {
         this.testAudioInput();
       }
-    }, 3000);
-    
-    // 初始化历史时间记录
+    }, 3e3);
     this.historyTime = 0;
-    
     uni.setKeepScreenOn({
       keepScreenOn: true
     });
+
+    // 添加截屏监听
+    uni.onUserCaptureScreen(() => {
+      console.log('User captured screen');
+      this.screenCaptureCount++;
+      
+      if (this.screenCaptureCount === 1) {
+        // 第一次截屏,显示警告
+        uni.showModal({
+          title: '警告',
+          content: '检测到屏幕截图。如果你再次捕捉屏幕,你的面试结果将无效。',
+          showCancel: false,
+          confirmText: 'OK'
+        });
+      } else if (this.screenCaptureCount >= 2) {
+        // 第二次及以上截屏,作废成绩
+        uni.showModal({
+          title: '面试作废',
+          content: '由于您在面试过程中多次截屏,本次面试作废,如有疑问请联系企业招聘人员',
+          showCancel: false,
+          confirmText: 'OK',
+          success: () => {
+            // 可以在这里添加其他处理逻辑,比如记录日志或上报服务器
+            this.invalidateInterview();
+          }
+        });
+      }
+    });
   },
   beforeDestroy() {
-    // 组件销毁前停止摄像头
-    this.stopUserCamera();
-    
-    // 清除倒计时定时器
-    this.clearCountdown();
-    
-    // 移除 WebSocket 连接关闭
-    // this.closeWebSocketConnection();
+    // 移除截屏监听
+    uni.offUserCaptureScreen();
   },
   methods: {
     // 初始化相机
@@ -3311,6 +3326,38 @@ export default {
         }
       });
     },
+
+    // 添加作废面试的方法
+    invalidateInterview() {
+      // 停止录制(如果正在录制)
+      if (this.isRecording) {
+        this.stopRecordingAnswer();
+      }
+      
+      // 清除所有计时器
+      if (this.recordingTimer) {
+        clearInterval(this.recordingTimer);
+      }
+      
+      // 重置状态
+      this.isRecording = false;
+      this.showStopRecordingButton = false;
+      this.showStartRecordingButton = false;
+      
+      // 显示作废提示
+      // uni.showToast({
+      //   title: 'Interview invalidated',
+      //   icon: 'none',
+      //   duration: 2000
+      // });
+      
+      // 延迟后返回上一页
+      setTimeout(() => {
+        uni.switchTab({
+        url: '/pages/index/index'
+      });
+      }, 500);
+    },
   },
   computed: {
     // 计算进度比例

+ 43 - 3
unpackage/dist/dev/mp-weixin/pages/identity-verify/identity-verify.js

@@ -139,8 +139,10 @@ const _sfc_main = {
       // 进度条颜色
       progressBgColor: "rgba(0, 0, 0,0.3)",
       // 进度条背景色
-      parentQuestion: ""
+      parentQuestion: "",
       // 添加父问题存储
+      screenCaptureCount: 0
+      // 添加截屏次数记录
     };
   },
   mounted() {
@@ -159,10 +161,31 @@ const _sfc_main = {
     common_vendor.index.setKeepScreenOn({
       keepScreenOn: true
     });
+    common_vendor.index.onUserCaptureScreen(() => {
+      console.log("User captured screen");
+      this.screenCaptureCount++;
+      if (this.screenCaptureCount === 1) {
+        common_vendor.index.showModal({
+          title: "警告",
+          content: "检测到屏幕截图。如果你再次捕捉屏幕,你的面试结果将无效。",
+          showCancel: false,
+          confirmText: "OK"
+        });
+      } else if (this.screenCaptureCount >= 2) {
+        common_vendor.index.showModal({
+          title: "面试作废",
+          content: "由于您在面试过程中多次截屏,本次面试作废,如有疑问请联系企业招聘人员",
+          showCancel: false,
+          confirmText: "OK",
+          success: () => {
+            this.invalidateInterview();
+          }
+        });
+      }
+    });
   },
   beforeDestroy() {
-    this.stopUserCamera();
-    this.clearCountdown();
+    common_vendor.index.offUserCaptureScreen();
   },
   methods: {
     // 初始化相机
@@ -2280,6 +2303,23 @@ const _sfc_main = {
           this.currentSubtitle = followUpSubtitles[0].text;
         }
       });
+    },
+    // 添加作废面试的方法
+    invalidateInterview() {
+      if (this.isRecording) {
+        this.stopRecordingAnswer();
+      }
+      if (this.recordingTimer) {
+        clearInterval(this.recordingTimer);
+      }
+      this.isRecording = false;
+      this.showStopRecordingButton = false;
+      this.showStartRecordingButton = false;
+      setTimeout(() => {
+        common_vendor.index.switchTab({
+          url: "/pages/index/index"
+        });
+      }, 500);
     }
   },
   computed: {