camera.vue 42 KB

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