camera.vue 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763
  1. <template>
  2. <view class="camera-container">
  3. <!-- 顶部相机区域 - 固定位置 -->
  4. <view class="fixed-camera-container">
  5. <view class="user-avatar">
  6. <camera v-if="!digitalHumanUrl" device-position="front" flash="auto" class="camera"
  7. :mode="mode" @error="handleCameraError"></camera>
  8. <web-view v-else-if="digitalHumanUrl" :src="digitalHumanUrl" class="digital-human-webview"></web-view>
  9. <image v-else src="/static/avatar.png" mode="aspectFill" class="avatar-image"></image>
  10. </view>
  11. </view>
  12. <!-- 主要内容区域 - 修改为流式布局 -->
  13. <scroll-view class="content-scroll" scroll-y="true" :scroll-into-view="currentScrollId" :scroll-with-animation="true" :scroll-top="scrollTop">
  14. <view class="content">
  15. <!-- 测试内容区域 - 修改为流式布局,每个问题都显示 -->
  16. <view v-for="(question, qIndex) in questions" :key="question.id" :id="'question-'+qIndex" class="interview-content">
  17. <!-- 问题编号和进度 -->
  18. <view class="question-number">
  19. <text>{{qIndex + 1}}/{{questions.length}}</text>
  20. </view>
  21. <!-- 问题和选项区域 -->
  22. <view class="question-area">
  23. <view class="question-importance">
  24. <!-- <text v-if="currentQuestion.isImportant">重点题</text> -->
  25. <text class="question-type">{{question.questionTypeName}}</text>
  26. {{question.text}}<text class="question-type" v-if="question.is_required_correct">(红线题)</text>
  27. </view>
  28. <!-- 添加图片显示区域,仅在 question_form 为 3 时显示 -->
  29. <view class="question-image-container" v-if="question.questionType === 3 && question.imageUrl">
  30. <image :src="question.imageUrl" mode="widthFix" class="question-image"></image>
  31. </view>
  32. <view class="options">
  33. <!-- 渲染非开放问题 (questionType: 1, 2 或 3) -->
  34. <view
  35. v-if="question.questionType !== 0"
  36. v-for="(option, index) in question.options"
  37. :key="index"
  38. class="option-item"
  39. :class="{
  40. 'option-selected': isOptionSelected(question, qIndex, index),
  41. 'option-disabled': qIndex !== currentQuestionIndex
  42. }"
  43. @click="handleOptionClick(qIndex, index)">
  44. <text class="option-text">{{ option.option_text || (typeof option === 'string' ? option : JSON.stringify(option)) }}</text>
  45. </view>
  46. </view>
  47. <!-- 添加当前题目的按钮 - 只在多选题时显示 -->
  48. <view class="question-button-container" v-if="qIndex === currentQuestionIndex && question.questionType === 2">
  49. <button class="next-button" @click="nextQuestion()"
  50. :disabled="selectedOptions.length === 0">
  51. {{"下一题"}}
  52. </button>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="continue-button-container" v-if="showContinueButton" id="continue-button">
  57. <button class="continue-button" @click="handleContinue">
  58. {{ currentGroupIndex < questionGroups.length - 1 ? '继续下一部分' : '完成测试' }}
  59. </button>
  60. </view>
  61. <!-- 添加底部锚点元素 -->
  62. <view id="bottom-anchor" style="height: 1px;"></view>
  63. <!-- 添加底部空白区域,确保内容不被固定按钮遮挡 -->
  64. <view class="bottom-space"></view>
  65. </view>
  66. </scroll-view>
  67. <!-- 面试结束弹窗 -->
  68. <view class="interview-end-modal" v-if="showEndModal">
  69. <view class="modal-content">
  70. <view class="modal-title">测试已完成</view>
  71. <!-- <view class="score-display">{{score}}/{{totalQuestions}}</view>
  72. <view class="modal-message">您在本次测试中答了{{score}}道题目,共{{totalQuestions}}道题目。</view> -->
  73. <view class="modal-buttons">
  74. <!-- <button type="default" class="modal-button" @click="restartTest">重新测试</button> -->
  75. <button type="primary" class="modal-button" @click="navigateToInterview">进入面试</button>
  76. </view>
  77. </view>
  78. </view>
  79. <!-- AI面试结束页面 -->
  80. <view class="interview-complete-screen" v-if="interviewCompleted">
  81. <view class="digital-avatar-large">
  82. <image src="/static/avatar.png" mode="aspectFill" class="avatar-image-large"></image>
  83. </view>
  84. <view class="complete-message">AI面试已结束</view>
  85. <view class="complete-description">本次面试的全部环节已结束。非常感谢您的参与。</view>
  86. <button class="complete-button" @click="back">我知道了</button>
  87. </view>
  88. <!-- 在模板中添加一个测试按钮(开发时使用,发布前删除) -->
  89. <!-- <button @click="testEndScreen" style="position: absolute; top: 10px; right: 10px; z-index: 9999;">测试结束页</button> -->
  90. <!-- 添加加载状态 -->
  91. <view class="loading-container" v-if="loading">
  92. <uni-load-more status="loading" :contentText="{contentdown: '加载中...'}" />
  93. <text class="loading-text">正在加载面试题目...</text>
  94. </view>
  95. <!-- 添加加载错误提示 -->
  96. <view class="loading-container" v-if="!loading && loadError">
  97. <view class="error-container">
  98. <text class="error-message">加载面试题目失败</text>
  99. <button class="retry-button" @click="fetchInterviewData">重试</button>
  100. </view>
  101. </view>
  102. <!-- 添加提示弹窗 -->
  103. <view class="prompt-modal" v-if="showPromptModal">
  104. <view class="prompt-content">
  105. <view class="prompt-title">温馨提示</view>
  106. <view class="prompt-text">
  107. 这部分是有关压力与情绪的测试,<text class="bold-text">所有问题没有绝对的"正确"或"错误"答案,只需结合您目前的状态选择最匹配的程度选项。</text>
  108. </view>
  109. <view class="prompt-text">
  110. 我们更关注您当下最真实的想法和感受。就像和朋友聊天一样,依据自己的主观意识如实回答即可。您的每一个回答都将被严格保密,仅用于帮助我们更深入地认识您,助力后续的职业发展规划。
  111. </view>
  112. <view class="prompt-text">
  113. 在开始前,不妨先做几个深呼吸,调整好状态。希望您能以轻松的心态完成检测!
  114. </view>
  115. <button class="prompt-button" @click="handlePromptConfirm">确定</button>
  116. </view>
  117. </view>
  118. </view>
  119. </template>
  120. <script>
  121. import { getInterviewList, getInterviewDetail,getQuestions } from '@/api/user.js';
  122. import { apiBaseUrl } from '@/common/config.js';
  123. export default {
  124. data() {
  125. return {
  126. cameraContext: null,
  127. devicePosition: 'front',
  128. interviewStarted: true,
  129. showEndModal: false,
  130. currentQuestionIndex: 0,
  131. currentStep: 1,
  132. stepTexts: ['测试准备', '回答问题', '测试结束'],
  133. progressWidth: 50,
  134. remainingTime: '00:27',
  135. selectedOption: null,
  136. selectedOptions: [],
  137. showResult: false,
  138. isAnswerCorrect: false,
  139. questions: [], // 改为空数组,将通过API获取
  140. interviewId: null, // 存储当前面试ID
  141. useVideo: false,
  142. timerInterval: null,
  143. score: 0,
  144. totalQuestions: 0,
  145. interviewCompleted: false,
  146. digitalHumanUrl: '', // 数字人URL
  147. loading: true, // 添加加载状态
  148. loadError: false, // 添加加载错误状态
  149. errorMessage: '', // 添加错误消息
  150. answers: [], // 存储用户的所有答案
  151. currentQuestionDetail: null, // 当前题目详情
  152. isSubmitting: false, // 是否正在提交答案
  153. openQuestionAnswer: '', // 存储开放问题的答案
  154. currentAnswer: null, // 存储当前答案以便提交
  155. questionStartTime: null, // 存储问题开始时间
  156. mode: 'normal', // 相机模式
  157. currentScrollId: 'question-0', // 当前滚动到的问题ID
  158. questionGroups: [], // 存储分组后的题目
  159. currentGroupIndex: 0, // 当前显示的组索引
  160. showContinueButton: false, // 是否显示继续按钮
  161. scrollToBottom: false, // 新增:是否需要滚动到底部
  162. scrollTop: 0, // 控制 scroll-view 的滚动位置
  163. _clickTimer: null,
  164. _isClicking: false,
  165. showPromptModal: false, // 添加新的数据属性
  166. }
  167. },
  168. computed: {
  169. currentQuestion() {
  170. console.log(this.questions[this.currentQuestionIndex]);
  171. return this.questions[this.currentQuestionIndex];
  172. }
  173. },
  174. onLoad(options) {
  175. // 从路由参数中获取面试ID
  176. if (options && options.id) {
  177. this.interviewId = options.id;
  178. this.fetchInterviewData();
  179. } else {
  180. // 如果没有ID,可以获取面试列表并使用第一个
  181. this.fetchInterviewList();
  182. }
  183. },
  184. onReady() {
  185. // 创建相机上下文
  186. this.cameraContext = uni.createCameraContext();
  187. // 创建AI视频上下文
  188. if (this.useVideo) {
  189. this.aiVideoContext = uni.createVideoContext('aiInterviewer');
  190. }
  191. // 初始化数字人
  192. this.initDigitalHuman();
  193. },
  194. methods: {
  195. // 获取面试列表
  196. async fetchInterviewList() {
  197. try {
  198. this.loading = true;
  199. const res = await getQuestions({
  200. position_id:JSON.parse(uni.getStorageSync('selectedJob')).id,
  201. page:1,
  202. limit:999,
  203. tenant_id:JSON.parse(uni.getStorageSync('userInfo')).tenant_id || 1
  204. });
  205. console.log(res.items);
  206. // 使用第一个面试
  207. this.interviewId = res.items//[0].id;
  208. this.fetchInterviewData(res.items);
  209. } catch (error) {
  210. console.error('获取面试列表失败:', error);
  211. this.handleLoadError('获取面试列表失败');
  212. }
  213. },
  214. // 获取面试详情数据
  215. async fetchInterviewData(data) {
  216. try {
  217. this.loading = true;
  218. // const res = await getInterviewDetail({ id: this.interviewId });
  219. // console.log('API返回数据:', res);
  220. // 如果返回的是问题列表
  221. if (data && Array.isArray(data)) {
  222. const formattedQuestions = data
  223. .filter(q => q.question_form !== 0)
  224. .map((q, index) => ({
  225. id: q.id || index + 1,
  226. text: q.question || '未知问题',
  227. options: q.options || [],
  228. correctAnswer: q.correctAnswer || 0,
  229. isImportant: q.is_system || false,
  230. explanation: q.explanation || '',
  231. questionType: q.question_form,
  232. questionTypeName: q.question_form_name || '单选题',
  233. is_required_correct: q.is_required_correct || false,
  234. correctAnswers: q.correct_answers || [],
  235. difficulty: q.difficulty || 1,
  236. difficultyName: q.difficulty_name || '初级',
  237. imageUrl: q.question_image_url || '', // 添加图片URL字段
  238. category: q.category || 0, // 添加 category 字段
  239. }));
  240. // 处理题目分组
  241. this.processQuestionGroups(formattedQuestions);
  242. } else {
  243. // 处理单个问题
  244. this.processInterviewData(res);
  245. }
  246. console.log(this.questions);
  247. // 设置总题目数
  248. this.totalQuestions = this.questions.length;
  249. /* // 启动倒计时
  250. if (this.questions.length > 0) {
  251. this.startTimer();
  252. } */
  253. } catch (error) {
  254. console.error('获取面试详情失败:', error);
  255. this.handleLoadError('获取面试详情失败');
  256. } finally {
  257. this.loading = false;
  258. }
  259. },
  260. // 处理面试数据
  261. processInterviewData(data) {
  262. // 清空现有问题列表
  263. this.questions = [];
  264. // 检查数据格式并处理
  265. if (data && data.question_form !== 0) { // 只处理非开放问题
  266. // 创建一个格式化的问题对象
  267. const formattedQuestion = {
  268. id: data.id || 1,
  269. text: data.question || '未知问题',
  270. options: data.options || [],
  271. correctAnswer: data.correctAnswer || 0,
  272. isImportant: data.is_system || false,
  273. explanation: data.explanation || '',
  274. questionType: data.question_form, // 1-单选题,2-多选题,3-看图答题
  275. questionTypeName: data.question_form_name || '单选题',
  276. is_required_correct: data.is_required_correct || false,
  277. correctAnswers: data.correct_answers || [],
  278. difficulty: data.difficulty || 1,
  279. difficultyName: data.difficulty_name || '初级',
  280. imageUrl: data.question_image_url || '' // 添加图片URL字段
  281. };
  282. // 添加到问题列表
  283. this.questions.push(formattedQuestion);
  284. // 设置总题目数
  285. this.totalQuestions = this.questions.length;
  286. /* // 启动倒计时
  287. this.startTimer(); */
  288. } else {
  289. this.handleLoadError('没有可用的选择题');
  290. }
  291. },
  292. // 处理加载错误
  293. handleLoadError(message) {
  294. this.loadError = true;
  295. this.loading = false;
  296. this.errorMessage = message || '加载失败';
  297. uni.showToast({
  298. title: message || '加载失败',
  299. icon: 'none',
  300. duration: 2000
  301. });
  302. },
  303. startTimer() {
  304. // 确保问题已加载
  305. if (this.questions.length === 0) return;
  306. // 记录开始时间
  307. this.questionStartTime = new Date();
  308. // 设置倒计时时间(秒)
  309. let seconds = 60; // 每题60秒,可以根据需要调整
  310. this.remainingTime = `01:00`;
  311. this.timerInterval = setInterval(() => {
  312. seconds--;
  313. if (seconds <= 0) {
  314. clearInterval(this.timerInterval);
  315. // 时间到,自动提交答案并进入下一题
  316. if (!this.showResult) {
  317. this.checkAnswer();
  318. // 短暂延迟后自动进入下一题
  319. setTimeout(() => {
  320. if (this.currentQuestionIndex < this.questions.length - 1) {
  321. this.goToNextQuestion();
  322. } else {
  323. // 如果是最后一题,显示结束模态框或跳转
  324. uni.navigateTo({
  325. url: '/pages/interview-question/interview-question'
  326. });
  327. }
  328. }, 1500);
  329. }
  330. }
  331. // 格式化显示时间 (不再显示,但仍然计算用于内部逻辑)
  332. const min = Math.floor(seconds / 60).toString().padStart(2, '0');
  333. const sec = (seconds % 60).toString().padStart(2, '0');
  334. this.remainingTime = `${min}:${sec}`;
  335. }, 1000);
  336. },
  337. resetTimer() {
  338. clearInterval(this.timerInterval);
  339. /* this.startTimer(); */
  340. },
  341. selectOption(index) {
  342. // 如果是最后一题且已经显示继续按钮,不允许重复作答
  343. if (this.currentQuestionIndex === this.questions.length - 1 && this.showContinueButton) {
  344. uni.showToast({
  345. title: '该题目已完成,请继续下一部分',
  346. icon: 'none',
  347. duration: 2000
  348. });
  349. return;
  350. }
  351. // 如果已经显示结果,不允许再次选择
  352. if (this.showResult) return;
  353. console.log('selectOption', index);
  354. // 判断当前题目类型
  355. if (this.currentQuestion.questionType === 2) {
  356. // 如果已经选中,则取消选中
  357. const optionIndex = this.selectedOptions.indexOf(index);
  358. if (optionIndex > -1) {
  359. this.selectedOptions.splice(optionIndex, 1);
  360. } else {
  361. // 否则添加到已选中数组
  362. this.selectedOptions.push(index);
  363. }
  364. // 多选题不自动提交,需要用户手动点击"提交答案"按钮
  365. } else if (this.currentQuestion.questionType === 1 || this.currentQuestion.questionType === 3 || this.currentQuestion.questionType === 4) {
  366. this.selectedOption = index;
  367. this.playAiSpeaking();
  368. setTimeout(() => {
  369. this.checkAnswer();
  370. this.saveAnswer();
  371. this.submitCurrentAnswer().then(() => {
  372. setTimeout(() => {
  373. this.goToNextQuestion();
  374. }, 800);
  375. }).catch(error => {
  376. console.error('提交答案失败:', error);
  377. setTimeout(() => {
  378. this.goToNextQuestion();
  379. }, 1000);
  380. });
  381. }, 500);
  382. } else {
  383. // 单选题逻辑
  384. this.selectedOption = index;
  385. // 保存答案到 answers 数组
  386. const answer = {
  387. questionId: this.currentQuestion.id,
  388. questionType: this.currentQuestion.questionType,
  389. answer: index
  390. };
  391. const existingIndex = this.answers.findIndex(a => a.questionId === answer.questionId);
  392. if (existingIndex > -1) {
  393. this.answers[existingIndex] = answer;
  394. } else {
  395. this.answers.push(answer);
  396. }
  397. this.playAiSpeaking();
  398. setTimeout(() => {
  399. this.checkAnswer();
  400. this.saveAnswer();
  401. this.submitCurrentAnswer().then(() => {
  402. setTimeout(() => {
  403. this.goToNextQuestion();
  404. }, 800);
  405. }).catch(error => {
  406. console.error('提交答案失败:', error);
  407. setTimeout(() => {
  408. this.goToNextQuestion();
  409. }, 1000);
  410. });
  411. }, 500);
  412. }
  413. },
  414. checkAnswer() {
  415. // 如果已经显示结果,说明已经提交过答案,不再重复提交
  416. if (this.showResult) return;
  417. clearInterval(this.timerInterval); // 停止计时
  418. // 确保当前问题存在
  419. if (!this.currentQuestion) {
  420. console.error('当前问题不存在');
  421. return;
  422. }
  423. // 根据题目类型检查答案是否正确
  424. if (this.currentQuestion.questionType === 0) {
  425. this.isAnswerCorrect = true;
  426. } else if (this.currentQuestion.questionType === 2) {
  427. const sortedSelected = [...this.selectedOptions].sort();
  428. const sortedCorrect = [...this.currentQuestion.correctAnswers].sort();
  429. if (sortedSelected.length !== sortedCorrect.length) {
  430. this.isAnswerCorrect = false;
  431. } else {
  432. this.isAnswerCorrect = sortedSelected.every((value, index) => value === sortedCorrect[index]);
  433. }
  434. } else {
  435. this.isAnswerCorrect = this.selectedOption === this.currentQuestion.correctAnswer;
  436. }
  437. // 显示结果
  438. this.showResult = true;
  439. // 保存当前题目的答案
  440. this.saveAnswer();
  441. // 如果是最后一题,确保状态被保存
  442. if (this.currentQuestionIndex === this.questions.length - 1) {
  443. this.$nextTick(() => {
  444. // 强制更新视图
  445. this.$forceUpdate();
  446. });
  447. }
  448. },
  449. // 修改 nextQuestion 方法,只处理多选题
  450. nextQuestion() {
  451. // 确保当前是多选题
  452. if (this.currentQuestion.questionType !== 2) return;
  453. // 检查答案并提交
  454. this.checkAnswer();
  455. // 保存当前题目的答案
  456. this.saveAnswer();
  457. // 提交答案
  458. this.submitCurrentAnswer().then(() => {
  459. // 提交成功后,短暂延迟后自动进入下一题
  460. setTimeout(() => {
  461. // 如果是最后一题,检查是否是最后一组题目
  462. if (this.currentQuestionIndex >= this.questions.length - 1) {
  463. if (this.currentGroupIndex < this.questionGroups.length - 1) {
  464. // 如果还有下一组题目,显示继续按钮
  465. this.showContinueButton = true;
  466. // 使用延时确保按钮渲染完成后再滚动
  467. setTimeout(() => {
  468. // 先重置 scrollTop,然后再设置新值,强制触发更新
  469. this.scrollTop = 0;
  470. // 使用 nextTick 确保视图已更新
  471. this.$nextTick(() => {
  472. // 延迟设置新的滚动位置
  473. setTimeout(() => {
  474. this.scrollTop = 10000; // 一个足够大的值
  475. }, 100);
  476. });
  477. }, 200);
  478. } else {
  479. // 如果是最后一组的最后一题,跳转到面试页面
  480. uni.navigateTo({
  481. url: '/pages/interview-question/interview-question'
  482. });
  483. }
  484. } else {
  485. // 否则进入下一题
  486. this.goToNextQuestion();
  487. }
  488. }, 500); // 0.5秒后自动进入下一题
  489. }).catch(error => {
  490. console.error('提交答案失败:', error);
  491. // 即使提交失败也继续下一题
  492. setTimeout(() => {
  493. if (this.currentQuestionIndex >= this.questions.length - 1) {
  494. if (this.currentGroupIndex < this.questionGroups.length - 1) {
  495. // 如果还有下一组题目,显示继续按钮
  496. this.showContinueButton = true;
  497. // 滚动到底部
  498. setTimeout(() => {
  499. this.scrollTop = 10000;
  500. }, 200);
  501. } else {
  502. // 如果是最后一组的最后一题,跳转到面试页面
  503. uni.navigateTo({
  504. url: '/pages/interview-question/interview-question'
  505. });
  506. }
  507. } else {
  508. this.goToNextQuestion();
  509. }
  510. }, 1000);
  511. });
  512. },
  513. toggleSettings() {
  514. // 打开设置面板
  515. uni.showToast({
  516. title: '设置功能开发中',
  517. icon: 'none'
  518. });
  519. },
  520. back(target) {
  521. // 清除计时器
  522. if (this.timerInterval) {
  523. clearInterval(this.timerInterval);
  524. }
  525. // 如果指定了跳转目标
  526. if (target) {
  527. uni.navigateTo({
  528. url: target
  529. });
  530. return;
  531. }
  532. // 否则尝试返回上一页,如果失败则跳转到首页
  533. // try {
  534. // const pages = getCurrentPages();
  535. // if (pages.length > 1) {
  536. // uni.reLaunch({
  537. // url: '/pages/index/index'
  538. // });
  539. // } else {
  540. // // 如果当前是第一页,则跳转到首页
  541. // uni.reLaunch({
  542. // url: '/pages/index/index'
  543. // });
  544. // }
  545. // } catch (e) {
  546. // console.error('导航错误:', e);
  547. // // 出错时也跳转到首页
  548. // uni.reLaunch({
  549. // url: '/pages/index/index'
  550. // });
  551. // }
  552. },
  553. error(e) {
  554. // 相机错误事件
  555. console.error(e.detail);
  556. uni.showToast({
  557. title: '相机启动失败,请检查权限设置',
  558. icon: 'none'
  559. });
  560. },
  561. playAiSpeaking() {
  562. if (this.useVideo && this.aiVideoContext) {
  563. this.aiVideoContext.play();
  564. }
  565. // 触发数字人说话动画
  566. if (this.digitalHumanUrl) {
  567. // 假设当前问题的文本作为数字人要说的内容
  568. const speakText = this.currentQuestion ? this.currentQuestion.text : '';
  569. this.interactWithDigitalHuman(speakText);
  570. }
  571. },
  572. pauseAiSpeaking() {
  573. if (this.useVideo && this.aiVideoContext) {
  574. this.aiVideoContext.pause();
  575. }
  576. },
  577. // 修改 restartTest 方法,添加可选的跳转目标
  578. restartTest(target) {
  579. this.currentQuestionIndex = 0;
  580. this.score = 0;
  581. this.showEndModal = false;
  582. this.showResult = false;
  583. this.selectedOption = null;
  584. this.selectedOptions = [];
  585. this.resetTimer();
  586. // 如果指定了跳转目标
  587. if (target) {
  588. uni.navigateTo({
  589. url: target
  590. });
  591. }
  592. },
  593. // 在methods中添加测试方法
  594. testEndScreen() {
  595. this.interviewCompleted = true;
  596. this.showEndModal = false;
  597. },
  598. // 初始化数字人
  599. initDigitalHuman() {
  600. // 移除不可用的示例URL
  601. // this.digitalHumanUrl = 'https://your-digital-human-service.com/avatar?id=123';
  602. // 暂时不使用数字人服务,直接使用本地图片
  603. this.digitalHumanUrl = '';
  604. // 如果您有实际可用的数字人服务,可以在这里设置
  605. // 例如:this.digitalHumanUrl = 'https://your-actual-service.com/avatar';
  606. // 或者使用本地HTML文件(如果有的话)
  607. // this.digitalHumanUrl = '/hybrid/html/digital-human.html';
  608. },
  609. // 与数字人交互的方法
  610. interactWithDigitalHuman(message) {
  611. // 如果数字人是通过web-view加载的,可以使用postMessage与其通信
  612. const webview = this.$mp.page.$getAppWebview().children()[0];
  613. if (webview) {
  614. webview.evalJS(`receiveMessage('${message}')`);
  615. }
  616. },
  617. // 添加 navigateToInterview 方法
  618. navigateToInterview() {
  619. // 关闭模态框
  620. this.showEndModal = false;
  621. // 跳转到interview页面
  622. uni.navigateTo({
  623. url: '/pages/interview/interview',
  624. success: () => {
  625. console.log('成功跳转到interview页面');
  626. },
  627. fail: (err) => {
  628. console.error('跳转失败:', err);
  629. uni.showToast({
  630. title: '跳转失败,请手动返回首页',
  631. icon: 'none'
  632. });
  633. }
  634. });
  635. },
  636. // 添加 handleCameraError 方法
  637. handleCameraError(e) {
  638. console.error('相机错误:', e.detail);
  639. uni.showToast({
  640. title: '相机启动失败,请检查权限设置',
  641. icon: 'none'
  642. });
  643. },
  644. // 修改 isOptionSelected 方法
  645. isOptionSelected(question, qIndex, optionIndex) {
  646. // 获取该题的答案
  647. const answer = this.answers.find(a => a.questionId === question.id);
  648. // 如果是当前正在回答的题目
  649. if (qIndex === this.currentQuestionIndex) {
  650. if (question.questionType === 1 || question.questionType === 3 || question.questionType === 4) {
  651. return this.selectedOption === optionIndex;
  652. } else if (question.questionType === 2) {
  653. return this.selectedOptions.includes(optionIndex);
  654. }
  655. }
  656. // 如果是已回答过的题目,使用保存的答案
  657. else if (answer) {
  658. if (question.questionType === 1 || question.questionType === 3 || question.questionType === 4) {
  659. return answer.answer === optionIndex;
  660. } else if (question.questionType === 2 && Array.isArray(answer.answer)) {
  661. return answer.answer.includes(optionIndex);
  662. }
  663. }
  664. return false;
  665. },
  666. // 修改 handleOptionClick 方法
  667. handleOptionClick(qIndex, index) {
  668. // 如果点击的是已完成的题目
  669. if (qIndex < this.currentQuestionIndex) {
  670. uni.showToast({
  671. title: '该题目已完成,无法修改',
  672. icon: 'none',
  673. duration: 2000
  674. });
  675. return;
  676. }
  677. // 如果是最后一题且已经显示继续按钮,不允许重复作答
  678. if (qIndex === this.questions.length - 1 && this.showContinueButton) {
  679. uni.showToast({
  680. title: '该题目已完成,请继续下一部分',
  681. icon: 'none',
  682. duration: 2000
  683. });
  684. return;
  685. }
  686. // 如果点击的是还未到的题目
  687. if (qIndex > this.currentQuestionIndex) {
  688. // 查找第一个未完成的题目索引
  689. const firstUnansweredIndex = this.currentQuestionIndex;
  690. uni.showToast({
  691. title: `请先完成第 ${firstUnansweredIndex + 1} 题`,
  692. icon: 'none',
  693. duration: 2000
  694. });
  695. // 滚动到当前应该做的题目
  696. this.currentScrollId = 'question-' + firstUnansweredIndex;
  697. return;
  698. }
  699. // 防重复点击
  700. if (this._isClicking) {
  701. return;
  702. }
  703. this._isClicking = true;
  704. // 清除之前的计时器
  705. if (this._clickTimer) {
  706. clearTimeout(this._clickTimer);
  707. }
  708. try {
  709. // 如果是当前题目,调用选择逻辑
  710. this.selectOption(index);
  711. // 设置延时,防止快速重复点击
  712. this._clickTimer = setTimeout(() => {
  713. this._isClicking = false;
  714. }, 1000);
  715. } catch (error) {
  716. console.error('处理选项点击失败:', error);
  717. uni.showToast({
  718. title: '操作失败,请重试',
  719. icon: 'none'
  720. });
  721. this._isClicking = false;
  722. }
  723. },
  724. // 处理题目分组
  725. processQuestionGroups(questions) {
  726. // 创建两个分组
  727. const group1 = []; // category 为 5 的题目
  728. const group2 = []; // 其他题目
  729. // 对题目进行分类
  730. questions.forEach(q => {
  731. if (q.category === 5) {
  732. group1.push(q);
  733. } else {
  734. group2.push(q);
  735. }
  736. });
  737. // 按照要求的顺序组合题目组:先显示其他题目,再显示 category 为 5 的题目
  738. this.questionGroups = [group2, group1].filter(group => group.length > 0);
  739. // 设置当前显示的题目
  740. this.questions = this.questionGroups[0] || [];
  741. },
  742. // 处理继续按钮点击
  743. handleContinue() {
  744. if (this.currentGroupIndex < this.questionGroups.length - 1) {
  745. // 检查是否是第一组结束
  746. if (this.currentGroupIndex === 0) {
  747. this.showPromptModal = true; // 显示提示弹窗
  748. } else {
  749. this.proceedToNextGroup();
  750. }
  751. } else {
  752. // 所有组都完成了,跳转到下一个页面
  753. uni.navigateTo({
  754. url: '/pages/interview-question/interview-question'
  755. });
  756. }
  757. },
  758. // 添加新的方法处理弹窗确认
  759. handlePromptConfirm() {
  760. this.showPromptModal = false;
  761. this.proceedToNextGroup();
  762. },
  763. // 添加新的方法处理组切换逻辑
  764. proceedToNextGroup() {
  765. this.currentGroupIndex++;
  766. this.questions = this.questionGroups[this.currentGroupIndex];
  767. this.currentQuestionIndex = 0;
  768. this.showContinueButton = false;
  769. this.currentScrollId = 'question-0';
  770. // 重置滚动位置
  771. this.scrollTop = 0;
  772. // 重置相关状态
  773. this.selectedOption = null;
  774. this.selectedOptions = [];
  775. this.showResult = false;
  776. },
  777. // 保存当前题目的答案
  778. saveAnswer() {
  779. let answer;
  780. if (this.currentQuestion.questionType === 0) { // 开放问题
  781. answer = {
  782. questionId: this.currentQuestion.id,
  783. questionType: this.currentQuestion.questionType,
  784. answer: this.openQuestionAnswer,
  785. answerDuration: this.getAnswerDuration() // 添加答题时长
  786. };
  787. } else if (this.currentQuestion.questionType === 1 || this.currentQuestion.questionType === 3 || this.currentQuestion.questionType === 4) { // 单选题、看图答题或类型4题目
  788. answer = {
  789. questionId: this.currentQuestion.id,
  790. questionType: this.currentQuestion.questionType,
  791. answer: this.selectedOption,
  792. answerDuration: this.getAnswerDuration() // 添加答题时长
  793. };
  794. } else { // 多选题
  795. answer = {
  796. questionId: this.currentQuestion.id,
  797. questionType: this.currentQuestion.questionType,
  798. answer: this.selectedOptions,
  799. answerDuration: this.getAnswerDuration() // 添加答题时长
  800. };
  801. }
  802. // 检查是否已存在该题目的答案,如果存在则更新
  803. const existingIndex = this.answers.findIndex(a => a.questionId === answer.questionId);
  804. if (existingIndex > -1) {
  805. this.answers[existingIndex] = answer;
  806. } else {
  807. this.answers.push(answer);
  808. }
  809. // 保存当前答案以便提交
  810. this.currentAnswer = answer;
  811. console.log('已保存答案:', this.answers);
  812. },
  813. // 获取答题时长(秒)
  814. getAnswerDuration() {
  815. // 这里假设每题默认30秒,根据剩余时间计算用时
  816. // 您可以根据实际情况调整计算逻辑
  817. const remainingTimeArr = this.remainingTime.split(':');
  818. const remainingSeconds = parseInt(remainingTimeArr[0]) * 60 + parseInt(remainingTimeArr[1]);
  819. return 30 - remainingSeconds; // 假设每题30秒
  820. },
  821. // 提交当前答案
  822. async submitCurrentAnswer() {
  823. if (!this.currentAnswer || this.isSubmitting) return; // 如果正在提交或没有答案,则不执行
  824. try {
  825. // 设置提交状态为true
  826. this.isSubmitting = true;
  827. // 显示提交中提示
  828. uni.showLoading({
  829. title: '正在提交答案...'
  830. });
  831. // 构建提交数据
  832. let answerContent = '';
  833. let answerOptions = [];
  834. if (this.currentAnswer.questionType === 0) {
  835. // 开放题直接使用文本答案
  836. answerContent = this.currentAnswer.answer;
  837. answerOptions = [];
  838. } else if (this.currentAnswer.questionType === 1 || this.currentAnswer.questionType === 3 || this.currentAnswer.questionType === 4) {
  839. // 单选题或看图答题,获取选项ID而不是索引
  840. const selectedIndex = this.currentAnswer.answer;
  841. const selectedOption = this.currentQuestion.options[selectedIndex];
  842. console.log('selectedOption',selectedOption);
  843. const optionId = selectedOption.id ? selectedOption.id : selectedIndex;
  844. answerContent = optionId.toString();
  845. answerOptions = [optionId];
  846. } else if (this.currentAnswer.questionType === 2) {
  847. // 多选题,将选项ID数组转为逗号分隔的字符串
  848. const selectedIndices = this.currentAnswer.answer;
  849. const selectedOptionIds = selectedIndices.map(index => {
  850. const option = this.currentQuestion.options[index];
  851. // 使用选项的ID或其他唯一标识符
  852. return option.id ? option.id : index;
  853. });
  854. answerOptions = selectedOptionIds;
  855. }
  856. const submitData = {
  857. position_id: JSON.parse(uni.getStorageSync('selectedJob')).id,
  858. applicant_id: JSON.parse(uni.getStorageSync('userInfo')).id,
  859. job_position_question_id: this.currentAnswer.questionId,
  860. // answer_content: answerContent,
  861. answer_options: answerOptions,
  862. answer_duration: this.currentAnswer.answerDuration || 0,
  863. tenant_id:JSON.parse(uni.getStorageSync('userInfo')).tenant_id || 1
  864. };
  865. console.log('提交数据:', submitData);
  866. // 调用API提交答案
  867. const res = await this.$http.post(`${apiBaseUrl}/api/job/submit_answer`, submitData);
  868. console.log('提交答案响应:', res);
  869. return res;
  870. } catch (error) {
  871. console.error('提交答案失败:', error);
  872. // 显示错误提示
  873. uni.showToast({
  874. title: '提交答案失败,请重试',
  875. icon: 'none'
  876. });
  877. throw error;
  878. } finally {
  879. // 隐藏加载提示
  880. uni.hideLoading();
  881. // 重置提交状态
  882. this.isSubmitting = false;
  883. }
  884. },
  885. // 修改 goToNextQuestion 方法
  886. async goToNextQuestion() {
  887. // 检查是否完成当前组的所有题目
  888. if (this.currentQuestionIndex >= this.questions.length - 1) {
  889. // 当前组的所有题目都已完成,显示继续按钮
  890. this.showContinueButton = true;
  891. // 使用延时确保按钮渲染完成后再滚动
  892. setTimeout(() => {
  893. // 先重置 scrollTop,然后再设置新值,强制触发更新
  894. this.scrollTop = 0;
  895. // 使用 nextTick 确保视图已更新
  896. this.$nextTick(() => {
  897. // 延迟设置新的滚动位置
  898. setTimeout(() => {
  899. this.scrollTop = 10000; // 一个足够大的值
  900. }, 100);
  901. });
  902. }, 200);
  903. return;
  904. }
  905. // 如果还有下一题,继续下一题
  906. this.currentQuestionIndex++;
  907. this.currentScrollId = 'question-' + this.currentQuestionIndex;
  908. // 重置状态(只在非最后一题时重置)
  909. this.showResult = false;
  910. this.selectedOption = null;
  911. this.selectedOptions = [];
  912. this.openQuestionAnswer = '';
  913. // 如果有下一题的详情
  914. if (this.questions[this.currentQuestionIndex]) {
  915. // 更新进度
  916. this.progressWidth = (this.currentQuestionIndex + 1) / this.questions.length * 100;
  917. // 重置计时器
  918. this.resetTimer();
  919. // 播放AI介绍下一题
  920. this.playAiSpeaking();
  921. setTimeout(() => {
  922. this.pauseAiSpeaking();
  923. }, 2000);
  924. }
  925. },
  926. },
  927. // 添加生命周期钩子,确保在组件销毁时清除计时器
  928. beforeDestroy() {
  929. if (this.timerInterval) {
  930. clearInterval(this.timerInterval);
  931. }
  932. }
  933. }
  934. </script>
  935. <style>
  936. .camera-container {
  937. position: relative;
  938. width: 100%;
  939. height: 100vh;
  940. background-color: #ffffff;
  941. display: flex;
  942. flex-direction: column;
  943. overflow: hidden; /* 防止内容溢出 */
  944. }
  945. .header {
  946. height: 90rpx;
  947. /* background-color: #000000; */
  948. display: flex;
  949. align-items: center;
  950. padding: 0 30rpx;
  951. /* color: #ffffff; */
  952. }
  953. .back-button {
  954. width: 60rpx;
  955. height: 60rpx;
  956. display: flex;
  957. align-items: center;
  958. justify-content: center;
  959. }
  960. .title {
  961. flex: 1;
  962. text-align: center;
  963. font-size: 32rpx;
  964. font-weight: bold;
  965. }
  966. .controls {
  967. display: flex;
  968. gap: 30rpx;
  969. }
  970. .iconfont {
  971. font-size: 40rpx;
  972. }
  973. .content {
  974. flex: 1;
  975. display: flex;
  976. flex-direction: column;
  977. position: relative;
  978. padding: 50rpx 20rpx 0;
  979. }
  980. .progress-container {
  981. display: flex;
  982. flex-direction: column;
  983. justify-content: space-between;
  984. margin-bottom: 20rpx;
  985. }
  986. .progress-step {
  987. display: flex;
  988. align-items: center;
  989. margin-bottom: 10rpx;
  990. }
  991. .step-circle {
  992. width: 40rpx;
  993. height: 40rpx;
  994. border-radius: 50%;
  995. background-color: #e0e0e0;
  996. display: flex;
  997. align-items: center;
  998. justify-content: center;
  999. font-size: 24rpx;
  1000. margin-right: 10rpx;
  1001. }
  1002. .step-circle.active {
  1003. background-color: #ff9500;
  1004. color: #ffffff;
  1005. }
  1006. .step-text {
  1007. font-size: 24rpx;
  1008. color: #666666;
  1009. }
  1010. .progress-bar {
  1011. height: 10rpx;
  1012. background-color: #e0e0e0;
  1013. border-radius: 5rpx;
  1014. overflow: hidden;
  1015. margin-bottom: 20rpx;
  1016. }
  1017. .progress-fill {
  1018. height: 100%;
  1019. background-color: #00c853;
  1020. transition: width 0.3s;
  1021. }
  1022. .interview-content {
  1023. flex: 1;
  1024. display: flex;
  1025. flex-direction: column;
  1026. margin-bottom: 40rpx;
  1027. padding: 20rpx;
  1028. border-bottom: 1px solid #eee;
  1029. }
  1030. .video-area {
  1031. display: flex;
  1032. /* flex-direction: column; */
  1033. justify-content: space-between;
  1034. height: auto;
  1035. margin-bottom: 20rpx;
  1036. }
  1037. .video-camera {
  1038. display: flex;
  1039. flex-direction: row;
  1040. align-items: center;
  1041. justify-content: space-between;
  1042. width: 65%;
  1043. }
  1044. .interviewer {
  1045. background-color: #f5f5f5;
  1046. display: flex;
  1047. align-items: center;
  1048. justify-content: center;
  1049. position: relative;
  1050. width: 48% !important;
  1051. height: 300rpx;
  1052. }
  1053. .interviewer-video {
  1054. width: 100%;
  1055. height: 100%;
  1056. object-fit: cover;
  1057. }
  1058. .interviewer-avatar {
  1059. width: 80%;
  1060. height: 80%;
  1061. object-fit: contain;
  1062. }
  1063. .user-camera-container {
  1064. width: 48%;
  1065. height: 300rpx;
  1066. border-radius: 10rpx;
  1067. overflow: hidden;
  1068. border: 4rpx solid #ffffff;
  1069. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.2);
  1070. }
  1071. .question-area {
  1072. flex: 1;
  1073. display: flex;
  1074. flex-direction: column;
  1075. }
  1076. .question-number {
  1077. font-size: 28rpx;
  1078. color: #666;
  1079. margin-bottom: 20rpx;
  1080. }
  1081. .question-importance {
  1082. background-color: #f9f9f9;
  1083. padding: 20rpx;
  1084. border-radius: 10rpx;
  1085. margin-bottom: 20rpx;
  1086. font-size: 28rpx;
  1087. color: #333;
  1088. }
  1089. .question-importance text {
  1090. color: #ff0000;
  1091. /* margin-right: 10rpx; */
  1092. }
  1093. .options {
  1094. display: flex;
  1095. flex-direction: column;
  1096. gap: 20rpx;
  1097. margin-bottom: 30rpx;
  1098. }
  1099. .option-item {
  1100. padding: 20rpx;
  1101. background-color: #f5f5f5;
  1102. border-radius: 10rpx;
  1103. font-size: 28rpx;
  1104. transition: all 0.3s;
  1105. border: 1px solid #e0e0e0;
  1106. display: flex;
  1107. align-items: center;
  1108. cursor: pointer; /* 添加指针样式 */
  1109. }
  1110. .option-item:active {
  1111. transform: scale(0.98); /* 点击时轻微缩小效果 */
  1112. opacity: 0.9;
  1113. }
  1114. .option-selected {
  1115. background-color: #e6f7ff;
  1116. border: 1px solid #1890ff;
  1117. }
  1118. /* 添加选中后的动画效果 */
  1119. @keyframes selectedPulse {
  1120. 0% { box-shadow: 0 0 0 0 rgba(24, 144, 255, 0.4); }
  1121. 70% { box-shadow: 0 0 0 10px rgba(24, 144, 255, 0); }
  1122. 100% { box-shadow: 0 0 0 0 rgba(24, 144, 255, 0); }
  1123. }
  1124. .option-selected {
  1125. animation: selectedPulse 1.5s ease-out;
  1126. }
  1127. .option-correct {
  1128. background-color: #d4f7d4;
  1129. border: 1px solid #52c41a;
  1130. }
  1131. .option-wrong {
  1132. background-color: #fff1f0;
  1133. border: 1px solid #ff4d4f;
  1134. }
  1135. .option-text {
  1136. color: #333;
  1137. }
  1138. .timer-container {
  1139. text-align: right;
  1140. margin: 20rpx 0;
  1141. }
  1142. .timer-text {
  1143. font-size: 24rpx;
  1144. color: #666;
  1145. background-color: #f0f0f0;
  1146. padding: 6rpx 12rpx;
  1147. border-radius: 6rpx;
  1148. }
  1149. .bottom-button-container {
  1150. position: fixed;
  1151. bottom: 50px;
  1152. left: 5%;
  1153. right: 0;
  1154. padding: 20rpx;
  1155. display: flex;
  1156. justify-content: center;
  1157. z-index: 10;
  1158. }
  1159. .bottom-button-wrapper {
  1160. display: flex;
  1161. width: 100%;
  1162. justify-content: space-between;
  1163. align-items: center;
  1164. }
  1165. .timer-display {
  1166. font-size: 28rpx;
  1167. color: #666;
  1168. padding: 10rpx 20rpx;
  1169. border-radius: 6rpx;
  1170. }
  1171. .next-button {
  1172. background-color: #0039b3;
  1173. color: #ffffff;
  1174. border-radius: 10rpx;
  1175. font-size: 30rpx;
  1176. height: 80rpx;
  1177. line-height: 80rpx;
  1178. width: 90%;
  1179. text-align: center;
  1180. margin: 0;
  1181. }
  1182. .footer {
  1183. height: 100rpx;
  1184. background-color: #000000;
  1185. display: flex;
  1186. justify-content: space-between;
  1187. align-items: center;
  1188. padding: 0 30rpx;
  1189. color: #ffffff;
  1190. }
  1191. .timer {
  1192. font-size: 28rpx;
  1193. }
  1194. .next-step {
  1195. font-size: 28rpx;
  1196. }
  1197. .interview-end-modal {
  1198. position: fixed;
  1199. top: 0;
  1200. left: 0;
  1201. right: 0;
  1202. bottom: 0;
  1203. background-color: rgba(0, 0, 0, 0.5);
  1204. display: flex;
  1205. align-items: center;
  1206. justify-content: center;
  1207. z-index: 999;
  1208. }
  1209. .modal-content {
  1210. width: 80%;
  1211. background-color: #ffffff;
  1212. border-radius: 20rpx;
  1213. padding: 40rpx;
  1214. display: flex;
  1215. flex-direction: column;
  1216. align-items: center;
  1217. }
  1218. .modal-title {
  1219. font-size: 36rpx;
  1220. font-weight: bold;
  1221. margin-bottom: 30rpx;
  1222. }
  1223. .score-display {
  1224. font-size: 48rpx;
  1225. font-weight: bold;
  1226. color: #0039b3;
  1227. margin: 20rpx 0;
  1228. }
  1229. .modal-message {
  1230. font-size: 28rpx;
  1231. color: #666;
  1232. text-align: center;
  1233. margin-bottom: 40rpx;
  1234. }
  1235. .modal-buttons {
  1236. display: flex;
  1237. justify-content: space-between;
  1238. width: 100%;
  1239. margin-top: 20rpx;
  1240. }
  1241. .modal-button {
  1242. width: 45%;
  1243. }
  1244. @keyframes speaking {
  1245. 0% {
  1246. opacity: 0.8;
  1247. }
  1248. 50% {
  1249. opacity: 1;
  1250. }
  1251. 100% {
  1252. opacity: 0.8;
  1253. }
  1254. }
  1255. .speaking {
  1256. animation: speaking 1.5s infinite;
  1257. }
  1258. .digital-avatar {
  1259. display: flex;
  1260. flex-direction: row;
  1261. align-items: flex-start;
  1262. justify-content: space-between;
  1263. width: 100%;
  1264. margin-bottom: 20rpx;
  1265. }
  1266. .message-box {
  1267. width: 65%;
  1268. min-height: 120rpx;
  1269. background-color: #f5f5f5;
  1270. border-radius: 10rpx;
  1271. padding: 15rpx;
  1272. margin-right: 20rpx;
  1273. display: flex;
  1274. align-items: center;
  1275. }
  1276. .message-text {
  1277. font-size: 24rpx;
  1278. color: #333;
  1279. line-height: 1.5;
  1280. }
  1281. .user-avatar {
  1282. width: 110px;
  1283. height: 160px;
  1284. border-radius: 10rpx;
  1285. overflow: hidden;
  1286. }
  1287. .camera {
  1288. width: 100%;
  1289. height: 100%;
  1290. border-radius: 10rpx;
  1291. border: 2rpx solid #e0e0e0;
  1292. }
  1293. .avatar-image {
  1294. width: 100%;
  1295. height: 100%;
  1296. border-radius: 10rpx;
  1297. border: 2rpx solid #e0e0e0;
  1298. }
  1299. .digital-human-webview {
  1300. width: 100%;
  1301. height: 100%;
  1302. border-radius: 10rpx;
  1303. border: 2rpx solid #e0e0e0;
  1304. }
  1305. .interview-complete-screen {
  1306. position: fixed;
  1307. top: 0;
  1308. left: 0;
  1309. right: 0;
  1310. bottom: 0;
  1311. background-color: #f0f5ff;
  1312. display: flex;
  1313. flex-direction: column;
  1314. align-items: center;
  1315. justify-content: center;
  1316. z-index: 1000;
  1317. padding: 40rpx;
  1318. }
  1319. .digital-avatar-large {
  1320. width: 200rpx;
  1321. height: 200rpx;
  1322. margin-bottom: 60rpx;
  1323. }
  1324. .avatar-image-large {
  1325. width: 100%;
  1326. height: 100%;
  1327. border-radius: 30rpx;
  1328. }
  1329. .complete-message {
  1330. font-size: 40rpx;
  1331. font-weight: bold;
  1332. color: #333;
  1333. margin-bottom: 30rpx;
  1334. }
  1335. .complete-description {
  1336. font-size: 28rpx;
  1337. color: #666;
  1338. text-align: center;
  1339. margin-bottom: 80rpx;
  1340. line-height: 1.5;
  1341. }
  1342. .complete-button {
  1343. background-color: #0039b3;
  1344. color: #ffffff;
  1345. border-radius: 10rpx;
  1346. font-size: 32rpx;
  1347. padding: 20rpx 60rpx;
  1348. margin-top: 40rpx;
  1349. }
  1350. /* 添加加载状态样式 */
  1351. .loading-container {
  1352. position: absolute;
  1353. top: 0;
  1354. left: 0;
  1355. right: 0;
  1356. bottom: 0;
  1357. display: flex;
  1358. flex-direction: column;
  1359. align-items: center;
  1360. justify-content: center;
  1361. background-color: rgba(255, 255, 255, 0.9);
  1362. z-index: 100;
  1363. }
  1364. .loading-text {
  1365. margin-top: 20rpx;
  1366. font-size: 28rpx;
  1367. color: #666;
  1368. }
  1369. .error-container {
  1370. text-align: center;
  1371. }
  1372. .error-message {
  1373. font-size: 28rpx;
  1374. color: #ff4d4f;
  1375. margin-bottom: 30rpx;
  1376. }
  1377. .retry-button {
  1378. background-color: #0039b3;
  1379. color: #ffffff;
  1380. border-radius: 10rpx;
  1381. font-size: 28rpx;
  1382. padding: 10rpx 30rpx;
  1383. }
  1384. .question-type {
  1385. display: inline-block;
  1386. /* background-color: #0039b3; */
  1387. color: white;
  1388. font-size: 24rpx;
  1389. /* padding: 4rpx 5rpx; */
  1390. border-radius: 6rpx;
  1391. /* margin-right: 10rpx; */
  1392. }
  1393. /* 新增的开放问题样式 */
  1394. .open-question-container {
  1395. display: flex;
  1396. flex-direction: column;
  1397. width: 100%;
  1398. margin-bottom: 20rpx;
  1399. }
  1400. .open-question-input {
  1401. width: 100%;
  1402. height: 300rpx;
  1403. background-color: #f9f9f9;
  1404. border: 1px solid #e0e0e0;
  1405. border-radius: 10rpx;
  1406. padding: 20rpx;
  1407. font-size: 28rpx;
  1408. color: #333;
  1409. }
  1410. .word-count {
  1411. text-align: right;
  1412. font-size: 24rpx;
  1413. color: #999;
  1414. margin-top: 10rpx;
  1415. }
  1416. .option-prefix {
  1417. margin-right: 10rpx;
  1418. font-weight: bold;
  1419. color: #333;
  1420. min-width: 30rpx;
  1421. }
  1422. /* 新增的图片显示样式 */
  1423. .question-image-container {
  1424. width: 100%;
  1425. margin: 20rpx 0;
  1426. display: flex;
  1427. justify-content: center;
  1428. align-items: center;
  1429. }
  1430. .question-image {
  1431. width: 100%;
  1432. max-width: 600rpx;
  1433. border-radius: 10rpx;
  1434. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  1435. }
  1436. /* 添加滚动视图样式 */
  1437. .content-scroll {
  1438. flex: 1;
  1439. height: calc(100vh - 200px); /* 只减去顶部相机的高度 */
  1440. margin-top: 10px;
  1441. }
  1442. /* 添加底部空白区域,防止内容被固定按钮遮挡 */
  1443. .bottom-space {
  1444. height: 50rpx; /* 减小底部空白区域 */
  1445. }
  1446. /* 添加流式布局相关样式 */
  1447. .interview-content {
  1448. margin-bottom: 40rpx;
  1449. padding: 20rpx;
  1450. border-bottom: 1px solid #eee;
  1451. }
  1452. .option-disabled {
  1453. opacity: 0.7;
  1454. background-color: #f0f0f0;
  1455. }
  1456. .question-button-container {
  1457. margin-top: 20rpx;
  1458. display: flex;
  1459. justify-content: center;
  1460. }
  1461. .bottom-timer-container {
  1462. display: none;
  1463. }
  1464. /* 添加固定相机容器样式 */
  1465. .fixed-camera-container {
  1466. position: sticky;
  1467. top: 0;
  1468. width: 100%;
  1469. padding: 20rpx;
  1470. background-color: #fff;
  1471. z-index: 10;
  1472. display: flex;
  1473. justify-content: flex-start;
  1474. border-bottom: 1px solid #eee;
  1475. }
  1476. .user-avatar {
  1477. width: 110px;
  1478. height: 160px;
  1479. border-radius: 10rpx;
  1480. overflow: hidden;
  1481. }
  1482. /* 添加继续按钮样式 */
  1483. .continue-button-container {
  1484. display: flex;
  1485. justify-content: center;
  1486. padding: 20rpx;
  1487. margin-top: 20rpx;
  1488. }
  1489. .continue-button {
  1490. background-color: #0039b3;
  1491. color: #ffffff;
  1492. border-radius: 10rpx;
  1493. font-size: 30rpx;
  1494. height: 80rpx;
  1495. line-height: 80rpx;
  1496. width: 90%;
  1497. text-align: center;
  1498. }
  1499. /* 添加新的样式 */
  1500. .prompt-modal {
  1501. position: fixed;
  1502. top: 0;
  1503. left: 0;
  1504. right: 0;
  1505. bottom: 0;
  1506. background-color: rgba(0, 0, 0, 0.5);
  1507. display: flex;
  1508. align-items: center;
  1509. justify-content: center;
  1510. z-index: 1000;
  1511. }
  1512. .prompt-content {
  1513. width: 85%;
  1514. background-color: #ffffff;
  1515. border-radius: 20rpx;
  1516. padding: 40rpx;
  1517. display: flex;
  1518. flex-direction: column;
  1519. align-items: center;
  1520. }
  1521. .prompt-title {
  1522. font-size: 36rpx;
  1523. font-weight: bold;
  1524. color: #333;
  1525. margin-bottom: 30rpx;
  1526. }
  1527. .prompt-text {
  1528. font-size: 28rpx;
  1529. color: #666;
  1530. line-height: 1.6;
  1531. margin-bottom: 20rpx;
  1532. text-align: justify;
  1533. }
  1534. .bold-text {
  1535. font-weight: bold;
  1536. color: #333;
  1537. }
  1538. .prompt-button {
  1539. background-color: #0039b3;
  1540. color: #ffffff;
  1541. border-radius: 10rpx;
  1542. font-size: 30rpx;
  1543. height: 80rpx;
  1544. line-height: 80rpx;
  1545. width: 60%;
  1546. text-align: center;
  1547. margin-top: 30rpx;
  1548. }
  1549. </style>