|
@@ -177,75 +177,24 @@ export default {
|
|
|
audioTranscript: '',
|
|
|
videoPlaying: false,
|
|
|
showDebugInfo: false, // 设置为true可以显示调试信息
|
|
|
- videoUrl: 'http://121.36.251.245:9000/minlong/9c139c99-a613-49f2-986b-8a3ac20a9b1b.mp4', // 用于存储AI数字人视频URL
|
|
|
+ videoUrl: '', // 修改为空字符串,将通过API获取
|
|
|
showReplayButton: false,
|
|
|
cameraStream: null, // 存储摄像头流
|
|
|
cameraError: null, // 存储摄像头错误信息
|
|
|
useMiniProgramCameraComponent: false, // 添加小程序相机组件标志
|
|
|
cameraContext: null, // 添加相机上下文
|
|
|
currentSubtitle: '',
|
|
|
- subtitles: [
|
|
|
- {
|
|
|
- startTime: 0, // 开始时间(秒)
|
|
|
- endTime: 5, // 结束时间(秒)
|
|
|
- text: '你好,我是本次面试的面试官,欢迎参加本公司的线上面试!'
|
|
|
- },
|
|
|
- {
|
|
|
- startTime: 5,
|
|
|
- endTime: 13,
|
|
|
- text: '面试预计需要15分钟,请你提前安排在网络良好、光线亮度合适、且相对安静的环境参加这次面试'
|
|
|
- },
|
|
|
- {
|
|
|
- startTime: 13,
|
|
|
- endTime: 20,
|
|
|
- text: '以免影响本次面试的结果。如果你在面试过程中遇到问题,请与我们的招聘人员联系。'
|
|
|
- }
|
|
|
- ],
|
|
|
- secondVideoSubtitles: [
|
|
|
- {
|
|
|
- startTime: 0,
|
|
|
- endTime: 10,
|
|
|
- text: '请结合您的基本信息与过往履历进行简单的自我介绍,并讲一讲您有哪些优势胜任本岗位:'
|
|
|
- }
|
|
|
- ],
|
|
|
- thirdVideoSubtitles: [
|
|
|
- {
|
|
|
- startTime: 0,
|
|
|
- endTime: 4,
|
|
|
- text: '在工作中,你如何确保个人防护装备的正确使用?'
|
|
|
- }
|
|
|
- ],
|
|
|
- fourthVideoSubtitles: [
|
|
|
- {
|
|
|
- startTime: 0,
|
|
|
- endTime: 4,
|
|
|
- text: '描述一次你与团队合作改善生产流程的经历。'
|
|
|
- }
|
|
|
- ],
|
|
|
- fifthVideoSubtitles: [
|
|
|
- {
|
|
|
- startTime: 0,
|
|
|
- endTime: 6,
|
|
|
- text: '你在团队合作中曾遇到过哪些挑战?如何解决团队内部的分歧?'
|
|
|
- }
|
|
|
- ],
|
|
|
- sixthVideoSubtitles: [
|
|
|
- {
|
|
|
- startTime: 0,
|
|
|
- endTime: 5,
|
|
|
- text: '您已完成本次面试全部题目,请问您对于这个岗位还有什么想要了解的吗?'
|
|
|
- }
|
|
|
- ],
|
|
|
+ subtitles: [], // 修改为空数组,将通过API获取
|
|
|
+ // 移除硬编码的字幕数组
|
|
|
+ // secondVideoSubtitles: [...],
|
|
|
+ // thirdVideoSubtitles: [...],
|
|
|
+ // 等等...
|
|
|
showAnswerButton: false, // 控制答题按钮显示
|
|
|
currentVideoIndex: 0, // 当前播放的视频索引
|
|
|
- videoList: [
|
|
|
- 'http://121.36.251.245:9000/minlong/tenant_1/general_uploads/880a117c8fcc4196b0d8c0750608d373.mp4', // 第一段视频
|
|
|
- 'http://121.36.251.245:9000/minlong/tenant_1/general_uploads/e465e23d377b4456bbb3b755d3ad9500.mp4', // 第二段视频
|
|
|
- 'http://121.36.251.245:9000/minlong/tenant_1/general_uploads/9bc84230d2a14978b4ea0a97e4102a15.mp4', // 第三段视频
|
|
|
- 'http://121.36.251.245:9000/minlong/tenant_1/general_uploads/9b48e824432f451d9e27e12b884d9074.mp4',
|
|
|
- 'http://121.36.251.245:9000/minlong/tenant_1/general_uploads/52f1445b400345e1a673b3c7f05e5cc1.mp4',
|
|
|
- 'http://121.36.251.245:9000/minlong/tenant_1/general_uploads/abdaa6fda8494e3a8613304743ed0433.mp4'//结束
|
|
|
- ],
|
|
|
+ videoList: [], // 修改为空数组,将通过API获取
|
|
|
+ // 其他属性保持不变...
|
|
|
+ questions: [], // 添加新属性存储API返回的问题数据
|
|
|
+ introVideoUrl: 'http://121.36.251.245:9000/minlong/tenant_1/general_uploads/880a117c8fcc4196b0d8c0750608d373.mp4', // 保留介绍视频
|
|
|
isRecording: false,
|
|
|
recordingTimer: null,
|
|
|
showStopRecordingButton: false,
|
|
@@ -279,7 +228,7 @@ export default {
|
|
|
},
|
|
|
mounted() {
|
|
|
/* this.fetchData() */
|
|
|
- this.playDigitalHumanVideo();
|
|
|
+ this.fetchQuestions(); // 添加获取问题数据的方法调用
|
|
|
this.checkAudioPermission();
|
|
|
this.initCamera();
|
|
|
this.checkIOSCameraRecordPermission();
|
|
@@ -593,7 +542,13 @@ export default {
|
|
|
|
|
|
// 播放数字人视频
|
|
|
playDigitalHumanVideo() {
|
|
|
- // 设置第一个视频
|
|
|
+ // 如果还没有加载问题数据,先获取问题数据
|
|
|
+ if (this.videoList.length === 0) {
|
|
|
+ this.fetchQuestions();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置当前视频
|
|
|
this.videoUrl = this.videoList[this.currentVideoIndex];
|
|
|
this.videoPlaying = true;
|
|
|
|
|
@@ -1596,25 +1551,24 @@ export default {
|
|
|
uploadRecordedVideo(fileOrPath) {
|
|
|
console.log('准备上传视频:', typeof fileOrPath === 'string' ? fileOrPath : fileOrPath.name);
|
|
|
|
|
|
- // 根据当前视频索引映射到正确的问题ID
|
|
|
+ // 获取当前问题ID
|
|
|
let questionId;
|
|
|
- switch(this.currentVideoIndex) {
|
|
|
- case 1: // 第一个问题
|
|
|
- questionId = 10;
|
|
|
- break;
|
|
|
- case 2: // 第二个问题
|
|
|
- questionId = 11;
|
|
|
- break;
|
|
|
- case 3: // 第三个问题
|
|
|
- questionId = 12;
|
|
|
- break;
|
|
|
- case 4: // 第四个问题
|
|
|
- questionId = 13;
|
|
|
- break;
|
|
|
- default:
|
|
|
- questionId = 10; // 默认值
|
|
|
+
|
|
|
+ // 获取当前正在回答的问题
|
|
|
+ const currentQuestion = this.getCurrentQuestionByIndex(this.currentVideoIndex);
|
|
|
+
|
|
|
+ if (currentQuestion && currentQuestion.id) {
|
|
|
+ // 直接使用API返回的问题ID
|
|
|
+ questionId = currentQuestion.id;
|
|
|
+ console.log(`使用API返回的问题ID: ${questionId}, 问题: ${currentQuestion.question}`);
|
|
|
+ } else {
|
|
|
+ // 如果没有找到对应的问题,使用默认ID
|
|
|
+ questionId = this.getDefaultQuestionId(this.currentVideoIndex);
|
|
|
+ console.log(`未找到当前问题,使用默认ID: ${questionId}`);
|
|
|
}
|
|
|
|
|
|
+ console.log('上传视频对应的问题ID:', questionId);
|
|
|
+
|
|
|
// 创建上传任务对象
|
|
|
const uploadTask = {
|
|
|
id: Date.now().toString(), // 生成唯一ID
|
|
@@ -1866,22 +1820,24 @@ export default {
|
|
|
if (task) {
|
|
|
questionId = task.questionId;
|
|
|
} else {
|
|
|
- // 根据当前视频索引映射到正确的问题ID(兼容旧代码)
|
|
|
- switch(this.currentVideoIndex) {
|
|
|
- case 1:
|
|
|
- questionId = 10;
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- questionId = 11;
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- questionId = 12;
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- questionId = 13;
|
|
|
- break;
|
|
|
- default:
|
|
|
- questionId = 10;
|
|
|
+ // 根据当前视频索引获取问题ID
|
|
|
+ if (this.currentVideoIndex >= 1 && this.questions.length > 0) {
|
|
|
+ // 获取当前正在回答的问题
|
|
|
+ const currentQuestion = this.getCurrentQuestionByIndex(this.currentVideoIndex);
|
|
|
+
|
|
|
+ if (currentQuestion && currentQuestion.id) {
|
|
|
+ // 直接使用API返回的问题ID
|
|
|
+ questionId = currentQuestion.id;
|
|
|
+ console.log(`使用API返回的问题ID: ${questionId}, 问题: ${currentQuestion.question}`);
|
|
|
+ } else {
|
|
|
+ // 如果没有找到对应的问题,使用默认ID
|
|
|
+ questionId = this.getDefaultQuestionId(this.currentVideoIndex);
|
|
|
+ console.log(`未找到当前问题,使用默认ID: ${questionId}`);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 使用旧的映射逻辑作为备用
|
|
|
+ questionId = this.getDefaultQuestionId(this.currentVideoIndex);
|
|
|
+ console.log(`使用备用问题ID: ${questionId} (问题索引: ${this.currentVideoIndex})`);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1893,6 +1849,8 @@ export default {
|
|
|
tenant_id: uni.getStorageSync('tenant_id') || '1'
|
|
|
};
|
|
|
|
|
|
+ console.log('提交面试请求参数:', requestData);
|
|
|
+
|
|
|
// 发送请求到面试接口
|
|
|
uni.request({
|
|
|
url: `${apiBaseUrl}/api/job/upload_video`,
|
|
@@ -2204,19 +2162,10 @@ export default {
|
|
|
let currentSubtitles;
|
|
|
if (this.currentVideoIndex === 0) {
|
|
|
currentSubtitles = this.subtitles;
|
|
|
- } else if (this.currentVideoIndex === 1) {
|
|
|
- currentSubtitles = this.secondVideoSubtitles;
|
|
|
- } else if (this.currentVideoIndex === 2) {
|
|
|
- currentSubtitles = this.thirdVideoSubtitles;
|
|
|
- } else if (this.currentVideoIndex === 3) {
|
|
|
- currentSubtitles = this.fourthVideoSubtitles;
|
|
|
- } else if (this.currentVideoIndex === 4) {
|
|
|
- currentSubtitles = this.fifthVideoSubtitles;
|
|
|
- } else if (this.currentVideoIndex === 5) {
|
|
|
- currentSubtitles = this.sixthVideoSubtitles;
|
|
|
} else {
|
|
|
- // 如果有更多视频,可以继续添加条件
|
|
|
- currentSubtitles = [];
|
|
|
+ // 动态获取字幕数组
|
|
|
+ const subtitleArrayName = `question${this.currentVideoIndex}Subtitles`;
|
|
|
+ currentSubtitles = this[subtitleArrayName] || [];
|
|
|
}
|
|
|
|
|
|
// 查找当前时间应该显示的字幕
|
|
@@ -2581,6 +2530,230 @@ export default {
|
|
|
const remainingSeconds = seconds % 60;
|
|
|
return `${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`;
|
|
|
},
|
|
|
+
|
|
|
+ // 添加获取问题数据的方法
|
|
|
+ fetchQuestions() {
|
|
|
+ this.loading = true;
|
|
|
+
|
|
|
+ // 获取tenant_id,如果没有则使用默认值1
|
|
|
+ const tenant_id = uni.getStorageSync('tenant_id') || '1';
|
|
|
+
|
|
|
+ uni.request({
|
|
|
+ url: `${apiBaseUrl}/api/wechat/open_questions/?position_id=1&tenant_id=${tenant_id}&question_form=0`,
|
|
|
+ method: 'GET',
|
|
|
+ success: (res) => {
|
|
|
+ if (res.data && res.data.code === 2000 && res.data.data && res.data.data.items) {
|
|
|
+ console.log('获取问题数据成功:', res.data.data.items);
|
|
|
+
|
|
|
+ // 存储问题数据
|
|
|
+ this.questions = res.data.data.items;
|
|
|
+
|
|
|
+ // 处理视频列表和字幕
|
|
|
+ this.processQuestionData();
|
|
|
+
|
|
|
+ // 播放介绍视频
|
|
|
+ this.playIntroVideo();
|
|
|
+ } else {
|
|
|
+ console.error('获取问题数据失败:', res.data);
|
|
|
+ uni.showToast({
|
|
|
+ title: '获取问题数据失败',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+
|
|
|
+ /* // 使用默认视频和字幕
|
|
|
+ this.useDefaultVideosAndSubtitles(); */
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ console.error('请求问题数据失败:', err);
|
|
|
+ uni.showToast({
|
|
|
+ title: '网络错误,请检查网络连接',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+
|
|
|
+ /* // 使用默认视频和字幕
|
|
|
+ this.useDefaultVideosAndSubtitles(); */
|
|
|
+ },
|
|
|
+ complete: () => {
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 处理问题数据,提取视频URL和字幕
|
|
|
+ processQuestionData() {
|
|
|
+ // 清空视频列表和字幕
|
|
|
+ this.videoList = [];
|
|
|
+
|
|
|
+ // 首先添加介绍视频
|
|
|
+ this.videoList.push(this.introVideoUrl);
|
|
|
+
|
|
|
+ // 为介绍视频设置字幕
|
|
|
+ this.subtitles = [
|
|
|
+ {
|
|
|
+ startTime: 0,
|
|
|
+ endTime: 5,
|
|
|
+ text: '你好,我是本次面试的面试官,欢迎参加本公司的线上面试!'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ startTime: 5,
|
|
|
+ endTime: 13,
|
|
|
+ text: '面试预计需要15分钟,请你提前安排在网络良好、光线亮度合适、且相对安静的环境参加这次面试'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ startTime: 13,
|
|
|
+ endTime: 20,
|
|
|
+ text: '以免影响本次面试的结果。如果你在面试过程中遇到问题,请与我们的招聘人员联系。'
|
|
|
+ }
|
|
|
+ ];
|
|
|
+
|
|
|
+ // 按照sequence_number排序问题
|
|
|
+ const sortedQuestions = [...this.questions].sort((a, b) => a.sequence_number - b.sequence_number);
|
|
|
+
|
|
|
+ // 只处理前5个问题(或者更少,如果问题总数不足5个)
|
|
|
+ const questionsToUse = sortedQuestions.slice(0, 5);
|
|
|
+
|
|
|
+ // 为每个问题添加视频URL和字幕
|
|
|
+ questionsToUse.forEach(question => {
|
|
|
+ // 如果有视频URL,添加到视频列表
|
|
|
+ if (question.digital_human_video_url) {
|
|
|
+ this.videoList.push(question.digital_human_video_url);
|
|
|
+
|
|
|
+ // 为这个问题创建字幕数组
|
|
|
+ const subtitleArray = [{
|
|
|
+ startTime: 0,
|
|
|
+ endTime: 10, // 默认10秒,可以根据实际情况调整
|
|
|
+ text: question.digital_human_video_subtitle || question.question
|
|
|
+ }];
|
|
|
+
|
|
|
+ // 根据问题的序号存储字幕
|
|
|
+ const index = this.videoList.length - 1; // 减1是因为我们已经添加了视频URL
|
|
|
+
|
|
|
+ // 动态创建字幕数组属性
|
|
|
+ this[`question${index}Subtitles`] = subtitleArray;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 如果没有获取到任何问题视频,使用默认视频
|
|
|
+ if (this.videoList.length <= 1) {
|
|
|
+ /* this.useDefaultVideosAndSubtitles(); */
|
|
|
+ } else {
|
|
|
+ console.log('处理后的视频列表:', this.videoList);
|
|
|
+ console.log('处理后的字幕:', this.subtitles);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 使用默认视频和字幕(作为备用)
|
|
|
+ useDefaultVideosAndSubtitles() {
|
|
|
+ console.log('使用默认视频和字幕');
|
|
|
+
|
|
|
+ // 设置默认视频列表
|
|
|
+ /* this.videoList = [
|
|
|
+ this.introVideoUrl, // 介绍视频
|
|
|
+ 'http://121.36.251.245:9000/minlong/tenant_1/general_uploads/e465e23d377b4456bbb3b755d3ad9500.mp4',
|
|
|
+ 'http://121.36.251.245:9000/minlong/tenant_1/general_uploads/9bc84230d2a14978b4ea0a97e4102a15.mp4',
|
|
|
+ 'http://121.36.251.245:9000/minlong/tenant_1/general_uploads/9b48e824432f451d9e27e12b884d9074.mp4',
|
|
|
+ 'http://121.36.251.245:9000/minlong/tenant_1/general_uploads/52f1445b400345e1a673b3c7f05e5cc1.mp4',
|
|
|
+ 'http://121.36.251.245:9000/minlong/tenant_1/general_uploads/abdaa6fda8494e3a8613304743ed0433.mp4'
|
|
|
+ ]; */
|
|
|
+
|
|
|
+ // 设置默认字幕
|
|
|
+ this.subtitles = [
|
|
|
+ {
|
|
|
+ startTime: 0,
|
|
|
+ endTime: 5,
|
|
|
+ text: '你好,我是本次面试的面试官,欢迎参加本公司的线上面试!'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ startTime: 5,
|
|
|
+ endTime: 13,
|
|
|
+ text: '面试预计需要15分钟,请你提前安排在网络良好、光线亮度合适、且相对安静的环境参加这次面试'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ startTime: 13,
|
|
|
+ endTime: 20,
|
|
|
+ text: '以免影响本次面试的结果。如果你在面试过程中遇到问题,请与我们的招聘人员联系。'
|
|
|
+ }
|
|
|
+ ];
|
|
|
+
|
|
|
+ // 设置默认问题字幕
|
|
|
+ this.question1Subtitles = [{
|
|
|
+ startTime: 0,
|
|
|
+ endTime: 10,
|
|
|
+ text: '请结合您的基本信息与过往履历进行简单的自我介绍,并讲一讲您有哪些优势胜任本岗位:'
|
|
|
+ }];
|
|
|
+
|
|
|
+ this.question2Subtitles = [{
|
|
|
+ startTime: 0,
|
|
|
+ endTime: 4,
|
|
|
+ text: '在工作中,你如何确保个人防护装备的正确使用?'
|
|
|
+ }];
|
|
|
+
|
|
|
+ this.question3Subtitles = [{
|
|
|
+ startTime: 0,
|
|
|
+ endTime: 4,
|
|
|
+ text: '描述一次你与团队合作改善生产流程的经历。'
|
|
|
+ }];
|
|
|
+
|
|
|
+ this.question4Subtitles = [{
|
|
|
+ startTime: 0,
|
|
|
+ endTime: 6,
|
|
|
+ text: '你在团队合作中曾遇到过哪些挑战?如何解决团队内部的分歧?'
|
|
|
+ }];
|
|
|
+
|
|
|
+ this.question5Subtitles = [{
|
|
|
+ startTime: 0,
|
|
|
+ endTime: 5,
|
|
|
+ text: '您已完成本次面试全部题目,请问您对于这个岗位还有什么想要了解的吗?'
|
|
|
+ }];
|
|
|
+ },
|
|
|
+
|
|
|
+ // 播放介绍视频
|
|
|
+ playIntroVideo() {
|
|
|
+ // 设置第一个视频(介绍视频)
|
|
|
+ this.videoUrl = this.videoList[0];
|
|
|
+ this.videoPlaying = true;
|
|
|
+
|
|
|
+ this.$nextTick(() => {
|
|
|
+ const videoContext = uni.createVideoContext('myVideo', this);
|
|
|
+ if (videoContext) {
|
|
|
+ videoContext.play();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 添加新方法:获取默认问题ID
|
|
|
+ getDefaultQuestionId(videoIndex) {
|
|
|
+ // 根据视频索引映射到默认问题ID
|
|
|
+ switch(videoIndex) {
|
|
|
+ case 1: // 第一个问题
|
|
|
+ return 10;
|
|
|
+ case 2: // 第二个问题
|
|
|
+ return 11;
|
|
|
+ case 3: // 第三个问题
|
|
|
+ return 12;
|
|
|
+ case 4: // 第四个问题
|
|
|
+ return 13;
|
|
|
+ default:
|
|
|
+ return 10; // 默认值
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 添加新方法:根据索引获取当前问题
|
|
|
+ getCurrentQuestionByIndex(videoIndex) {
|
|
|
+ // 视频索引减1,因为第一个视频是介绍视频
|
|
|
+ const questionIndex = videoIndex - 1;
|
|
|
+
|
|
|
+ // 按照sequence_number排序问题
|
|
|
+ const sortedQuestions = [...this.questions].sort((a, b) => a.sequence_number - b.sequence_number);
|
|
|
+
|
|
|
+ // 检查索引是否有效
|
|
|
+ if (questionIndex >= 0 && questionIndex < sortedQuestions.length) {
|
|
|
+ return sortedQuestions[questionIndex];
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ },
|
|
|
}
|
|
|
}
|
|
|
</script>
|