camera.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const api_user = require("../../api/user.js");
  4. const common_config = require("../../common/config.js");
  5. const common_assets = require("../../common/assets.js");
  6. const _sfc_main = {
  7. data() {
  8. return {
  9. cameraContext: null,
  10. devicePosition: "front",
  11. interviewStarted: true,
  12. showEndModal: false,
  13. currentQuestionIndex: 0,
  14. currentStep: 1,
  15. stepTexts: ["测试准备", "回答问题", "测试结束"],
  16. progressWidth: 50,
  17. remainingTime: "00:27",
  18. selectedOption: null,
  19. selectedOptions: [],
  20. showResult: false,
  21. isAnswerCorrect: false,
  22. questions: [],
  23. // 改为空数组,将通过API获取
  24. interviewId: null,
  25. // 存储当前面试ID
  26. useVideo: false,
  27. timerInterval: null,
  28. score: 0,
  29. totalQuestions: 0,
  30. interviewCompleted: false,
  31. digitalHumanUrl: "",
  32. // 数字人URL
  33. loading: true,
  34. // 添加加载状态
  35. loadError: false,
  36. // 添加加载错误状态
  37. errorMessage: "",
  38. // 添加错误消息
  39. answers: [],
  40. // 存储用户的所有答案
  41. currentQuestionDetail: null,
  42. // 当前题目详情
  43. isSubmitting: false,
  44. // 是否正在提交答案
  45. openQuestionAnswer: "",
  46. // 存储开放问题的答案
  47. currentAnswer: null,
  48. // 存储当前答案以便提交
  49. questionStartTime: null,
  50. // 存储问题开始时间
  51. mode: "normal",
  52. // 相机模式
  53. currentScrollId: "question-0",
  54. // 当前滚动到的问题ID
  55. questionGroups: [],
  56. // 存储分组后的题目
  57. currentGroupIndex: 0,
  58. // 当前显示的组索引
  59. showContinueButton: false,
  60. // 是否显示继续按钮
  61. scrollToBottom: false,
  62. // 新增:是否需要滚动到底部
  63. scrollTop: 0
  64. // 控制 scroll-view 的滚动位置
  65. };
  66. },
  67. computed: {
  68. currentQuestion() {
  69. console.log(this.questions[this.currentQuestionIndex]);
  70. return this.questions[this.currentQuestionIndex];
  71. }
  72. },
  73. onLoad(options) {
  74. if (options && options.id) {
  75. this.interviewId = options.id;
  76. this.fetchInterviewData();
  77. } else {
  78. this.fetchInterviewList();
  79. }
  80. },
  81. onReady() {
  82. this.cameraContext = common_vendor.index.createCameraContext();
  83. if (this.useVideo) {
  84. this.aiVideoContext = common_vendor.index.createVideoContext("aiInterviewer");
  85. }
  86. this.initDigitalHuman();
  87. },
  88. methods: {
  89. // 获取面试列表
  90. async fetchInterviewList() {
  91. try {
  92. this.loading = true;
  93. const res2 = await api_user.getQuestions({
  94. position_id: JSON.parse(common_vendor.index.getStorageSync("selectedJob")).id,
  95. page: 1,
  96. limit: 999,
  97. tenant_id: JSON.parse(common_vendor.index.getStorageSync("userInfo")).tenant_id || 1
  98. });
  99. console.log(res2.items);
  100. this.interviewId = res2.items;
  101. this.fetchInterviewData(res2.items);
  102. } catch (error) {
  103. console.error("获取面试列表失败:", error);
  104. this.handleLoadError("获取面试列表失败");
  105. }
  106. },
  107. // 获取面试详情数据
  108. async fetchInterviewData(data) {
  109. try {
  110. this.loading = true;
  111. if (data && Array.isArray(data)) {
  112. const formattedQuestions = data.filter((q) => q.question_form !== 0).map((q, index) => ({
  113. id: q.id || index + 1,
  114. text: q.question || "未知问题",
  115. options: q.options || [],
  116. correctAnswer: q.correctAnswer || 0,
  117. isImportant: q.is_system || false,
  118. explanation: q.explanation || "",
  119. questionType: q.question_form,
  120. questionTypeName: q.question_form_name || "单选题",
  121. is_required_correct: q.is_required_correct || false,
  122. correctAnswers: q.correct_answers || [],
  123. difficulty: q.difficulty || 1,
  124. difficultyName: q.difficulty_name || "初级",
  125. imageUrl: q.question_image_url || "",
  126. // 添加图片URL字段
  127. category: q.category || 0
  128. // 添加 category 字段
  129. }));
  130. this.processQuestionGroups(formattedQuestions);
  131. } else {
  132. this.processInterviewData(res);
  133. }
  134. console.log(this.questions);
  135. this.totalQuestions = this.questions.length;
  136. } catch (error) {
  137. console.error("获取面试详情失败:", error);
  138. this.handleLoadError("获取面试详情失败");
  139. } finally {
  140. this.loading = false;
  141. }
  142. },
  143. // 处理面试数据
  144. processInterviewData(data) {
  145. this.questions = [];
  146. if (data && data.question_form !== 0) {
  147. const formattedQuestion = {
  148. id: data.id || 1,
  149. text: data.question || "未知问题",
  150. options: data.options || [],
  151. correctAnswer: data.correctAnswer || 0,
  152. isImportant: data.is_system || false,
  153. explanation: data.explanation || "",
  154. questionType: data.question_form,
  155. // 1-单选题,2-多选题,3-看图答题
  156. questionTypeName: data.question_form_name || "单选题",
  157. is_required_correct: data.is_required_correct || false,
  158. correctAnswers: data.correct_answers || [],
  159. difficulty: data.difficulty || 1,
  160. difficultyName: data.difficulty_name || "初级",
  161. imageUrl: data.question_image_url || ""
  162. // 添加图片URL字段
  163. };
  164. this.questions.push(formattedQuestion);
  165. this.totalQuestions = this.questions.length;
  166. } else {
  167. this.handleLoadError("没有可用的选择题");
  168. }
  169. },
  170. // 处理加载错误
  171. handleLoadError(message) {
  172. this.loadError = true;
  173. this.loading = false;
  174. this.errorMessage = message || "加载失败";
  175. common_vendor.index.showToast({
  176. title: message || "加载失败",
  177. icon: "none",
  178. duration: 2e3
  179. });
  180. },
  181. startTimer() {
  182. if (this.questions.length === 0)
  183. return;
  184. this.questionStartTime = /* @__PURE__ */ new Date();
  185. let seconds = 60;
  186. this.remainingTime = `01:00`;
  187. this.timerInterval = setInterval(() => {
  188. seconds--;
  189. if (seconds <= 0) {
  190. clearInterval(this.timerInterval);
  191. if (!this.showResult) {
  192. this.checkAnswer();
  193. setTimeout(() => {
  194. if (this.currentQuestionIndex < this.questions.length - 1) {
  195. this.goToNextQuestion();
  196. } else {
  197. common_vendor.index.navigateTo({
  198. url: "/pages/interview-question/interview-question"
  199. });
  200. }
  201. }, 1500);
  202. }
  203. }
  204. const min = Math.floor(seconds / 60).toString().padStart(2, "0");
  205. const sec = (seconds % 60).toString().padStart(2, "0");
  206. this.remainingTime = `${min}:${sec}`;
  207. }, 1e3);
  208. },
  209. resetTimer() {
  210. clearInterval(this.timerInterval);
  211. },
  212. selectOption(index) {
  213. if (this.currentQuestionIndex === this.questions.length - 1 && this.showContinueButton) {
  214. common_vendor.index.showToast({
  215. title: "该题目已完成,请继续下一部分",
  216. icon: "none",
  217. duration: 2e3
  218. });
  219. return;
  220. }
  221. if (this.showResult)
  222. return;
  223. console.log("selectOption", index);
  224. if (this.currentQuestion.questionType === 2) {
  225. const optionIndex = this.selectedOptions.indexOf(index);
  226. if (optionIndex > -1) {
  227. this.selectedOptions.splice(optionIndex, 1);
  228. } else {
  229. this.selectedOptions.push(index);
  230. }
  231. } else if (this.currentQuestion.questionType === 1 || this.currentQuestion.questionType === 3 || this.currentQuestion.questionType === 4) {
  232. this.selectedOption = index;
  233. this.playAiSpeaking();
  234. setTimeout(() => {
  235. this.checkAnswer();
  236. this.saveAnswer();
  237. this.submitCurrentAnswer().then(() => {
  238. setTimeout(() => {
  239. this.goToNextQuestion();
  240. }, 800);
  241. }).catch((error) => {
  242. console.error("提交答案失败:", error);
  243. setTimeout(() => {
  244. this.goToNextQuestion();
  245. }, 1e3);
  246. });
  247. }, 500);
  248. } else {
  249. this.selectedOption = index;
  250. const answer = {
  251. questionId: this.currentQuestion.id,
  252. questionType: this.currentQuestion.questionType,
  253. answer: index
  254. };
  255. const existingIndex = this.answers.findIndex((a) => a.questionId === answer.questionId);
  256. if (existingIndex > -1) {
  257. this.answers[existingIndex] = answer;
  258. } else {
  259. this.answers.push(answer);
  260. }
  261. this.playAiSpeaking();
  262. setTimeout(() => {
  263. this.checkAnswer();
  264. this.saveAnswer();
  265. this.submitCurrentAnswer().then(() => {
  266. setTimeout(() => {
  267. this.goToNextQuestion();
  268. }, 800);
  269. }).catch((error) => {
  270. console.error("提交答案失败:", error);
  271. setTimeout(() => {
  272. this.goToNextQuestion();
  273. }, 1e3);
  274. });
  275. }, 500);
  276. }
  277. },
  278. checkAnswer() {
  279. if (this.showResult)
  280. return;
  281. clearInterval(this.timerInterval);
  282. if (!this.currentQuestion) {
  283. console.error("当前问题不存在");
  284. return;
  285. }
  286. if (this.currentQuestion.questionType === 0) {
  287. this.isAnswerCorrect = true;
  288. } else if (this.currentQuestion.questionType === 2) {
  289. const sortedSelected = [...this.selectedOptions].sort();
  290. const sortedCorrect = [...this.currentQuestion.correctAnswers].sort();
  291. if (sortedSelected.length !== sortedCorrect.length) {
  292. this.isAnswerCorrect = false;
  293. } else {
  294. this.isAnswerCorrect = sortedSelected.every((value, index) => value === sortedCorrect[index]);
  295. }
  296. } else {
  297. this.isAnswerCorrect = this.selectedOption === this.currentQuestion.correctAnswer;
  298. }
  299. this.showResult = true;
  300. this.saveAnswer();
  301. if (this.currentQuestionIndex === this.questions.length - 1) {
  302. this.$nextTick(() => {
  303. this.$forceUpdate();
  304. });
  305. }
  306. },
  307. // 修改 nextQuestion 方法,只处理多选题
  308. nextQuestion() {
  309. if (this.currentQuestion.questionType !== 2)
  310. return;
  311. this.checkAnswer();
  312. this.saveAnswer();
  313. this.submitCurrentAnswer().then(() => {
  314. setTimeout(() => {
  315. if (this.currentQuestionIndex >= this.questions.length - 1) {
  316. common_vendor.index.navigateTo({
  317. url: "/pages/interview-question/interview-question"
  318. });
  319. } else {
  320. this.goToNextQuestion();
  321. }
  322. }, 500);
  323. }).catch((error) => {
  324. console.error("提交答案失败:", error);
  325. setTimeout(() => {
  326. if (this.currentQuestionIndex >= this.questions.length - 1) {
  327. common_vendor.index.navigateTo({
  328. url: "/pages/interview-question/interview-question"
  329. });
  330. } else {
  331. this.goToNextQuestion();
  332. }
  333. }, 1e3);
  334. });
  335. },
  336. // 保存当前题目的答案
  337. saveAnswer() {
  338. let answer;
  339. if (this.currentQuestion.questionType === 0) {
  340. answer = {
  341. questionId: this.currentQuestion.id,
  342. questionType: this.currentQuestion.questionType,
  343. answer: this.openQuestionAnswer,
  344. answerDuration: this.getAnswerDuration()
  345. // 添加答题时长
  346. };
  347. } else if (this.currentQuestion.questionType === 1 || this.currentQuestion.questionType === 3 || this.currentQuestion.questionType === 4) {
  348. answer = {
  349. questionId: this.currentQuestion.id,
  350. questionType: this.currentQuestion.questionType,
  351. answer: this.selectedOption,
  352. answerDuration: this.getAnswerDuration()
  353. // 添加答题时长
  354. };
  355. } else {
  356. answer = {
  357. questionId: this.currentQuestion.id,
  358. questionType: this.currentQuestion.questionType,
  359. answer: this.selectedOptions,
  360. answerDuration: this.getAnswerDuration()
  361. // 添加答题时长
  362. };
  363. }
  364. const existingIndex = this.answers.findIndex((a) => a.questionId === answer.questionId);
  365. if (existingIndex > -1) {
  366. this.answers[existingIndex] = answer;
  367. } else {
  368. this.answers.push(answer);
  369. }
  370. this.currentAnswer = answer;
  371. console.log("已保存答案:", this.answers);
  372. },
  373. // 获取答题时长(秒)
  374. getAnswerDuration() {
  375. const remainingTimeArr = this.remainingTime.split(":");
  376. const remainingSeconds = parseInt(remainingTimeArr[0]) * 60 + parseInt(remainingTimeArr[1]);
  377. return 30 - remainingSeconds;
  378. },
  379. // 提交当前答案
  380. async submitCurrentAnswer() {
  381. if (!this.currentAnswer || this.isSubmitting)
  382. return;
  383. try {
  384. this.isSubmitting = true;
  385. common_vendor.index.showLoading({
  386. title: "正在提交答案..."
  387. });
  388. let answerContent = "";
  389. let answerOptions = [];
  390. if (this.currentAnswer.questionType === 0) {
  391. answerContent = this.currentAnswer.answer;
  392. answerOptions = [];
  393. } else if (this.currentAnswer.questionType === 1 || this.currentAnswer.questionType === 3 || this.currentAnswer.questionType === 4) {
  394. const selectedIndex = this.currentAnswer.answer;
  395. const selectedOption = this.currentQuestion.options[selectedIndex];
  396. console.log("selectedOption", selectedOption);
  397. const optionId = selectedOption.id ? selectedOption.id : selectedIndex;
  398. answerContent = optionId.toString();
  399. answerOptions = [optionId];
  400. } else if (this.currentAnswer.questionType === 2) {
  401. const selectedIndices = this.currentAnswer.answer;
  402. const selectedOptionIds = selectedIndices.map((index) => {
  403. const option = this.currentQuestion.options[index];
  404. return option.id ? option.id : index;
  405. });
  406. answerOptions = selectedOptionIds;
  407. }
  408. const submitData = {
  409. position_id: JSON.parse(common_vendor.index.getStorageSync("selectedJob")).id,
  410. applicant_id: JSON.parse(common_vendor.index.getStorageSync("userInfo")).id,
  411. job_position_question_id: this.currentAnswer.questionId,
  412. // answer_content: answerContent,
  413. answer_options: answerOptions,
  414. answer_duration: this.currentAnswer.answerDuration || 0,
  415. tenant_id: JSON.parse(common_vendor.index.getStorageSync("userInfo")).tenant_id || 1
  416. };
  417. console.log("提交数据:", submitData);
  418. const res2 = await this.$http.post(`${common_config.apiBaseUrl}/api/job/submit_answer`, submitData);
  419. console.log("提交答案响应:", res2);
  420. return res2;
  421. } catch (error) {
  422. console.error("提交答案失败:", error);
  423. common_vendor.index.showToast({
  424. title: "提交答案失败,请重试",
  425. icon: "none"
  426. });
  427. throw error;
  428. } finally {
  429. common_vendor.index.hideLoading();
  430. this.isSubmitting = false;
  431. }
  432. },
  433. // 修改 goToNextQuestion 方法
  434. async goToNextQuestion() {
  435. if (this.currentQuestionIndex >= this.questions.length - 1) {
  436. this.showContinueButton = true;
  437. setTimeout(() => {
  438. this.scrollTop = 0;
  439. this.$nextTick(() => {
  440. setTimeout(() => {
  441. this.scrollTop = 1e4;
  442. }, 100);
  443. });
  444. }, 200);
  445. return;
  446. }
  447. this.currentQuestionIndex++;
  448. this.currentScrollId = "question-" + this.currentQuestionIndex;
  449. this.showResult = false;
  450. this.selectedOption = null;
  451. this.selectedOptions = [];
  452. this.openQuestionAnswer = "";
  453. if (this.questions[this.currentQuestionIndex]) {
  454. this.progressWidth = (this.currentQuestionIndex + 1) / this.questions.length * 100;
  455. this.resetTimer();
  456. this.playAiSpeaking();
  457. setTimeout(() => {
  458. this.pauseAiSpeaking();
  459. }, 2e3);
  460. }
  461. },
  462. toggleSettings() {
  463. common_vendor.index.showToast({
  464. title: "设置功能开发中",
  465. icon: "none"
  466. });
  467. },
  468. back(target) {
  469. if (this.timerInterval) {
  470. clearInterval(this.timerInterval);
  471. }
  472. if (target) {
  473. common_vendor.index.navigateTo({
  474. url: target
  475. });
  476. return;
  477. }
  478. },
  479. error(e) {
  480. console.error(e.detail);
  481. common_vendor.index.showToast({
  482. title: "相机启动失败,请检查权限设置",
  483. icon: "none"
  484. });
  485. },
  486. playAiSpeaking() {
  487. if (this.useVideo && this.aiVideoContext) {
  488. this.aiVideoContext.play();
  489. }
  490. if (this.digitalHumanUrl) {
  491. const speakText = this.currentQuestion ? this.currentQuestion.text : "";
  492. this.interactWithDigitalHuman(speakText);
  493. }
  494. },
  495. pauseAiSpeaking() {
  496. if (this.useVideo && this.aiVideoContext) {
  497. this.aiVideoContext.pause();
  498. }
  499. },
  500. // 修改 restartTest 方法,添加可选的跳转目标
  501. restartTest(target) {
  502. this.currentQuestionIndex = 0;
  503. this.score = 0;
  504. this.showEndModal = false;
  505. this.showResult = false;
  506. this.selectedOption = null;
  507. this.selectedOptions = [];
  508. this.resetTimer();
  509. if (target) {
  510. common_vendor.index.navigateTo({
  511. url: target
  512. });
  513. }
  514. },
  515. // 在methods中添加测试方法
  516. testEndScreen() {
  517. this.interviewCompleted = true;
  518. this.showEndModal = false;
  519. },
  520. // 初始化数字人
  521. initDigitalHuman() {
  522. this.digitalHumanUrl = "";
  523. },
  524. // 与数字人交互的方法
  525. interactWithDigitalHuman(message) {
  526. const webview = this.$mp.page.$getAppWebview().children()[0];
  527. if (webview) {
  528. webview.evalJS(`receiveMessage('${message}')`);
  529. }
  530. },
  531. // 添加 navigateToInterview 方法
  532. navigateToInterview() {
  533. this.showEndModal = false;
  534. common_vendor.index.navigateTo({
  535. url: "/pages/interview/interview",
  536. success: () => {
  537. console.log("成功跳转到interview页面");
  538. },
  539. fail: (err) => {
  540. console.error("跳转失败:", err);
  541. common_vendor.index.showToast({
  542. title: "跳转失败,请手动返回首页",
  543. icon: "none"
  544. });
  545. }
  546. });
  547. },
  548. // 添加 handleCameraError 方法
  549. handleCameraError(e) {
  550. console.error("相机错误:", e.detail);
  551. common_vendor.index.showToast({
  552. title: "相机启动失败,请检查权限设置",
  553. icon: "none"
  554. });
  555. },
  556. // 修改 isOptionSelected 方法
  557. isOptionSelected(question, qIndex, optionIndex) {
  558. const answer = this.answers.find((a) => a.questionId === question.id);
  559. if (qIndex === this.currentQuestionIndex) {
  560. if (question.questionType === 1 || question.questionType === 3 || question.questionType === 4) {
  561. return this.selectedOption === optionIndex;
  562. } else if (question.questionType === 2) {
  563. return this.selectedOptions.includes(optionIndex);
  564. }
  565. } else if (answer) {
  566. if (question.questionType === 1 || question.questionType === 3 || question.questionType === 4) {
  567. return answer.answer === optionIndex;
  568. } else if (question.questionType === 2 && Array.isArray(answer.answer)) {
  569. return answer.answer.includes(optionIndex);
  570. }
  571. }
  572. return false;
  573. },
  574. // 修改 handleOptionClick 方法
  575. handleOptionClick(qIndex, index) {
  576. if (qIndex < this.currentQuestionIndex) {
  577. common_vendor.index.showToast({
  578. title: "该题目已完成,无法修改",
  579. icon: "none",
  580. duration: 2e3
  581. });
  582. return;
  583. }
  584. if (qIndex === this.questions.length - 1 && this.showContinueButton) {
  585. common_vendor.index.showToast({
  586. title: "该题目已完成,请继续下一部分",
  587. icon: "none",
  588. duration: 2e3
  589. });
  590. return;
  591. }
  592. if (qIndex > this.currentQuestionIndex) {
  593. const firstUnansweredIndex = this.currentQuestionIndex;
  594. common_vendor.index.showToast({
  595. title: `请先完成第 ${firstUnansweredIndex + 1} 题`,
  596. icon: "none",
  597. duration: 2e3
  598. });
  599. this.currentScrollId = "question-" + firstUnansweredIndex;
  600. return;
  601. }
  602. this.selectOption(index);
  603. },
  604. // 处理题目分组
  605. processQuestionGroups(questions) {
  606. const group1 = [];
  607. const group2 = [];
  608. const group3 = [];
  609. questions.forEach((q) => {
  610. if (q.category === 10 || q.category === 7) {
  611. group1.push(q);
  612. } else if (q.category === 5) {
  613. group2.push(q);
  614. } else {
  615. group3.push(q);
  616. }
  617. });
  618. this.questionGroups = [group3, group1, group2].filter((group) => group.length > 0);
  619. this.questions = this.questionGroups[0] || [];
  620. },
  621. // 处理继续按钮点击
  622. handleContinue() {
  623. if (this.currentGroupIndex < this.questionGroups.length - 1) {
  624. this.currentGroupIndex++;
  625. this.questions = this.questionGroups[this.currentGroupIndex];
  626. this.currentQuestionIndex = 0;
  627. this.showContinueButton = false;
  628. this.currentScrollId = "question-0";
  629. this.scrollTop = 0;
  630. this.selectedOption = null;
  631. this.selectedOptions = [];
  632. this.showResult = false;
  633. } else {
  634. common_vendor.index.navigateTo({
  635. url: "/pages/interview-question/interview-question"
  636. });
  637. }
  638. }
  639. },
  640. // 添加生命周期钩子,确保在组件销毁时清除计时器
  641. beforeDestroy() {
  642. if (this.timerInterval) {
  643. clearInterval(this.timerInterval);
  644. }
  645. }
  646. };
  647. if (!Array) {
  648. const _component_uni_load_more = common_vendor.resolveComponent("uni-load-more");
  649. _component_uni_load_more();
  650. }
  651. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  652. return common_vendor.e({
  653. a: !$data.digitalHumanUrl
  654. }, !$data.digitalHumanUrl ? {
  655. b: $data.mode,
  656. c: common_vendor.o((...args) => $options.handleCameraError && $options.handleCameraError(...args))
  657. } : $data.digitalHumanUrl ? {
  658. e: $data.digitalHumanUrl
  659. } : {
  660. f: common_assets._imports_0$1
  661. }, {
  662. d: $data.digitalHumanUrl,
  663. g: common_vendor.f($data.questions, (question, qIndex, i0) => {
  664. return common_vendor.e({
  665. a: common_vendor.t(qIndex + 1),
  666. b: common_vendor.t(question.questionTypeName),
  667. c: common_vendor.t(question.text),
  668. d: question.is_required_correct
  669. }, question.is_required_correct ? {} : {}, {
  670. e: question.questionType === 3 && question.imageUrl
  671. }, question.questionType === 3 && question.imageUrl ? {
  672. f: question.imageUrl
  673. } : {}, {
  674. g: question.questionType !== 0
  675. }, question.questionType !== 0 ? {
  676. h: common_vendor.f(question.options, (option, index, i1) => {
  677. return {
  678. a: common_vendor.t(option.option_text || (typeof option === "string" ? option : JSON.stringify(option))),
  679. b: index,
  680. c: $options.isOptionSelected(question, qIndex, index) ? 1 : "",
  681. d: common_vendor.o(($event) => $options.handleOptionClick(qIndex, index), index)
  682. };
  683. }),
  684. i: qIndex !== $data.currentQuestionIndex ? 1 : ""
  685. } : {}, {
  686. j: qIndex === $data.currentQuestionIndex && question.questionType === 2
  687. }, qIndex === $data.currentQuestionIndex && question.questionType === 2 ? {
  688. k: common_vendor.t("提交答案"),
  689. l: common_vendor.o(($event) => $options.nextQuestion(), question.id),
  690. m: $data.selectedOptions.length === 0
  691. } : {}, {
  692. n: question.id,
  693. o: "question-" + qIndex
  694. });
  695. }),
  696. h: common_vendor.t($data.questions.length),
  697. i: $data.showContinueButton
  698. }, $data.showContinueButton ? {
  699. j: common_vendor.t($data.currentGroupIndex < $data.questionGroups.length - 1 ? "继续下一部分" : "完成测试"),
  700. k: common_vendor.o((...args) => $options.handleContinue && $options.handleContinue(...args))
  701. } : {}, {
  702. l: $data.currentScrollId,
  703. m: $data.scrollTop,
  704. n: $data.showEndModal
  705. }, $data.showEndModal ? {
  706. o: common_vendor.o((...args) => $options.navigateToInterview && $options.navigateToInterview(...args))
  707. } : {}, {
  708. p: $data.interviewCompleted
  709. }, $data.interviewCompleted ? {
  710. q: common_assets._imports_0$1,
  711. r: common_vendor.o((...args) => $options.back && $options.back(...args))
  712. } : {}, {
  713. s: $data.loading
  714. }, $data.loading ? {
  715. t: common_vendor.p({
  716. status: "loading",
  717. contentText: {
  718. contentdown: "加载中..."
  719. }
  720. })
  721. } : {}, {
  722. v: !$data.loading && $data.loadError
  723. }, !$data.loading && $data.loadError ? {
  724. w: common_vendor.o((...args) => $options.fetchInterviewData && $options.fetchInterviewData(...args))
  725. } : {});
  726. }
  727. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
  728. wx.createPage(MiniProgramPage);