|
@@ -1635,7 +1635,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- // 修改 uploadRecordedVideo 方法
|
|
|
+ // 修改 uploadRecordedVideo 方法,添加记录父问题ID的逻辑
|
|
|
uploadRecordedVideo(fileOrPath) {
|
|
|
console.log('准备上传视频:', typeof fileOrPath === 'string' ? fileOrPath : fileOrPath.name);
|
|
|
console.log('当前问题ID:', this.currentParentQuestionId);
|
|
@@ -1648,7 +1648,7 @@ export default {
|
|
|
let questionText = '';
|
|
|
let questionForm = 0;
|
|
|
|
|
|
- // 检查当前是否是追问问题 - 修改判断逻辑
|
|
|
+ // 检查当前是否是追问问题
|
|
|
if (this.currentFollowUpQuestion &&
|
|
|
(this.currentFollowUpQuestion.question_form === 5 || this.isFollowUpQuestion)) {
|
|
|
// 使用追问问题的信息
|
|
@@ -1689,8 +1689,14 @@ export default {
|
|
|
questionForm: questionForm,
|
|
|
attempts: 0,
|
|
|
maxAttempts: 3,
|
|
|
+ parentQuestionId: this.currentParentQuestionId // 添加父问题ID
|
|
|
};
|
|
|
|
|
|
+ // 如果不是追问问题,记录当前问题ID作为父问题ID
|
|
|
+ if (!isFollowUpQuestionUpload) {
|
|
|
+ this.currentParentQuestionId = questionId;
|
|
|
+ }
|
|
|
+
|
|
|
// 添加到上传队列
|
|
|
this.uploadQueue.push(uploadTask);
|
|
|
|
|
@@ -1712,9 +1718,35 @@ export default {
|
|
|
if (!this.isUploading) {
|
|
|
this.processUploadQueue();
|
|
|
}
|
|
|
+
|
|
|
+ // 立即执行后续逻辑
|
|
|
+ this.handlePostUploadActions(uploadTask);
|
|
|
},
|
|
|
-
|
|
|
- // 修改 processUploadQueue 方法,在上传完成后检查是否需要播放低分视频
|
|
|
+
|
|
|
+ // 添加新方法:处理上传后的逻辑
|
|
|
+ handlePostUploadActions(task) {
|
|
|
+ // 检查是否需要播放低分视频
|
|
|
+ if (this.needPlayLowScoreVideo && this.retryCount < 1) {
|
|
|
+ this.playLowScoreVideo();
|
|
|
+ this.needPlayLowScoreVideo = false;
|
|
|
+ } else {
|
|
|
+ // 如果是追问问题的回答,直接进入下一个问题
|
|
|
+ if (task.isFollowUp) {
|
|
|
+ console.log('追问问题回答完成,进入下一个问题');
|
|
|
+ this.retryCount = 0; // 重置重试次数
|
|
|
+ this.isFollowUpQuestion = false; // 重置追问标记
|
|
|
+ this.currentFollowUpQuestion = null; // 清除当前追问问题信息
|
|
|
+ this.proceedToNextQuestion();
|
|
|
+ } else {
|
|
|
+ // 如果是常规问题,记录父问题ID并检查追问问题
|
|
|
+ this.currentParentQuestionId = task.questionId;
|
|
|
+ console.log('检查常规问题的追问,父问题ID:', this.currentParentQuestionId);
|
|
|
+ this.checkAndPlayFollowUpQuestion(this.currentParentQuestionId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 修改 processUploadQueue 方法
|
|
|
processUploadQueue() {
|
|
|
// 如果队列为空,结束处理
|
|
|
if (this.uploadQueue.length === 0) {
|
|
@@ -1738,12 +1770,12 @@ export default {
|
|
|
task.attempts++;
|
|
|
|
|
|
// 根据文件类型选择上传方法
|
|
|
- if (typeof task.file !== 'string') {
|
|
|
- // 浏览器环境,使用XMLHttpRequest上传
|
|
|
- this.uploadFileWithXHR(task);
|
|
|
- } else {
|
|
|
+ if (typeof task.file === 'string') {
|
|
|
// 小程序环境,使用uni.uploadFile上传
|
|
|
this.uploadFileWithUni(task);
|
|
|
+ } else {
|
|
|
+ // 浏览器环境,使用XMLHttpRequest上传
|
|
|
+ this.uploadFileWithXHR(task);
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -1921,64 +1953,19 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- // 修改 submitVideoToInterview 方法,确保正确使用追问问题ID
|
|
|
- submitVideoToInterview(videoUrl, task = null) {
|
|
|
- console.log('提交视频URL到面试接口:', videoUrl);
|
|
|
-
|
|
|
- // 确定问题ID和是否是追问问题
|
|
|
- let questionId;
|
|
|
- let isFollowUp = false;
|
|
|
- let questionForm = 0; // 默认为常规问题
|
|
|
- let questionText = ''; // 添加问题文本变量
|
|
|
-
|
|
|
- if (task) {
|
|
|
- // 如果是从任务中获取信息
|
|
|
- questionId = task.questionId;
|
|
|
- isFollowUp = task.isFollowUp || false;
|
|
|
- questionForm = task.questionForm || (isFollowUp ? 5 : 0);
|
|
|
- questionText = task.questionText || '';
|
|
|
- console.log(`从任务中获取问题信息 - ID: ${questionId}, 是否追问: ${isFollowUp}, 问题类型: ${questionForm}, 问题内容: ${questionText}`);
|
|
|
- } else {
|
|
|
- // 检查当前是否正在回答追问问题
|
|
|
- if (this.isFollowUpQuestion && this.currentFollowUpQuestion) {
|
|
|
- // 使用当前追问问题的信息
|
|
|
- questionId = this.currentFollowUpQuestion.id;
|
|
|
- isFollowUp = true;
|
|
|
- questionForm = 5; // 追问问题使用question_form=5
|
|
|
- questionText = this.currentFollowUpQuestion.question || '';
|
|
|
- console.log(`使用当前追问问题信息 - ID: ${questionId}, 问题内容: ${questionText}`);
|
|
|
- } else {
|
|
|
- // 使用常规问题信息
|
|
|
- const currentQuestion = this.getCurrentQuestionByIndex(this.currentVideoIndex);
|
|
|
- if (currentQuestion && currentQuestion.id) {
|
|
|
- questionId = currentQuestion.id;
|
|
|
- questionText = currentQuestion.question || '';
|
|
|
- console.log(`使用常规问题信息 - ID: ${questionId}, 问题内容: ${questionText}`);
|
|
|
- } else {
|
|
|
- questionId = this.getDefaultQuestionId(this.currentVideoIndex);
|
|
|
- console.log(`使用默认问题ID: ${questionId}`);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 记录当前回答的问题ID,用于后续查找追问
|
|
|
- if (!isFollowUp) {
|
|
|
- this.currentParentQuestionId = questionId;
|
|
|
- }
|
|
|
-
|
|
|
+ // 修改 submitVideoToInterview 方法
|
|
|
+ submitVideoToInterview(videoUrl, task) {
|
|
|
// 准备请求参数
|
|
|
const requestData = {
|
|
|
application_id: uni.getStorageSync('appId'),
|
|
|
- question_id: questionId,
|
|
|
+ question_id: task.questionId,
|
|
|
video_url: videoUrl,
|
|
|
tenant_id: JSON.parse(uni.getStorageSync('userInfo')).tenant_id || '1',
|
|
|
- is_follow_up: isFollowUp ? 1 : 0, // 添加是否为追问的标记
|
|
|
- question_form: questionForm, // 添加问题类型参数
|
|
|
- question_text: questionText // 添加问题文本
|
|
|
+ is_follow_up: task.isFollowUp ? 1 : 0,
|
|
|
+ question_form: task.questionForm,
|
|
|
+ question_text: task.questionText
|
|
|
};
|
|
|
|
|
|
- console.log('提交面试请求参数:', requestData);
|
|
|
-
|
|
|
// 发送请求到面试接口
|
|
|
uni.request({
|
|
|
url: `${apiBaseUrl}/api/job/upload_video`,
|
|
@@ -1988,72 +1975,18 @@ export default {
|
|
|
'content-type': 'application/x-www-form-urlencoded'
|
|
|
},
|
|
|
success: (res) => {
|
|
|
- console.log('面试接口提交成功:', res);
|
|
|
-
|
|
|
if (res.data.code === 200 || res.data.code === 2000) {
|
|
|
- // 提交成功
|
|
|
- if (task) {
|
|
|
- // 从队列中移除当前任务
|
|
|
- this.uploadQueue.shift();
|
|
|
-
|
|
|
- // 检查是否需要播放低分视频
|
|
|
- if (this.needPlayLowScoreVideo && this.retryCount < 1) {
|
|
|
- this.playLowScoreVideo();
|
|
|
- this.needPlayLowScoreVideo = false;
|
|
|
- } else {
|
|
|
- // 如果是追问问题的回答,直接进入下一个问题
|
|
|
- if (isFollowUp) {
|
|
|
- console.log('追问问题回答完成,进入下一个问题');
|
|
|
- this.retryCount = 0; // 重置重试次数
|
|
|
- this.isFollowUpQuestion = false; // 重置追问标记
|
|
|
- this.currentFollowUpQuestion = null; // 清除当前追问问题信息
|
|
|
- this.proceedToNextQuestion();
|
|
|
- } else {
|
|
|
- // 如果是常规问题,检查是否有对应的追问问题
|
|
|
- this.checkAndPlayFollowUpQuestion(this.currentParentQuestionId);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 继续处理队列中的下一个任务
|
|
|
- this.processUploadQueue();
|
|
|
- } else {
|
|
|
- // 兼容旧代码的处理逻辑
|
|
|
- uni.showToast({
|
|
|
- title: '回答已提交',
|
|
|
- icon: 'success'
|
|
|
- });
|
|
|
-
|
|
|
- // 检查是否需要播放低分视频
|
|
|
- if (this.needPlayLowScoreVideo && this.retryCount < 1) {
|
|
|
- this.playLowScoreVideo();
|
|
|
- this.needPlayLowScoreVideo = false;
|
|
|
- } else {
|
|
|
- // 如果是追问问题的回答,直接进入下一个问题
|
|
|
- if (isFollowUp) {
|
|
|
- console.log('追问问题回答完成,进入下一个问题');
|
|
|
- this.retryCount = 0;
|
|
|
- this.isFollowUpQuestion = false;
|
|
|
- this.currentFollowUpQuestion = null;
|
|
|
- this.proceedToNextQuestion();
|
|
|
- } else {
|
|
|
- // 如果是常规问题,检查是否有对应的追问问题
|
|
|
- this.checkAndPlayFollowUpQuestion(this.currentParentQuestionId);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 保存最后上传的视频URL
|
|
|
- this.lastUploadedVideoUrl = videoUrl;
|
|
|
-
|
|
|
- // 隐藏重试按钮(如果之前显示了)
|
|
|
- this.showRetryButton = false;
|
|
|
- this.lastVideoToRetry = null;
|
|
|
- }
|
|
|
+ // 从队列中移除已完成的任务
|
|
|
+ this.uploadQueue.shift();
|
|
|
+
|
|
|
+ // 继续处理队列中的下一个任务
|
|
|
+ this.processUploadQueue();
|
|
|
} else {
|
|
|
- // 提交失败处理...
|
|
|
+ this.handleUploadError(task, '提交失败: ' + (res.data.msg || '未知错误'));
|
|
|
}
|
|
|
},
|
|
|
fail: (err) => {
|
|
|
- // 失败处理...
|
|
|
+ this.handleUploadError(task, '网络错误: ' + err.errMsg);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -3236,21 +3169,27 @@ export default {
|
|
|
checkAndPlayFollowUpQuestion(parentQuestionId) {
|
|
|
console.log('检查是否有追问问题,父问题ID:', parentQuestionId);
|
|
|
|
|
|
+ if (!parentQuestionId) {
|
|
|
+ console.warn('没有父问题ID,无法检查追问问题');
|
|
|
+ this.proceedToNextQuestion();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
// 如果已经播放过这个问题的追问,则直接进入下一个问题
|
|
|
if (this.hasPlayedFollowUp[parentQuestionId]) {
|
|
|
console.log('已经播放过此问题的追问,直接进入下一个问题');
|
|
|
- this.retryCount = 0; // 重置重试次数
|
|
|
+ this.retryCount = 0;
|
|
|
this.proceedToNextQuestion();
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 查找对应的追问问题
|
|
|
const followUpQuestion = this.followUpQuestions.find(q =>
|
|
|
q.parent_question_id === parentQuestionId &&
|
|
|
- q.digital_human_video_url && // 确保有视频URL
|
|
|
- q.question_form === 5 // 确保是追问问题类型
|
|
|
+ q.digital_human_video_url &&
|
|
|
+ q.question_form === 5
|
|
|
);
|
|
|
-
|
|
|
+
|
|
|
if (followUpQuestion) {
|
|
|
console.log('找到追问问题:', followUpQuestion);
|
|
|
|
|
@@ -3260,17 +3199,17 @@ export default {
|
|
|
// 标记当前是追问问题
|
|
|
this.isFollowUpQuestion = true;
|
|
|
|
|
|
- // 记录当前父问题ID,用于后续查找正确的追问问题
|
|
|
+ // 记录当前父问题ID
|
|
|
this.currentParentQuestionId = parentQuestionId;
|
|
|
|
|
|
- // 保存当前追问问题的完整信息,用于后续上传
|
|
|
+ // 保存当前追问问题的完整信息
|
|
|
this.currentFollowUpQuestion = followUpQuestion;
|
|
|
|
|
|
// 播放追问问题视频
|
|
|
this.playFollowUpQuestionVideo(followUpQuestion);
|
|
|
} else {
|
|
|
console.log('没有找到对应的追问问题,继续下一个问题');
|
|
|
- this.retryCount = 0; // 重置重试次数
|
|
|
+ this.retryCount = 0;
|
|
|
this.proceedToNextQuestion();
|
|
|
}
|
|
|
},
|