camera.vue 38 KB

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