|
@@ -3016,14 +3016,7 @@ export default {
|
|
|
return null;
|
|
|
},
|
|
|
|
|
|
- onShow() {
|
|
|
- console.log('identity-verify页面onShow');
|
|
|
- console.log('当前本地存储中的职位信息:', uni.getStorageSync('selectedJob'));
|
|
|
-
|
|
|
- // 每次页面显示时重新获取问题
|
|
|
- this.fetchQuestions();
|
|
|
- this.fetchFollowUpQuestions(); // 添加获取追问问题的调用
|
|
|
- },
|
|
|
+
|
|
|
|
|
|
// 添加新方法:重置录制状态,准备重新回答
|
|
|
resetForRerecording() {
|
|
@@ -3139,18 +3132,74 @@ export default {
|
|
|
this.handleStartRecordingClick();
|
|
|
},
|
|
|
|
|
|
- // 添加 onUnload 生命周期钩子,移除 WebSocket 关闭
|
|
|
+ // 页面卸载时关闭WebSocket连接
|
|
|
onUnload() {
|
|
|
- console.log('页面卸载');
|
|
|
- // 移除 WebSocket 关闭
|
|
|
- // this.closeWebSocketConnection();
|
|
|
+ console.log('页面卸载,关闭WebSocket连接');
|
|
|
+ this.cleanupPersonDetectionWebSocket();
|
|
|
+ // 清理其他资源
|
|
|
+ this.stopUserCamera();
|
|
|
+ this.clearCountdown();
|
|
|
+
|
|
|
+ // 清理录制相关定时器
|
|
|
+ if (this.recordingTimer) {
|
|
|
+ clearInterval(this.recordingTimer);
|
|
|
+ this.recordingTimer = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 停止MediaRecorder
|
|
|
+ if (this.mediaRecorder && this.mediaRecorder.state !== 'inactive') {
|
|
|
+ this.mediaRecorder.stop();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 关闭屏幕常亮
|
|
|
+ uni.setKeepScreenOn({
|
|
|
+ keepScreenOn: false
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
- // 修改 onHide 生命周期钩子,移除 WebSocket 关闭
|
|
|
+ // 页面隐藏时关闭WebSocket连接
|
|
|
onHide() {
|
|
|
- console.log('页面隐藏');
|
|
|
- // 移除 WebSocket 关闭
|
|
|
- // this.closeWebSocketConnection();
|
|
|
+ console.log('页面隐藏,关闭WebSocket连接');
|
|
|
+
|
|
|
+ // 完全关闭WebSocket连接和相关定时器
|
|
|
+ this.cleanupPersonDetectionWebSocket();
|
|
|
+
|
|
|
+ // 如果正在录制,给用户提示
|
|
|
+ if (this.isRecording) {
|
|
|
+ console.log('页面隐藏时正在录制,录制将继续');
|
|
|
+ // 可以选择暂停录制或者给用户提示
|
|
|
+ uni.showToast({
|
|
|
+ title: '请不要离开面试页面',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 页面显示时重新初始化WebSocket连接
|
|
|
+ onShow() {
|
|
|
+ console.log('identity-verify页面onShow');
|
|
|
+ console.log('当前本地存储中的职位信息:', uni.getStorageSync('selectedJob'));
|
|
|
+
|
|
|
+ // 每次页面显示时重新获取问题
|
|
|
+ this.fetchQuestions();
|
|
|
+ this.fetchFollowUpQuestions(); // 添加获取追问问题的调用
|
|
|
+
|
|
|
+ // 重新初始化WebSocket连接(仅在小程序环境中)
|
|
|
+ const systemInfo = uni.getSystemInfoSync();
|
|
|
+ const isMiniProgram = systemInfo.uniPlatform && systemInfo.uniPlatform.startsWith('mp-');
|
|
|
+ if (isMiniProgram) {
|
|
|
+ // 如果WebSocket未连接,重新初始化
|
|
|
+ if (!this.personDetectionSocket) {
|
|
|
+ console.log('重新初始化WebSocket连接');
|
|
|
+ this.initPersonDetectionWebSocket();
|
|
|
+ }
|
|
|
+ // 如果WebSocket已连接但检测定时器被停止,重新启动检测
|
|
|
+ else if (!this.personDetectionInterval) {
|
|
|
+ console.log('重新启动人脸检测定时器');
|
|
|
+ this.startPersonDetectionInterval();
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
// 添加新方法:阻止视频控制
|