Przeglądaj źródła

修改使用接口返回问题

yangg 2 miesięcy temu
rodzic
commit
ccd2ec2a45

+ 6 - 0
api/user.js

@@ -153,3 +153,9 @@ export const getUserAgreement = () => {
 /* export function getPrivacyPolicy() {
   return http.get('/api/privacy-policy');
 } */
+
+/* 获取问题数据 */
+export const getQuestions = (params) => {
+  return http.get('/api/wechat/choice_questions/', params);
+};
+

+ 7 - 7
pages/camera/camera.vue

@@ -107,7 +107,7 @@
 </template>
 
 <script>
-	import { getInterviewList, getInterviewDetail } from '@/api/user.js';
+	import { getInterviewList, getInterviewDetail,getQuestions } from '@/api/user.js';
 	import { apiBaseUrl } from '@/common/config.js';
 	export default {
 		data() {
@@ -178,12 +178,12 @@
 			async fetchInterviewList() {
 				try {
 					this.loading = true;
-					const res = await getInterviewList({job_id:JSON.parse(uni.getStorageSync('selectedJob')).id,page:1,limit:999});
-					console.log(res);
+					const res = await getQuestions({position_id:JSON.parse(uni.getStorageSync('selectedJob')).id,page:1,limit:999,tenant_id:1});
+					console.log(res.items);
 										// 使用第一个面试
-					this.interviewId = res//[0].id;
+					this.interviewId = res.items//[0].id;
 					
-					this.fetchInterviewData(res);
+					this.fetchInterviewData(res.items);
 				} catch (error) {
 					console.error('获取面试列表失败:', error);
 					this.handleLoadError('获取面试列表失败');
@@ -550,9 +550,9 @@
 					}
 					
 					const submitData = {
-						job_id: JSON.parse(uni.getStorageSync('selectedJob')).id,
+						position_id: JSON.parse(uni.getStorageSync('selectedJob')).id,
 						applicant_id: JSON.parse(uni.getStorageSync('userInfo')).id,
-						question_id: this.currentAnswer.questionId,
+						job_position_question_id: this.currentAnswer.questionId,
 						// answer_content: answerContent,
 						answer_options: answerOptions, 
 						answer_duration: this.currentAnswer.answerDuration || 0,

+ 280 - 107
pages/identity-verify/identity-verify.vue

@@ -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>

+ 4 - 4
unpackage/dist/dev/mp-weixin/api/user.js

@@ -48,19 +48,19 @@ const getJobList = (params = {}) => {
 const fillUserInfo = (params) => {
   return utils_request.http.post("/api/wechat/save_user_info", params);
 };
-const getInterviewList = (params) => {
-  return utils_request.http.get("/job/questions", params);
-};
 const applyJob = (params) => {
   return utils_request.http.post("/api/job/apply", params);
 };
 const getUserAgreement = () => {
   return utils_request.http.get("/api/public/agreements/terms_of_service/");
 };
+const getQuestions = (params) => {
+  return utils_request.http.get("/api/wechat/choice_questions/", params);
+};
 exports.applyJob = applyJob;
 exports.fillUserInfo = fillUserInfo;
-exports.getInterviewList = getInterviewList;
 exports.getJobList = getJobList;
+exports.getQuestions = getQuestions;
 exports.getUserAgreement = getUserAgreement;
 exports.getUserInfo = getUserInfo;
 exports.logout = logout;

+ 6 - 6
unpackage/dist/dev/mp-weixin/pages/camera/camera.js

@@ -80,10 +80,10 @@ const _sfc_main = {
     async fetchInterviewList() {
       try {
         this.loading = true;
-        const res2 = await api_user.getInterviewList({ job_id: JSON.parse(common_vendor.index.getStorageSync("selectedJob")).id, page: 1, limit: 999 });
-        console.log(res2);
-        this.interviewId = res2;
-        this.fetchInterviewData(res2);
+        const res2 = await api_user.getQuestions({ position_id: JSON.parse(common_vendor.index.getStorageSync("selectedJob")).id, page: 1, limit: 999, tenant_id: 1 });
+        console.log(res2.items);
+        this.interviewId = res2.items;
+        this.fetchInterviewData(res2.items);
       } catch (error) {
         console.error("获取面试列表失败:", error);
         this.handleLoadError("获取面试列表失败");
@@ -356,9 +356,9 @@ const _sfc_main = {
           answerOptions = selectedOptionIds;
         }
         const submitData = {
-          job_id: JSON.parse(common_vendor.index.getStorageSync("selectedJob")).id,
+          position_id: JSON.parse(common_vendor.index.getStorageSync("selectedJob")).id,
           applicant_id: JSON.parse(common_vendor.index.getStorageSync("userInfo")).id,
-          question_id: this.currentAnswer.questionId,
+          job_position_question_id: this.currentAnswer.questionId,
           // answer_content: answerContent,
           answer_options: answerOptions,
           answer_duration: this.currentAnswer.answerDuration || 0,

+ 200 - 110
unpackage/dist/dev/mp-weixin/pages/identity-verify/identity-verify.js

@@ -13,8 +13,8 @@ const _sfc_main = {
       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,
       // 存储摄像头流
@@ -25,76 +25,23 @@ const _sfc_main = {
       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,
@@ -144,7 +91,7 @@ const _sfc_main = {
     };
   },
   mounted() {
-    this.playDigitalHumanVideo();
+    this.fetchQuestions();
     this.checkAudioPermission();
     this.initCamera();
     this.checkIOSCameraRecordPermission();
@@ -375,6 +322,10 @@ const _sfc_main = {
     },
     // 播放数字人视频
     playDigitalHumanVideo() {
+      if (this.videoList.length === 0) {
+        this.fetchQuestions();
+        return;
+      }
       this.videoUrl = this.videoList[this.currentVideoIndex];
       this.videoPlaying = true;
       this.$nextTick(() => {
@@ -1088,22 +1039,15 @@ const _sfc_main = {
     uploadRecordedVideo(fileOrPath) {
       console.log("准备上传视频:", typeof fileOrPath === "string" ? fileOrPath : fileOrPath.name);
       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) {
+        questionId = currentQuestion.id;
+        console.log(`使用API返回的问题ID: ${questionId}, 问题: ${currentQuestion.question}`);
+      } else {
+        questionId = this.getDefaultQuestionId(this.currentVideoIndex);
+        console.log(`未找到当前问题,使用默认ID: ${questionId}`);
       }
+      console.log("上传视频对应的问题ID:", questionId);
       const uploadTask = {
         id: Date.now().toString(),
         // 生成唯一ID
@@ -1281,21 +1225,18 @@ const _sfc_main = {
       if (task) {
         questionId = task.questionId;
       } else {
-        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;
+        if (this.currentVideoIndex >= 1 && this.questions.length > 0) {
+          const currentQuestion = this.getCurrentQuestionByIndex(this.currentVideoIndex);
+          if (currentQuestion && currentQuestion.id) {
+            questionId = currentQuestion.id;
+            console.log(`使用API返回的问题ID: ${questionId}, 问题: ${currentQuestion.question}`);
+          } else {
+            questionId = this.getDefaultQuestionId(this.currentVideoIndex);
+            console.log(`未找到当前问题,使用默认ID: ${questionId}`);
+          }
+        } else {
+          questionId = this.getDefaultQuestionId(this.currentVideoIndex);
+          console.log(`使用备用问题ID: ${questionId} (问题索引: ${this.currentVideoIndex})`);
         }
       }
       const requestData = {
@@ -1304,6 +1245,7 @@ const _sfc_main = {
         video_url: videoUrl,
         tenant_id: common_vendor.index.getStorageSync("tenant_id") || "1"
       };
+      console.log("提交面试请求参数:", requestData);
       common_vendor.index.request({
         url: `${common_config.apiBaseUrl}/api/job/upload_video`,
         method: "POST",
@@ -1505,18 +1447,9 @@ const _sfc_main = {
       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] || [];
       }
       const subtitle = currentSubtitles.find(
         (sub) => currentTime >= sub.startTime && currentTime < sub.endTime
@@ -1793,6 +1726,163 @@ const _sfc_main = {
       const minutes = Math.floor(seconds / 60);
       const remainingSeconds = seconds % 60;
       return `${minutes.toString().padStart(2, "0")}:${remainingSeconds.toString().padStart(2, "0")}`;
+    },
+    // 添加获取问题数据的方法
+    fetchQuestions() {
+      this.loading = true;
+      const tenant_id = common_vendor.index.getStorageSync("tenant_id") || "1";
+      common_vendor.index.request({
+        url: `${common_config.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 === 2e3 && 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);
+            common_vendor.index.showToast({
+              title: "获取问题数据失败",
+              icon: "none"
+            });
+          }
+        },
+        fail: (err) => {
+          console.error("请求问题数据失败:", err);
+          common_vendor.index.showToast({
+            title: "网络错误,请检查网络连接",
+            icon: "none"
+          });
+        },
+        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: "以免影响本次面试的结果。如果你在面试过程中遇到问题,请与我们的招聘人员联系。"
+        }
+      ];
+      const sortedQuestions = [...this.questions].sort((a, b) => a.sequence_number - b.sequence_number);
+      const questionsToUse = sortedQuestions.slice(0, 5);
+      questionsToUse.forEach((question) => {
+        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;
+          this[`question${index}Subtitles`] = subtitleArray;
+        }
+      });
+      if (this.videoList.length <= 1)
+        ;
+      else {
+        console.log("处理后的视频列表:", this.videoList);
+        console.log("处理后的字幕:", this.subtitles);
+      }
+    },
+    // 使用默认视频和字幕(作为备用)
+    useDefaultVideosAndSubtitles() {
+      console.log("使用默认视频和字幕");
+      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 = common_vendor.index.createVideoContext("myVideo", this);
+        if (videoContext) {
+          videoContext.play();
+        }
+      });
+    },
+    // 添加新方法:获取默认问题ID
+    getDefaultQuestionId(videoIndex) {
+      switch (videoIndex) {
+        case 1:
+          return 10;
+        case 2:
+          return 11;
+        case 3:
+          return 12;
+        case 4:
+          return 13;
+        default:
+          return 10;
+      }
+    },
+    // 添加新方法:根据索引获取当前问题
+    getCurrentQuestionByIndex(videoIndex) {
+      const questionIndex = videoIndex - 1;
+      const sortedQuestions = [...this.questions].sort((a, b) => a.sequence_number - b.sequence_number);
+      if (questionIndex >= 0 && questionIndex < sortedQuestions.length) {
+        return sortedQuestions[questionIndex];
+      }
+      return null;
     }
   }
 };

+ 1 - 1
unpackage/dist/dev/mp-weixin/project.config.json

@@ -8,7 +8,7 @@
     "urlCheck": false,
     "es6": true,
     "postcss": false,
-    "minified": true,
+    "minified": false,
     "newFeature": true,
     "bigPackageSizeSupport": true,
     "babelSetting": {