camera.vue 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348
  1. <template>
  2. <view class="custom-navbar" >
  3. <!-- <view class="navbar-title">我的标题</view>1:style="{paddingTop: statusBarHeight + 'px'}" -->
  4. </view>
  5. <view class="camera-container">
  6. <!-- 顶部相机区域 - 固定位置 -->
  7. <view class="fixed-camera-container">
  8. <view class="user-avatar" :class="{ 'camera-warning': showPageWarning }">
  9. <camera v-if="!digitalHumanUrl" device-position="front" flash="auto" class="camera"
  10. :mode="mode" @error="handleCameraError"></camera>
  11. <web-view v-else-if="digitalHumanUrl" :src="digitalHumanUrl" class="digital-human-webview"></web-view>
  12. <image v-else src="/static/avatar.png" mode="aspectFill" class="avatar-image"></image>
  13. </view>
  14. </view>
  15. <!-- 主要内容区域 - 修改为流式布局 -->
  16. <scroll-view class="content-scroll" scroll-y="true" :scroll-into-view="currentScrollId" :scroll-with-animation="true" :scroll-top="scrollTop">
  17. <view class="content">
  18. <!-- 测试内容区域 - 修改为流式布局,每个问题都显示 -->
  19. <view v-for="(question, qIndex) in questions" :key="question.id" :id="'question-'+qIndex" class="interview-content">
  20. <!-- 问题编号和进度 -->
  21. <view class="question-number">
  22. <text>{{qIndex + 1}}/{{questions.length}}</text>
  23. </view>
  24. <!-- 问题和选项区域 -->
  25. <view class="question-area">
  26. <view class="question-importance">
  27. <!-- <text v-if="currentQuestion.isImportant">重点题</text> -->
  28. <text class="question-type">{{question.questionTypeName}}</text>
  29. {{question.text}}<text class="question-type" v-if="question.is_required_correct">(红线题)</text>
  30. </view>
  31. <!-- 添加图片显示区域,仅在 question_form 为 3 时显示 -->
  32. <view class="question-image-container" v-if="question.questionType === 3 && question.imageUrl">
  33. <image :src="question.imageUrl" mode="widthFix" class="question-image"></image>
  34. </view>
  35. <view class="options">
  36. <!-- 渲染非开放问题 (questionType: 1, 2 或 3) -->
  37. <template v-if="question.questionType !== 0 && question.questionType !== 6">
  38. <view
  39. v-for="(option, index) in question.options"
  40. :key="index"
  41. class="option-item"
  42. :class="{
  43. 'option-selected': isOptionSelected(question, qIndex, index),
  44. 'option-disabled': qIndex !== currentQuestionIndex
  45. }"
  46. @click="handleOptionClick(qIndex, index)">
  47. <text class="option-text">{{ option.option_text || (typeof option === 'string' ? option : JSON.stringify(option)) }}</text>
  48. </view>
  49. </template>
  50. <!-- 渲染填空题 (questionType: 6) -->
  51. <view v-if="question.questionType === 6" class="blank-question-container">
  52. <!-- // <view class="blank-question-text">
  53. // <text>{{ question.text }}</text>
  54. // </view> -->
  55. <!-- 为每个空白创建输入框 -->
  56. <view class="blank-inputs" v-if="question.blanks && question.blanks.length > 0">
  57. <view v-for="(blank, blankIndex) in question.blanks" :key="blankIndex" class="blank-input-item">
  58. <text class="blank-label">第{{ blankIndex + 1 }}个空:</text>
  59. <input
  60. class="blank-input"
  61. type="text"
  62. :value="getBlankValue(question.id, blankIndex + 1)"
  63. placeholder="请填入答案"
  64. @input="handleBlankInput(question.id, blankIndex + 1, $event)"
  65. :disabled="qIndex !== currentQuestionIndex" />
  66. </view>
  67. </view>
  68. <!-- 提交按钮,只在当前题目且填写了答案时显示 -->
  69. <view class="question-button-container" v-if="qIndex === currentQuestionIndex && hasBlankAnswers(question)">
  70. <button class="next-button" @click="submitBlankQuestion(qIndex)">
  71. 下一题
  72. </button>
  73. </view>
  74. </view>
  75. </view>
  76. <!-- 添加当前题目的按钮 - 只在多选题时显示 -->
  77. <view class="question-button-container" v-if="qIndex === currentQuestionIndex && question.questionType === 2">
  78. <button class="next-button" @click="nextQuestion()"
  79. :disabled="selectedOptions.length === 0">
  80. {{"下一题"}}
  81. </button>
  82. </view>
  83. </view>
  84. </view>
  85. <view class="continue-button-container" v-if="showContinueButton" id="continue-button">
  86. <button class="continue-button" @click="handleContinue">
  87. {{ currentGroupIndex < questionGroups.length - 1 ? '继续下一部分' : '完成测试' }}
  88. </button>
  89. </view>
  90. <!-- 添加底部锚点元素 -->
  91. <view id="bottom-anchor" style="height: 1px;"></view>
  92. <!-- 添加底部空白区域,确保内容不被固定按钮遮挡 -->
  93. <view class="bottom-space"></view>
  94. </view>
  95. </scroll-view>
  96. <!-- 面试结束弹窗 -->
  97. <view class="interview-end-modal" v-if="showEndModal">
  98. <view class="modal-content">
  99. <view class="modal-title">测试已完成</view>
  100. <!-- <view class="score-display">{{score}}/{{totalQuestions}}</view>
  101. <view class="modal-message">您在本次测试中答了{{score}}道题目,共{{totalQuestions}}道题目。</view> -->
  102. <view class="modal-buttons">
  103. <!-- <button type="default" class="modal-button" @click="restartTest">重新测试</button> -->
  104. <button type="primary" class="modal-button" @click="navigateToInterview">进入面试</button>
  105. </view>
  106. </view>
  107. </view>
  108. <!-- AI面试结束页面 -->
  109. <view class="interview-complete-screen" v-if="interviewCompleted">
  110. <view class="digital-avatar-large">
  111. <image src="/static/avatar.png" mode="aspectFill" class="avatar-image-large"></image>
  112. </view>
  113. <view class="complete-message">AI面试已结束</view>
  114. <view class="complete-description">本次面试的全部环节已结束。非常感谢您的参与。</view>
  115. <button class="complete-button" @click="back">我知道了</button>
  116. </view>
  117. <!-- 在模板中添加一个测试按钮(开发时使用,发布前删除) -->
  118. <!-- <button @click="testEndScreen" style="position: absolute; top: 10px; right: 10px; z-index: 9999;">测试结束页</button> -->
  119. <!-- 添加加载状态 -->
  120. <view class="loading-container" v-if="loading">
  121. <uni-load-more status="loading" :contentText="{contentdown: '加载中...'}" />
  122. <text class="loading-text">正在加载面试题目...</text>
  123. </view>
  124. <!-- 添加加载错误提示 -->
  125. <view class="loading-container" v-if="!loading && loadError">
  126. <view class="error-container">
  127. <text class="error-message">加载面试题目失败</text>
  128. <button class="retry-button" @click="fetchInterviewData">重试</button>
  129. </view>
  130. </view>
  131. <!-- 添加提示弹窗 -->
  132. <view class="prompt-modal" v-if="showPromptModal">
  133. <view class="prompt-content">
  134. <view class="prompt-title">温馨提示</view>
  135. <view class="prompt-text">
  136. 这部分是有关压力与情绪的测试,<text class="bold-text">所有问题没有绝对的"正确"或"错误"答案,只需结合您目前的状态选择最匹配的程度选项。</text>
  137. </view>
  138. <view class="prompt-text">
  139. 我们更关注您当下最真实的想法和感受。就像和朋友聊天一样,依据自己的主观意识如实回答即可。您的每一个回答都将被严格保密,仅用于帮助我们更深入地认识您,助力后续的职业发展规划。
  140. </view>
  141. <view class="prompt-text">
  142. 在开始前,不妨先做几个深呼吸,调整好状态。希望您能以轻松的心态完成检测!
  143. </view>
  144. <button class="prompt-button" @click="handlePromptConfirm">确定</button>
  145. </view>
  146. </view>
  147. </view>
  148. </template>
  149. <script>
  150. import { getInterviewList, getInterviewDetail,getQuestions } from '@/api/user.js';
  151. import { apiBaseUrl,personDetectionWsUrl } from '@/common/config.js';
  152. export default {
  153. data() {
  154. return {
  155. cameraContext: null,
  156. devicePosition: 'front',
  157. interviewStarted: true,
  158. showEndModal: false,
  159. currentQuestionIndex: 0,
  160. currentStep: 1,
  161. stepTexts: ['测试准备', '回答问题', '测试结束'],
  162. progressWidth: 50,
  163. remainingTime: '00:27',
  164. selectedOption: null,
  165. selectedOptions: [],
  166. showResult: false,
  167. isAnswerCorrect: false,
  168. questions: [], // 改为空数组,将通过API获取
  169. interviewId: null, // 存储当前面试ID
  170. useVideo: false,
  171. timerInterval: null,
  172. score: 0,
  173. totalQuestions: 0,
  174. interviewCompleted: false,
  175. digitalHumanUrl: '', // 数字人URL
  176. loading: true, // 添加加载状态
  177. loadError: false, // 添加加载错误状态
  178. errorMessage: '', // 添加错误消息
  179. answers: [], // 存储用户的所有答案
  180. currentQuestionDetail: null, // 当前题目详情
  181. isSubmitting: false, // 是否正在提交答案
  182. openQuestionAnswer: '', // 存储开放问题的答案
  183. currentAnswer: null, // 存储当前答案以便提交
  184. questionStartTime: null, // 存储问题开始时间
  185. mode: 'normal', // 相机模式
  186. currentScrollId: 'question-0', // 当前滚动到的问题ID
  187. questionGroups: [], // 存储分组后的题目
  188. currentGroupIndex: 0, // 当前显示的组索引
  189. showContinueButton: false, // 是否显示继续按钮
  190. scrollToBottom: false, // 新增:是否需要滚动到底部
  191. scrollTop: 0, // 控制 scroll-view 的滚动位置
  192. _clickTimer: null,
  193. _isClicking: false,
  194. showPromptModal: false, // 添加新的数据属性
  195. personDetectionSocket: null, // WebSocket对象
  196. personDetectionInterval: null, // 定时器对象
  197. showCameraWarning: false, // 添加新的数据属性
  198. showPageWarning: false, // 添加新的数据属性
  199. statusBarHeight: 0,
  200. positionConfig:{},
  201. blankQuestions: [], // 存储填空题
  202. blankAnswers: [], // 存储填空题答案
  203. currentBlankAnswers: {} // 当前填空题的答案
  204. }
  205. },
  206. computed: {
  207. currentQuestion() {
  208. console.log(this.questions[this.currentQuestionIndex]);
  209. return this.questions[this.currentQuestionIndex];
  210. }
  211. },
  212. onLoad(options) {
  213. // 从路由参数中获取面试ID
  214. if (options && options.id) {
  215. this.interviewId = options.id;
  216. this.fetchInterviewData();
  217. } else {
  218. // 如果没有ID,可以获取面试列表并使用第一个
  219. this.fetchInterviewList();
  220. }
  221. this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0
  222. this.positionConfig = JSON.parse(uni.getStorageSync('configData'))
  223. },
  224. onReady() {
  225. // 创建相机上下文
  226. this.cameraContext = uni.createCameraContext();
  227. // 创建AI视频上下文
  228. if (this.useVideo) {
  229. this.aiVideoContext = uni.createVideoContext('aiInterviewer');
  230. }
  231. // 初始化数字人
  232. this.initDigitalHuman();
  233. },
  234. mounted() {
  235. this.positionConfig = JSON.parse(uni.getStorageSync('configData'))
  236. // 添加截屏监听
  237. uni.onUserCaptureScreen(() => {
  238. console.log('User captured screen');
  239. this.screenCaptureCount++;
  240. if (this.screenCaptureCount === 1) {
  241. uni.showModal({
  242. title: 'Warning',
  243. content: '检测到屏幕截图。如果你再次捕捉屏幕,你的面试将无效.',
  244. showCancel: false,
  245. confirmText: 'OK'
  246. });
  247. } else if (this.screenCaptureCount >= 2) {
  248. uni.showModal({
  249. title: 'Interview Invalid',
  250. content: '由于多次屏幕截图,您的面试已无效。请联系招聘人员寻求帮助.',
  251. showCancel: false,
  252. confirmText: 'OK',
  253. success: () => {
  254. this.invalidateInterview();
  255. }
  256. });
  257. }
  258. });
  259. },
  260. beforeDestroy() {
  261. // 移除截屏
  262. this.cleanupPersonDetectionWebSocket();
  263. },
  264. methods: {
  265. initPersonDetectionWebSocket() {
  266. if (this.personDetectionSocket) {
  267. this.cleanupPersonDetectionWebSocket();
  268. }
  269. try {
  270. this.personDetectionSocket = uni.connectSocket({
  271. url: `${personDetectionWsUrl}/ws/interview-room/room_${uni.getStorageSync('appId')}/${uni.getStorageSync('appId')}/`,
  272. success: () => {
  273. console.log('WebSocket connection initiated');
  274. },
  275. fail: (error) => {
  276. console.error('WebSocket connection failed:', error);
  277. }
  278. });
  279. this.personDetectionSocket.onOpen(() => {
  280. console.log('WebSocket connection opened');
  281. this.startPersonDetectionInterval();
  282. });
  283. this.personDetectionSocket.onError((error) => {
  284. console.error('WebSocket error:', error);
  285. this.cleanupPersonDetectionWebSocket();
  286. });
  287. this.personDetectionSocket.onClose(() => {
  288. console.log('WebSocket connection closed');
  289. this.cleanupPersonDetectionWebSocket();
  290. });
  291. this.personDetectionSocket.onMessage((res) => {
  292. try {
  293. const data = JSON.parse(res.data);
  294. console.log(data);
  295. if (data.type === 'person_detection_result') {
  296. this.handlePersonDetectionResult(data);
  297. }
  298. } catch (error) {
  299. console.error('Error parsing WebSocket message:', error);
  300. }
  301. });
  302. } catch (error) {
  303. console.error('Error initializing WebSocket:', error);
  304. this.cleanupPersonDetectionWebSocket();
  305. }
  306. },
  307. startPersonDetectionInterval() {
  308. if (this.personDetectionInterval) {
  309. clearInterval(this.personDetectionInterval);
  310. }
  311. this.personDetectionInterval = setInterval(() => {
  312. if (this.personDetectionSocket && this.cameraContext) {
  313. this.cameraContext.takePhoto({
  314. quality: 'low',
  315. success: (res) => {
  316. const tempFilePath = res.tempImagePath;
  317. uni.getFileSystemManager().readFile({
  318. filePath: tempFilePath,
  319. encoding: 'base64',
  320. success: (res) => {
  321. const base64Image = res.data;
  322. this.personDetectionSocket.send({
  323. data: JSON.stringify({
  324. type: 'person_detection',
  325. image_data: base64Image
  326. })
  327. });
  328. },
  329. fail: (error) => {
  330. console.error('Error reading image file:', error);
  331. }
  332. });
  333. },
  334. fail: (error) => {
  335. console.error('Error taking photo:', error);
  336. }
  337. });
  338. }
  339. }, 3000);
  340. },
  341. cleanupPersonDetectionWebSocket() {
  342. if (this.personDetectionInterval) {
  343. clearInterval(this.personDetectionInterval);
  344. this.personDetectionInterval = null;
  345. }
  346. if (this.personDetectionSocket) {
  347. try {
  348. this.personDetectionSocket.close();
  349. } catch (error) {
  350. console.error('Error closing WebSocket:', error);
  351. }
  352. this.personDetectionSocket = null;
  353. }
  354. },
  355. handlePersonDetectionResult(data) {
  356. console.log(data.data.detection.has_person);
  357. console.log(data.data.identity.status);//identity_verified
  358. // 首先检查是否有人
  359. /* if (!data.data.detection.has_person) {
  360. this.showPageWarning = true;
  361. uni.showToast({
  362. title: '请勿离开摄像头',
  363. icon: 'none',
  364. duration: 3000
  365. });
  366. // 添加震动反馈
  367. uni.vibrateShort({
  368. success: function () {
  369. console.log('Vibration successful');
  370. },
  371. fail: function (err) {
  372. console.error('Vibration failed:', err);
  373. }
  374. });
  375. setTimeout(() => {
  376. this.showPageWarning = false;
  377. }, 3000);
  378. }
  379. // 然后检查身份验证状态
  380. else */ if (data.data.identity.status !== "identity_verified") {
  381. this.showPageWarning = true;
  382. uni.showToast({
  383. title: data.data.identity.message,
  384. icon: 'none',
  385. duration: 3000
  386. });
  387. uni.vibrateLong({
  388. success: function () {
  389. console.log('Vibration successful');
  390. },
  391. fail: function (err) {
  392. console.error('Vibration failed:', err);
  393. }
  394. });
  395. setTimeout(() => {
  396. this.showPageWarning = false;
  397. }, 3000);
  398. }
  399. },
  400. // 添加作废面试的方法
  401. invalidateInterview() {
  402. // 停止录制(如果正在录制)
  403. if (this.isRecording) {
  404. this.stopRecordingAnswer();
  405. }
  406. // 清除所有计时器
  407. if (this.recordingTimer) {
  408. clearInterval(this.recordingTimer);
  409. }
  410. // 重置状态
  411. this.isRecording = false;
  412. this.showStopRecordingButton = false;
  413. this.showStartRecordingButton = false;
  414. // 显示作废提示
  415. // uni.showToast({
  416. // title: 'Interview invalidated',
  417. // icon: 'none',
  418. // duration: 2000
  419. // });
  420. // 延迟后返回上一页
  421. setTimeout(() => {
  422. uni.switchTab({
  423. url: '/pages/index/index'
  424. });
  425. }, 500);
  426. const systemInfo = uni.getSystemInfoSync();
  427. const isMiniProgram = systemInfo.uniPlatform && systemInfo.uniPlatform.startsWith('mp-');
  428. if (isMiniProgram) {
  429. this.initPersonDetectionWebSocket();
  430. }
  431. },
  432. // 获取面试列表
  433. async fetchInterviewList() {
  434. try {
  435. this.loading = true;
  436. const res = await getQuestions({
  437. position_id:JSON.parse(uni.getStorageSync('selectedJob')).id,
  438. page:1,
  439. limit:999,
  440. tenant_id:uni.getStorageSync('tenant_id') ||JSON.parse(uni.getStorageSync('userInfo')).tenant_id || 1
  441. });
  442. console.log(res.items);
  443. // 使用第一个面试
  444. this.interviewId = res.items//[0].id;
  445. // 同时获取填空题
  446. await this.fetchBlankQuestions();
  447. this.fetchInterviewData(res.items);
  448. } catch (error) {
  449. console.error('获取面试列表失败:', error);
  450. this.handleLoadError('获取面试列表失败');
  451. }
  452. },
  453. // 获取面试详情数据
  454. async fetchInterviewData(data) {
  455. try {
  456. this.loading = true;
  457. // const res = await getInterviewDetail({ id: this.interviewId });
  458. // console.log('API返回数据:', res);
  459. // 如果返回的是问题列表
  460. if (data && Array.isArray(data)) {
  461. const formattedQuestions = data
  462. .filter(q => q.question_form !== 0)
  463. .map((q, index) => ({
  464. id: q.id || index + 1,
  465. text: q.question || '未知问题',
  466. options: q.options || [],
  467. correctAnswer: q.correctAnswer || 0,
  468. isImportant: q.is_system || false,
  469. explanation: q.explanation || '',
  470. questionType: q.question_form,
  471. questionTypeName: q.question_form_name || '单选题',
  472. is_required_correct: q.is_required_correct || false,
  473. correctAnswers: q.correct_answers || [],
  474. difficulty: q.difficulty || 1,
  475. difficultyName: q.difficulty_name || '初级',
  476. imageUrl: q.question_image_url || '', // 添加图片URL字段
  477. category: q.category || 0, // 添加 category 字段
  478. }));
  479. // 处理题目分组
  480. this.processQuestionGroups(formattedQuestions);
  481. } else {
  482. // 处理单个问题
  483. this.processInterviewData(res);
  484. }
  485. console.log(this.questions);
  486. // 设置总题目数
  487. this.totalQuestions = this.questions.length;
  488. /* // 启动倒计时
  489. if (this.questions.length > 0) {
  490. this.startTimer();
  491. } */
  492. } catch (error) {
  493. console.error('获取面试详情失败:', error);
  494. this.handleLoadError('获取面试详情失败');
  495. } finally {
  496. this.loading = false;
  497. }
  498. },
  499. // 获取填空题
  500. async fetchBlankQuestions() {
  501. try {
  502. const positionId = JSON.parse(uni.getStorageSync('selectedJob')).id;
  503. const tenantId = uni.getStorageSync('tenant_id') ||JSON.parse(uni.getStorageSync('userInfo')).tenant_id || 1;
  504. const res = await this.$http.get(`${apiBaseUrl}/api/wechat/blank_questions/?tenant_id=${tenantId}&position_id=${positionId}`);
  505. console.log(res)
  506. if (res && Array.isArray(res.items)) {
  507. this.blankQuestions = res.items.map((q, index) => {
  508. // 自动检测问题中的下划线数量
  509. const questionText = q.question || '';
  510. const blankPattern = /_{3,}/g;
  511. const matches = questionText.match(blankPattern) || [];
  512. const blanks = matches.map((_, blankIndex) => ({
  513. id: blankIndex + 1,
  514. index: blankIndex + 1,
  515. label: `第${blankIndex + 1}个空白`
  516. }));
  517. return {
  518. id: q.id || `blank_${index + 1}`,
  519. text: questionText,
  520. questionType: 6, // 使用 6 表示填空题
  521. questionTypeName: '填空题',
  522. blanks: blanks, // 根据下划线数量生成的空白数组
  523. category: q.category || 0
  524. };
  525. });
  526. console.log('获取填空题成功:', this.blankQuestions);
  527. } else {
  528. console.log('没有填空题数据');
  529. this.blankQuestions = [];
  530. }
  531. } catch (error) {
  532. console.error('获取填空题失败:', error);
  533. this.blankQuestions = [];
  534. }
  535. },
  536. // 处理面试数据
  537. processInterviewData(data) {
  538. // 清空现有问题列表
  539. this.questions = [];
  540. // 检查数据格式并处理
  541. if (data && data.question_form !== 0) { // 只处理非开放问题
  542. // 创建一个格式化的问题对象
  543. const formattedQuestion = {
  544. id: data.id || 1,
  545. text: data.question || '未知问题',
  546. options: data.options || [],
  547. correctAnswer: data.correctAnswer || 0,
  548. isImportant: data.is_system || false,
  549. explanation: data.explanation || '',
  550. questionType: data.question_form, // 1-单选题,2-多选题,3-看图答题
  551. questionTypeName: data.question_form_name || '单选题',
  552. is_required_correct: data.is_required_correct || false,
  553. correctAnswers: data.correct_answers || [],
  554. difficulty: data.difficulty || 1,
  555. difficultyName: data.difficulty_name || '初级',
  556. imageUrl: data.question_image_url || '' // 添加图片URL字段
  557. };
  558. // 添加到问题列表
  559. this.questions.push(formattedQuestion);
  560. // 设置总题目数
  561. this.totalQuestions = this.questions.length;
  562. /* // 启动倒计时
  563. this.startTimer(); */
  564. } else {
  565. this.handleLoadError('没有可用的选择题');
  566. }
  567. },
  568. // 处理加载错误
  569. handleLoadError(message) {
  570. this.loadError = true;
  571. this.loading = false;
  572. this.errorMessage = message || '加载失败';
  573. uni.showToast({
  574. title: message || '加载失败',
  575. icon: 'none',
  576. duration: 2000
  577. });
  578. },
  579. startTimer() {
  580. // 确保问题已加载
  581. if (this.questions.length === 0) return;
  582. // 记录开始时间
  583. this.questionStartTime = new Date();
  584. // 设置倒计时时间(秒)
  585. let seconds = 60; // 每题60秒,可以根据需要调整
  586. this.remainingTime = `01:00`;
  587. this.timerInterval = setInterval(() => {
  588. seconds--;
  589. if (seconds <= 0) {
  590. clearInterval(this.timerInterval);
  591. // 时间到,自动提交答案并进入下一题
  592. if (!this.showResult) {
  593. this.checkAnswer();
  594. // 短暂延迟后自动进入下一题
  595. setTimeout(() => {
  596. if (this.currentQuestionIndex < this.questions.length - 1) {
  597. this.goToNextQuestion();
  598. } else {
  599. // 如果是最后一题,显示结束模态框或跳转
  600. uni.navigateTo({
  601. url: '/pages/posture-guide/posture-guide'
  602. });
  603. }
  604. }, 1500);
  605. }
  606. }
  607. // 格式化显示时间 (不再显示,但仍然计算用于内部逻辑)
  608. const min = Math.floor(seconds / 60).toString().padStart(2, '0');
  609. const sec = (seconds % 60).toString().padStart(2, '0');
  610. this.remainingTime = `${min}:${sec}`;
  611. }, 1000);
  612. },
  613. resetTimer() {
  614. clearInterval(this.timerInterval);
  615. /* this.startTimer(); */
  616. },
  617. selectOption(index) {
  618. // 如果是最后一题且已经显示继续按钮,不允许重复作答
  619. if (this.currentQuestionIndex === this.questions.length - 1 && this.showContinueButton) {
  620. uni.showToast({
  621. title: '该题目已完成,请继续下一部分',
  622. icon: 'none',
  623. duration: 2000
  624. });
  625. return;
  626. }
  627. // 如果已经显示结果,不允许再次选择
  628. if (this.showResult) return;
  629. console.log('selectOption', index);
  630. // 判断当前题目类型
  631. if (this.currentQuestion.questionType === 2) {
  632. // 如果已经选中,则取消选中
  633. const optionIndex = this.selectedOptions.indexOf(index);
  634. if (optionIndex > -1) {
  635. this.selectedOptions.splice(optionIndex, 1);
  636. } else {
  637. // 否则添加到已选中数组
  638. this.selectedOptions.push(index);
  639. }
  640. // 多选题不自动提交,需要用户手动点击"提交答案"按钮
  641. } else if (this.currentQuestion.questionType === 1 || this.currentQuestion.questionType === 3 || this.currentQuestion.questionType === 4) {
  642. this.selectedOption = index;
  643. this.playAiSpeaking();
  644. setTimeout(() => {
  645. this.checkAnswer();
  646. this.saveAnswer();
  647. this.submitCurrentAnswer().then(() => {
  648. setTimeout(() => {
  649. this.goToNextQuestion();
  650. }, 800);
  651. }).catch(error => {
  652. console.error('提交答案失败:', error);
  653. setTimeout(() => {
  654. this.goToNextQuestion();
  655. }, 1000);
  656. });
  657. }, 500);
  658. } else {
  659. // 单选题逻辑
  660. this.selectedOption = index;
  661. // 保存答案到 answers 数组
  662. const answer = {
  663. questionId: this.currentQuestion.id,
  664. questionType: this.currentQuestion.questionType,
  665. answer: index
  666. };
  667. const existingIndex = this.answers.findIndex(a => a.questionId === answer.questionId);
  668. if (existingIndex > -1) {
  669. this.answers[existingIndex] = answer;
  670. } else {
  671. this.answers.push(answer);
  672. }
  673. this.playAiSpeaking();
  674. setTimeout(() => {
  675. this.checkAnswer();
  676. this.saveAnswer();
  677. this.submitCurrentAnswer().then(() => {
  678. setTimeout(() => {
  679. this.goToNextQuestion();
  680. }, 800);
  681. }).catch(error => {
  682. console.error('提交答案失败:', error);
  683. setTimeout(() => {
  684. this.goToNextQuestion();
  685. }, 1000);
  686. });
  687. }, 500);
  688. }
  689. },
  690. checkAnswer() {
  691. // 如果已经显示结果,说明已经提交过答案,不再重复提交
  692. if (this.showResult) return;
  693. clearInterval(this.timerInterval); // 停止计时
  694. // 确保当前问题存在
  695. if (!this.currentQuestion) {
  696. console.error('当前问题不存在');
  697. return;
  698. }
  699. // 根据题目类型检查答案是否正确
  700. if (this.currentQuestion.questionType === 0) {
  701. this.isAnswerCorrect = true;
  702. } else if (this.currentQuestion.questionType === 2) {
  703. const sortedSelected = [...this.selectedOptions].sort();
  704. const sortedCorrect = [...this.currentQuestion.correctAnswers].sort();
  705. if (sortedSelected.length !== sortedCorrect.length) {
  706. this.isAnswerCorrect = false;
  707. } else {
  708. this.isAnswerCorrect = sortedSelected.every((value, index) => value === sortedCorrect[index]);
  709. }
  710. } else {
  711. this.isAnswerCorrect = this.selectedOption === this.currentQuestion.correctAnswer;
  712. }
  713. // 显示结果
  714. this.showResult = true;
  715. // 保存当前题目的答案
  716. this.saveAnswer();
  717. // 如果是最后一题,确保状态被保存
  718. if (this.currentQuestionIndex === this.questions.length - 1) {
  719. this.$nextTick(() => {
  720. // 强制更新视图
  721. this.$forceUpdate();
  722. });
  723. }
  724. },
  725. // 修改 nextQuestion 方法,只处理多选题
  726. nextQuestion() {
  727. // 确保当前是多选题
  728. if (this.currentQuestion.questionType !== 2) return;
  729. // 检查答案并提交
  730. this.checkAnswer();
  731. // 保存当前题目的答案
  732. this.saveAnswer();
  733. // 提交答案
  734. this.submitCurrentAnswer().then(() => {
  735. // 提交成功后,短暂延迟后自动进入下一题
  736. setTimeout(() => {
  737. // 如果是最后一题,检查是否是最后一组题目
  738. if (this.currentQuestionIndex >= this.questions.length - 1) {
  739. if (this.currentGroupIndex < this.questionGroups.length - 1) {
  740. // 如果还有下一组题目,显示继续按钮
  741. this.showContinueButton = true;
  742. // 使用延时确保按钮渲染完成后再滚动
  743. setTimeout(() => {
  744. // 先重置 scrollTop,然后再设置新值,强制触发更新
  745. this.scrollTop = 0;
  746. // 使用 nextTick 确保视图已更新
  747. this.$nextTick(() => {
  748. // 延迟设置新的滚动位置
  749. setTimeout(() => {
  750. this.scrollTop = 10000; // 一个足够大的值
  751. }, 100);
  752. });
  753. }, 200);
  754. } else {
  755. // 如果是最后一组的最后一题,跳转到面试页面
  756. uni.navigateTo({
  757. url: '/pages/posture-guide/posture-guide'
  758. });
  759. }
  760. } else {
  761. // 否则进入下一题
  762. this.goToNextQuestion();
  763. }
  764. }, 500); // 0.5秒后自动进入下一题
  765. }).catch(error => {
  766. console.error('提交答案失败:', error);
  767. // 即使提交失败也继续下一题
  768. setTimeout(() => {
  769. if (this.currentQuestionIndex >= this.questions.length - 1) {
  770. if (this.currentGroupIndex < this.questionGroups.length - 1) {
  771. // 如果还有下一组题目,显示继续按钮
  772. this.showContinueButton = true;
  773. // 滚动到底部
  774. setTimeout(() => {
  775. this.scrollTop = 10000;
  776. }, 200);
  777. } else {
  778. // 如果是最后一组的最后一题,跳转到面试页面
  779. uni.navigateTo({
  780. url: '/pages/posture-guide/posture-guide'
  781. });
  782. }
  783. } else {
  784. this.goToNextQuestion();
  785. }
  786. }, 1000);
  787. });
  788. },
  789. toggleSettings() {
  790. // 打开设置面板
  791. uni.showToast({
  792. title: '设置功能开发中',
  793. icon: 'none'
  794. });
  795. },
  796. back(target) {
  797. // 清除计时器
  798. if (this.timerInterval) {
  799. clearInterval(this.timerInterval);
  800. }
  801. // 如果指定了跳转目标
  802. if (target) {
  803. uni.navigateTo({
  804. url: target
  805. });
  806. return;
  807. }
  808. // 否则尝试返回上一页,如果失败则跳转到首页
  809. // try {
  810. // const pages = getCurrentPages();
  811. // if (pages.length > 1) {
  812. // uni.reLaunch({
  813. // url: '/pages/index/index'
  814. // });
  815. // } else {
  816. // // 如果当前是第一页,则跳转到首页
  817. // uni.reLaunch({
  818. // url: '/pages/index/index'
  819. // });
  820. // }
  821. // } catch (e) {
  822. // console.error('导航错误:', e);
  823. // // 出错时也跳转到首页
  824. // uni.reLaunch({
  825. // url: '/pages/index/index'
  826. // });
  827. // }
  828. },
  829. error(e) {
  830. // 相机错误事件
  831. console.error(e.detail);
  832. uni.showToast({
  833. title: '相机启动失败,请检查权限设置',
  834. icon: 'none'
  835. });
  836. },
  837. playAiSpeaking() {
  838. if (this.useVideo && this.aiVideoContext) {
  839. this.aiVideoContext.play();
  840. }
  841. // 触发数字人说话动画
  842. if (this.digitalHumanUrl) {
  843. // 假设当前问题的文本作为数字人要说的内容
  844. const speakText = this.currentQuestion ? this.currentQuestion.text : '';
  845. this.interactWithDigitalHuman(speakText);
  846. }
  847. },
  848. pauseAiSpeaking() {
  849. if (this.useVideo && this.aiVideoContext) {
  850. this.aiVideoContext.pause();
  851. }
  852. },
  853. // 修改 restartTest 方法,添加可选的跳转目标
  854. restartTest(target) {
  855. this.currentQuestionIndex = 0;
  856. this.score = 0;
  857. this.showEndModal = false;
  858. this.showResult = false;
  859. this.selectedOption = null;
  860. this.selectedOptions = [];
  861. this.resetTimer();
  862. // 如果指定了跳转目标
  863. if (target) {
  864. uni.navigateTo({
  865. url: target
  866. });
  867. }
  868. },
  869. // 在methods中添加测试方法
  870. testEndScreen() {
  871. this.interviewCompleted = true;
  872. this.showEndModal = false;
  873. },
  874. // 初始化数字人
  875. initDigitalHuman() {
  876. // 移除不可用的示例URL
  877. // this.digitalHumanUrl = 'https://your-digital-human-service.com/avatar?id=123';
  878. // 暂时不使用数字人服务,直接使用本地图片
  879. this.digitalHumanUrl = '';
  880. // 如果您有实际可用的数字人服务,可以在这里设置
  881. // 例如:this.digitalHumanUrl = 'https://your-actual-service.com/avatar';
  882. // 或者使用本地HTML文件(如果有的话)
  883. // this.digitalHumanUrl = '/hybrid/html/digital-human.html';
  884. },
  885. // 与数字人交互的方法
  886. interactWithDigitalHuman(message) {
  887. // 如果数字人是通过web-view加载的,可以使用postMessage与其通信
  888. const webview = this.$mp.page.$getAppWebview().children()[0];
  889. if (webview) {
  890. webview.evalJS(`receiveMessage('${message}')`);
  891. }
  892. },
  893. // 添加 navigateToInterview 方法
  894. navigateToInterview() {
  895. // 关闭模态框
  896. this.showEndModal = false;
  897. // 跳转到interview页面
  898. uni.navigateTo({
  899. url: '/pages/interview/interview',
  900. success: () => {
  901. console.log('成功跳转到interview页面');
  902. },
  903. fail: (err) => {
  904. console.error('跳转失败:', err);
  905. uni.showToast({
  906. title: '跳转失败,请手动返回首页',
  907. icon: 'none'
  908. });
  909. }
  910. });
  911. },
  912. // 添加 handleCameraError 方法
  913. handleCameraError(e) {
  914. console.error('相机错误:', e.detail);
  915. uni.showToast({
  916. title: '相机启动失败,请检查权限设置',
  917. icon: 'none'
  918. });
  919. },
  920. // 修改 isOptionSelected 方法
  921. isOptionSelected(question, qIndex, optionIndex) {
  922. // 获取该题的答案
  923. const answer = this.answers.find(a => a.questionId === question.id);
  924. // 如果是当前正在回答的题目
  925. if (qIndex === this.currentQuestionIndex) {
  926. if (question.questionType === 1 || question.questionType === 3 || question.questionType === 4) {
  927. return this.selectedOption === optionIndex;
  928. } else if (question.questionType === 2) {
  929. return this.selectedOptions.includes(optionIndex);
  930. }
  931. }
  932. // 如果是已回答过的题目,使用保存的答案
  933. else if (answer) {
  934. if (question.questionType === 1 || question.questionType === 3 || question.questionType === 4) {
  935. return answer.answer === optionIndex;
  936. } else if (question.questionType === 2 && Array.isArray(answer.answer)) {
  937. return answer.answer.includes(optionIndex);
  938. }
  939. }
  940. return false;
  941. },
  942. // 修改 handleOptionClick 方法
  943. handleOptionClick(qIndex, index) {
  944. // 如果点击的是已完成的题目
  945. if (qIndex < this.currentQuestionIndex-1) {
  946. uni.showToast({
  947. title: '该题目已完成,无法修改',
  948. icon: 'none',
  949. duration: 2000
  950. });
  951. return;
  952. }
  953. // 如果是最后一题且已经显示继续按钮,不允许重复作答
  954. if (qIndex === this.questions.length - 1 && this.showContinueButton) {
  955. uni.showToast({
  956. title: '该题目已完成,请继续下一部分',
  957. icon: 'none',
  958. duration: 2000
  959. });
  960. return;
  961. }
  962. // 如果点击的是还未到的题目
  963. if (qIndex > this.currentQuestionIndex) {
  964. // 查找第一个未完成的题目索引
  965. const firstUnansweredIndex = this.currentQuestionIndex;
  966. uni.showToast({
  967. title: `请先完成第 ${firstUnansweredIndex + 1} 题`,
  968. icon: 'none',
  969. duration: 2000
  970. });
  971. // 滚动到当前应该做的题目
  972. this.currentScrollId = 'question-' + firstUnansweredIndex;
  973. return;
  974. }
  975. // 防重复点击
  976. if (this._isClicking) {
  977. return;
  978. }
  979. this._isClicking = true;
  980. // 清除之前的计时器
  981. if (this._clickTimer) {
  982. clearTimeout(this._clickTimer);
  983. }
  984. try {
  985. // 如果是上一题,先切换到上一题
  986. if (qIndex === this.currentQuestionIndex - 1) {
  987. this.currentQuestionIndex = qIndex;
  988. this.currentScrollId = 'question-' + qIndex;
  989. // 重置相关状态
  990. this.showResult = false;
  991. this.selectedOption = null;
  992. this.selectedOptions = [];
  993. }
  994. // 如果是当前题目,调用选择逻辑
  995. this.selectOption(index);
  996. // 设置延时,防止快速重复点击
  997. this._clickTimer = setTimeout(() => {
  998. this._isClicking = false;
  999. }, 1000);
  1000. } catch (error) {
  1001. console.error('处理选项点击失败:', error);
  1002. uni.showToast({
  1003. title: '操作失败,请重试',
  1004. icon: 'none'
  1005. });
  1006. this._isClicking = false;
  1007. }
  1008. },
  1009. // 处理题目分组
  1010. processQuestionGroups(questions) {
  1011. // 创建两个分组
  1012. const group1 = []; // category 为 5 的题目
  1013. const group2 = []; // 其他题目
  1014. // 对题目进行分类
  1015. console.log('处理题目分组...',questions);
  1016. questions.forEach(q => {
  1017. console.log(q.questionType === 4)
  1018. if (q.questionType !== 4) {
  1019. group1.push(q);
  1020. } else {
  1021. group2.push(q);
  1022. }
  1023. });
  1024. // 将填空题添加到适当的分组中
  1025. console.log('处理填空题...',this.blankQuestions);
  1026. if (this.blankQuestions && this.blankQuestions.length > 0) {
  1027. this.blankQuestions.forEach(q => {
  1028. if (q.questionType === 6) {
  1029. group1.push(q);
  1030. } else {
  1031. group2.push(q);
  1032. }
  1033. });
  1034. }
  1035. // 按照要求的顺序组合题目组:先显示其他题目,再显示 category 为 5 的题目
  1036. this.questionGroups = [group1, group2].filter(group => group.length > 0);
  1037. // 设置当前显示的题目
  1038. this.questions = this.questionGroups[0] || [];
  1039. },
  1040. // 处理继续按钮点击
  1041. handleContinue() {
  1042. if (this.currentGroupIndex < this.questionGroups.length - 1) {
  1043. // 检查是否是第一组结束
  1044. if (this.currentGroupIndex === 0) {
  1045. this.showPromptModal = true; // 显示提示弹窗
  1046. } else {
  1047. this.proceedToNextGroup();
  1048. }
  1049. } else {
  1050. // 所有组都完成了,根据配置跳转到下一个页面
  1051. this.navigateToNextPage();
  1052. }
  1053. },
  1054. // 添加新的方法处理弹窗确认
  1055. handlePromptConfirm() {
  1056. this.showPromptModal = false;
  1057. this.proceedToNextGroup();
  1058. },
  1059. // 添加新的方法处理组切换逻辑
  1060. proceedToNextGroup() {
  1061. this.currentGroupIndex++;
  1062. this.questions = this.questionGroups[this.currentGroupIndex];
  1063. this.currentQuestionIndex = 0;
  1064. this.showContinueButton = false;
  1065. this.currentScrollId = 'question-0';
  1066. // 重置滚动位置
  1067. this.scrollTop = 0;
  1068. // 重置相关状态
  1069. this.selectedOption = null;
  1070. this.selectedOptions = [];
  1071. this.showResult = false;
  1072. },
  1073. // 根据配置决定跳转到下一个页面
  1074. navigateToNextPage() {
  1075. // 获取本地存储的配置数据
  1076. let configData = {};
  1077. try {
  1078. const configStr = uni.getStorageSync('configData');
  1079. if (configStr && configStr.trim()) {
  1080. configData = JSON.parse(configStr);
  1081. }
  1082. } catch (error) {
  1083. console.error('解析configData失败:', error);
  1084. configData = {};
  1085. }
  1086. console.log('camera页面获取到的配置数据:', configData);
  1087. // 获取问题形式开关配置
  1088. const questionFormSwitches = configData?.question_form_switches || {};
  1089. // 肢体检测配置
  1090. const hasPostureDetection =configData?.enable_posture_check;
  1091. // 候选人提问配置
  1092. const hasCandidateQuestions = questionFormSwitches.enable_candidate_questions;
  1093. let targetUrl = '/pages/success/success'; // 默认跳转到成功页面
  1094. let pageName = 'success页面';
  1095. console.log('camera页面配置检查:', {
  1096. hasPostureDetection,
  1097. hasCandidateQuestions,
  1098. questionFormSwitches
  1099. });
  1100. // 根据配置决定跳转页面(参考identity-verify页面的逻辑)
  1101. if (hasPostureDetection) {
  1102. // 如果启用了肢体检测,跳转到posture-guide页面
  1103. targetUrl = '/pages/posture-guide/posture-guide';
  1104. pageName = 'posture-guide页面';
  1105. } else if (hasCandidateQuestions) {
  1106. // 如果启用了候选人提问,跳转到interview-question页面
  1107. targetUrl = '/pages/interview-question/interview-question';
  1108. pageName = 'interview-question页面';
  1109. }else{
  1110. targetUrl = '/pages/success/success';
  1111. pageName = 'success页面';
  1112. }
  1113. console.log('camera页面根据配置跳转到:', targetUrl);
  1114. // 执行页面跳转
  1115. uni.navigateTo({
  1116. url: targetUrl,
  1117. success: () => {
  1118. console.log(`成功跳转到${pageName}`);
  1119. },
  1120. fail: (err) => {
  1121. console.error(`跳转到${pageName}失败:`, err);
  1122. // 如果跳转失败,尝试使用redirectTo
  1123. uni.redirectTo({
  1124. url: targetUrl,
  1125. fail: (redirectErr) => {
  1126. console.error(`重定向到${pageName}也失败:`, redirectErr);
  1127. // 最后尝试使用switchTab(如果是tabBar页面)
  1128. uni.switchTab({
  1129. url: targetUrl,
  1130. fail: (switchErr) => {
  1131. console.error('所有跳转方式都失败:', switchErr);
  1132. // 如果所有跳转方式都失败,尝试返回上一页
  1133. uni.navigateBack({
  1134. delta: 1
  1135. });
  1136. }
  1137. });
  1138. }
  1139. });
  1140. }
  1141. });
  1142. },
  1143. // 保存当前题目的答案
  1144. saveAnswer() {
  1145. let answer;
  1146. if (this.currentQuestion.questionType === 0) { // 开放问题
  1147. answer = {
  1148. questionId: this.currentQuestion.id,
  1149. questionType: this.currentQuestion.questionType,
  1150. answer: this.openQuestionAnswer,
  1151. answerDuration: this.getAnswerDuration() // 添加答题时长
  1152. };
  1153. } else if (this.currentQuestion.questionType === 1 || this.currentQuestion.questionType === 3 || this.currentQuestion.questionType === 4) { // 单选题、看图答题或类型4题目
  1154. answer = {
  1155. questionId: this.currentQuestion.id,
  1156. questionType: this.currentQuestion.questionType,
  1157. answer: this.selectedOption,
  1158. answerDuration: this.getAnswerDuration() // 添加答题时长
  1159. };
  1160. } else if (this.currentQuestion.questionType === 6) { // 填空题
  1161. answer = {
  1162. questionId: this.currentQuestion.id,
  1163. questionType: this.currentQuestion.questionType,
  1164. answer: this.currentBlankAnswers[this.currentQuestion.id] || {},
  1165. answerDuration: this.getAnswerDuration() // 添加答题时长
  1166. };
  1167. } else { // 多选题
  1168. answer = {
  1169. questionId: this.currentQuestion.id,
  1170. questionType: this.currentQuestion.questionType,
  1171. answer: this.selectedOptions,
  1172. answerDuration: this.getAnswerDuration() // 添加答题时长
  1173. };
  1174. }
  1175. // 检查是否已存在该题目的答案,如果存在则更新
  1176. const existingIndex = this.answers.findIndex(a => a.questionId === answer.questionId);
  1177. if (existingIndex > -1) {
  1178. this.answers[existingIndex] = answer;
  1179. } else {
  1180. this.answers.push(answer);
  1181. }
  1182. // 保存当前答案以便提交
  1183. this.currentAnswer = answer;
  1184. console.log('已保存答案:', this.answers);
  1185. },
  1186. // 获取答题时长(秒)
  1187. getAnswerDuration() {
  1188. // 这里假设每题默认30秒,根据剩余时间计算用时
  1189. // 您可以根据实际情况调整计算逻辑
  1190. const remainingTimeArr = this.remainingTime.split(':');
  1191. const remainingSeconds = parseInt(remainingTimeArr[0]) * 60 + parseInt(remainingTimeArr[1]);
  1192. return 30 - remainingSeconds; // 假设每题30秒
  1193. },
  1194. // 提交当前答案
  1195. async submitCurrentAnswer() {
  1196. if (!this.currentAnswer || this.isSubmitting) return; // 如果正在提交或没有答案,则不执行
  1197. try {
  1198. // 设置提交状态为true
  1199. this.isSubmitting = true;
  1200. // 显示提交中提示
  1201. /* uni.showLoading({
  1202. title: '正在提交答案...'
  1203. }); */
  1204. // 构建提交数据
  1205. let answerContent = '';
  1206. let answerOptions = [];
  1207. let blankAnswers = [];
  1208. if (this.currentAnswer.questionType === 0) {
  1209. // 开放题直接使用文本答案
  1210. answerContent = this.currentAnswer.answer;
  1211. answerOptions = [];
  1212. } else if (this.currentAnswer.questionType === 1 || this.currentAnswer.questionType === 3 || this.currentAnswer.questionType === 4) {
  1213. // 单选题或看图答题,获取选项ID而不是索引
  1214. const selectedIndex = this.currentAnswer.answer;
  1215. const selectedOption = this.currentQuestion.options[selectedIndex];
  1216. console.log('selectedOption',selectedOption);
  1217. const optionId = selectedOption.id ? selectedOption.id : selectedIndex;
  1218. answerContent = optionId.toString();
  1219. answerOptions = [optionId];
  1220. } else if (this.currentAnswer.questionType === 2) {
  1221. // 多选题,将选项ID数组转为逗号分隔的字符串
  1222. const selectedIndices = this.currentAnswer.answer;
  1223. const selectedOptionIds = selectedIndices.map(index => {
  1224. const option = this.currentQuestion.options[index];
  1225. // 使用选项的ID或其他唯一标识符
  1226. return option.id ? option.id : index;
  1227. });
  1228. answerOptions = selectedOptionIds;
  1229. } else if (this.currentAnswer.questionType === 6) {
  1230. // 填空题,构造填空答案数组
  1231. const blankAnswerObj = this.currentAnswer.answer;
  1232. if (blankAnswerObj && typeof blankAnswerObj === 'object') {
  1233. blankAnswers = Object.entries(blankAnswerObj).map(([key, value]) => ({
  1234. blank_index: parseInt(key),
  1235. answer_text: value || ''
  1236. }));
  1237. }
  1238. }
  1239. const submitData = {
  1240. position_id: JSON.parse(uni.getStorageSync('selectedJob')).id,
  1241. applicant_id: JSON.parse(uni.getStorageSync('userInfo')).id,
  1242. job_position_question_id: this.currentAnswer.questionId,
  1243. // answer_content: answerContent,
  1244. answer_options: answerOptions,
  1245. answer_duration: this.currentAnswer.answerDuration || 0,
  1246. tenant_id:uni.getStorageSync('tenant_id') ||JSON.parse(uni.getStorageSync('userInfo')).tenant_id || 1
  1247. };
  1248. // 如果是填空题,添加 blank_answers 字段
  1249. if (this.currentAnswer.questionType === 6 && blankAnswers.length > 0) {
  1250. submitData.blank_answers = blankAnswers;
  1251. }
  1252. console.log('提交数据:', submitData);
  1253. // 调用API提交答案
  1254. const res = await this.$http.post(`${apiBaseUrl}/api/job/submit_answer`, submitData);
  1255. console.log('提交答案响应:', res);
  1256. return res;
  1257. } catch (error) {
  1258. console.error('提交答案失败:', error);
  1259. // 显示错误提示
  1260. uni.showToast({
  1261. title: '提交答案失败,请重试',
  1262. icon: 'none'
  1263. });
  1264. throw error;
  1265. } finally {
  1266. // 隐藏加载提示
  1267. uni.hideLoading();
  1268. // 重置提交状态
  1269. this.isSubmitting = false;
  1270. }
  1271. },
  1272. // 修改 goToNextQuestion 方法
  1273. async goToNextQuestion() {
  1274. // 检查是否完成当前组的所有题目
  1275. if (this.currentQuestionIndex >= this.questions.length - 1) {
  1276. // 当前组的所有题目都已完成,显示继续按钮
  1277. this.showContinueButton = true;
  1278. // 使用延时确保按钮渲染完成后再滚动
  1279. setTimeout(() => {
  1280. // 先重置 scrollTop,然后再设置新值,强制触发更新
  1281. this.scrollTop = 0;
  1282. // 使用 nextTick 确保视图已更新
  1283. this.$nextTick(() => {
  1284. // 延迟设置新的滚动位置
  1285. setTimeout(() => {
  1286. this.scrollTop = 10000; // 一个足够大的值
  1287. }, 100);
  1288. });
  1289. }, 200);
  1290. return;
  1291. }
  1292. // 如果还有下一题,继续下一题
  1293. this.currentQuestionIndex++;
  1294. this.currentScrollId = 'question-' + this.currentQuestionIndex;
  1295. // 重置状态(只在非最后一题时重置)
  1296. this.showResult = false;
  1297. this.selectedOption = null;
  1298. this.selectedOptions = [];
  1299. this.openQuestionAnswer = '';
  1300. // 如果有下一题的详情
  1301. if (this.questions[this.currentQuestionIndex]) {
  1302. // 更新进度
  1303. this.progressWidth = (this.currentQuestionIndex + 1) / this.questions.length * 100;
  1304. // 重置计时器
  1305. this.resetTimer();
  1306. // 播放AI介绍下一题
  1307. this.playAiSpeaking();
  1308. setTimeout(() => {
  1309. this.pauseAiSpeaking();
  1310. }, 2000);
  1311. }
  1312. },
  1313. // 填空题相关方法
  1314. // 获取填空值
  1315. getBlankValue(questionId, blankIndex) {
  1316. if (this.currentBlankAnswers[questionId] && this.currentBlankAnswers[questionId][blankIndex]) {
  1317. return this.currentBlankAnswers[questionId][blankIndex];
  1318. }
  1319. return '';
  1320. },
  1321. // 处理填空输入
  1322. handleBlankInput(questionId, blankIndex, event) {
  1323. const value = event.detail.value;
  1324. if (!this.currentBlankAnswers[questionId]) {
  1325. this.$set(this.currentBlankAnswers, questionId, {});
  1326. }
  1327. this.$set(this.currentBlankAnswers[questionId], blankIndex, value);
  1328. // 保存到填空答案数组中
  1329. const existingAnswerIndex = this.blankAnswers.findIndex(answer => answer.questionId === questionId);
  1330. if (existingAnswerIndex > -1) {
  1331. this.blankAnswers[existingAnswerIndex].answer = this.currentBlankAnswers[questionId];
  1332. } else {
  1333. this.blankAnswers.push({
  1334. questionId: questionId,
  1335. answer: this.currentBlankAnswers[questionId]
  1336. });
  1337. }
  1338. },
  1339. // 检查是否有填空答案
  1340. hasBlankAnswers(question) {
  1341. const answers = this.currentBlankAnswers[question.id];
  1342. if (!answers) return false;
  1343. // 检查是否至少有一个空白被填写
  1344. return Object.values(answers).some(value => value && value.trim() !== '');
  1345. },
  1346. // 提交填空题
  1347. submitBlankQuestion(qIndex) {
  1348. const question = this.questions[qIndex];
  1349. // 检查答案
  1350. this.checkAnswer();
  1351. // 保存当前题目的答案
  1352. this.saveAnswer();
  1353. // 提交答案
  1354. this.submitCurrentAnswer().then(() => {
  1355. // 提交成功后,短暂延迟后自动进入下一题
  1356. setTimeout(() => {
  1357. this.goToNextQuestion();
  1358. }, 500);
  1359. }).catch(error => {
  1360. console.error('提交答案失败:', error);
  1361. // 即使提交失败也继续下一题
  1362. setTimeout(() => {
  1363. this.goToNextQuestion();
  1364. }, 1000);
  1365. });
  1366. }
  1367. },
  1368. // 添加生命周期钩子,确保在组件销毁时清除计时器
  1369. beforeDestroy() {
  1370. if (this.timerInterval) {
  1371. clearInterval(this.timerInterval);
  1372. }
  1373. }
  1374. }
  1375. </script>
  1376. <style>
  1377. .camera-container {
  1378. position: relative;
  1379. margin-top: 25px;
  1380. width: 100%;
  1381. height: 96vh;
  1382. background-color: #ffffff;
  1383. display: flex;
  1384. flex-direction: column;
  1385. overflow: hidden; /* 防止内容溢出 */
  1386. }
  1387. .header {
  1388. height: 90rpx;
  1389. /* background-color: #000000; */
  1390. display: flex;
  1391. align-items: center;
  1392. padding: 0 30rpx;
  1393. /* color: #ffffff; */
  1394. }
  1395. .back-button {
  1396. width: 60rpx;
  1397. height: 60rpx;
  1398. display: flex;
  1399. align-items: center;
  1400. justify-content: center;
  1401. }
  1402. .title {
  1403. flex: 1;
  1404. text-align: center;
  1405. font-size: 32rpx;
  1406. font-weight: bold;
  1407. }
  1408. .controls {
  1409. display: flex;
  1410. gap: 30rpx;
  1411. }
  1412. .iconfont {
  1413. font-size: 40rpx;
  1414. }
  1415. .content {
  1416. flex: 1;
  1417. display: flex;
  1418. flex-direction: column;
  1419. position: relative;
  1420. padding: 50rpx 20rpx 0;
  1421. }
  1422. .progress-container {
  1423. display: flex;
  1424. flex-direction: column;
  1425. justify-content: space-between;
  1426. margin-bottom: 20rpx;
  1427. }
  1428. .progress-step {
  1429. display: flex;
  1430. align-items: center;
  1431. margin-bottom: 10rpx;
  1432. }
  1433. .step-circle {
  1434. width: 40rpx;
  1435. height: 40rpx;
  1436. border-radius: 50%;
  1437. background-color: #e0e0e0;
  1438. display: flex;
  1439. align-items: center;
  1440. justify-content: center;
  1441. font-size: 24rpx;
  1442. margin-right: 10rpx;
  1443. }
  1444. .step-circle.active {
  1445. background-color: #ff9500;
  1446. color: #ffffff;
  1447. }
  1448. .step-text {
  1449. font-size: 24rpx;
  1450. color: #666666;
  1451. }
  1452. .progress-bar {
  1453. height: 10rpx;
  1454. background-color: #e0e0e0;
  1455. border-radius: 5rpx;
  1456. overflow: hidden;
  1457. margin-bottom: 20rpx;
  1458. }
  1459. .progress-fill {
  1460. height: 100%;
  1461. background-color: #00c853;
  1462. transition: width 0.3s;
  1463. }
  1464. .interview-content {
  1465. flex: 1;
  1466. display: flex;
  1467. flex-direction: column;
  1468. margin-bottom: 40rpx;
  1469. padding: 20rpx;
  1470. border-bottom: 1px solid #eee;
  1471. }
  1472. .video-area {
  1473. display: flex;
  1474. /* flex-direction: column; */
  1475. justify-content: space-between;
  1476. height: auto;
  1477. margin-bottom: 20rpx;
  1478. }
  1479. .video-camera {
  1480. display: flex;
  1481. flex-direction: row;
  1482. align-items: center;
  1483. justify-content: space-between;
  1484. width: 65%;
  1485. }
  1486. .interviewer {
  1487. background-color: #f5f5f5;
  1488. display: flex;
  1489. align-items: center;
  1490. justify-content: center;
  1491. position: relative;
  1492. width: 48% !important;
  1493. height: 300rpx;
  1494. }
  1495. .interviewer-video {
  1496. width: 100%;
  1497. height: 100%;
  1498. object-fit: cover;
  1499. }
  1500. .interviewer-avatar {
  1501. width: 80%;
  1502. height: 80%;
  1503. object-fit: contain;
  1504. }
  1505. .user-camera-container {
  1506. width: 48%;
  1507. height: 300rpx;
  1508. border-radius: 10rpx;
  1509. overflow: hidden;
  1510. border: 4rpx solid #ffffff;
  1511. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.2);
  1512. }
  1513. .question-area {
  1514. flex: 1;
  1515. display: flex;
  1516. flex-direction: column;
  1517. }
  1518. .question-number {
  1519. font-size: 28rpx;
  1520. color: #666;
  1521. margin-bottom: 20rpx;
  1522. }
  1523. .question-importance {
  1524. background-color: #f9f9f9;
  1525. padding: 20rpx;
  1526. border-radius: 10rpx;
  1527. margin-bottom: 20rpx;
  1528. font-size: 28rpx;
  1529. color: #333;
  1530. }
  1531. .question-importance text {
  1532. color: #ff0000;
  1533. /* margin-right: 10rpx; */
  1534. }
  1535. .options {
  1536. display: flex;
  1537. flex-direction: column;
  1538. gap: 20rpx;
  1539. margin-bottom: 30rpx;
  1540. }
  1541. .option-item {
  1542. padding: 20rpx;
  1543. background-color: #f5f5f5;
  1544. border-radius: 10rpx;
  1545. font-size: 28rpx;
  1546. transition: all 0.3s;
  1547. border: 1px solid #e0e0e0;
  1548. display: flex;
  1549. align-items: center;
  1550. cursor: pointer; /* 添加指针样式 */
  1551. }
  1552. .option-item:active {
  1553. transform: scale(0.98); /* 点击时轻微缩小效果 */
  1554. opacity: 0.9;
  1555. }
  1556. .option-selected {
  1557. background-color: #e6f7ff;
  1558. border: 1px solid #1890ff;
  1559. }
  1560. /* 添加选中后的动画效果 */
  1561. @keyframes selectedPulse {
  1562. 0% { box-shadow: 0 0 0 0 rgba(24, 144, 255, 0.4); }
  1563. 70% { box-shadow: 0 0 0 10px rgba(24, 144, 255, 0); }
  1564. 100% { box-shadow: 0 0 0 0 rgba(24, 144, 255, 0); }
  1565. }
  1566. .option-selected {
  1567. animation: selectedPulse 1.5s ease-out;
  1568. }
  1569. .option-correct {
  1570. background-color: #d4f7d4;
  1571. border: 1px solid #52c41a;
  1572. }
  1573. .option-wrong {
  1574. background-color: #fff1f0;
  1575. border: 1px solid #ff4d4f;
  1576. }
  1577. .option-text {
  1578. color: #333;
  1579. }
  1580. .timer-container {
  1581. text-align: right;
  1582. margin: 20rpx 0;
  1583. }
  1584. .timer-text {
  1585. font-size: 24rpx;
  1586. color: #666;
  1587. background-color: #f0f0f0;
  1588. padding: 6rpx 12rpx;
  1589. border-radius: 6rpx;
  1590. }
  1591. .bottom-button-container {
  1592. position: fixed;
  1593. bottom: 50px;
  1594. left: 5%;
  1595. right: 0;
  1596. padding: 20rpx;
  1597. display: flex;
  1598. justify-content: center;
  1599. z-index: 10;
  1600. }
  1601. .bottom-button-wrapper {
  1602. display: flex;
  1603. width: 100%;
  1604. justify-content: space-between;
  1605. align-items: center;
  1606. }
  1607. .timer-display {
  1608. font-size: 28rpx;
  1609. color: #666;
  1610. padding: 10rpx 20rpx;
  1611. border-radius: 6rpx;
  1612. }
  1613. .next-button {
  1614. background-color: #0039b3;
  1615. color: #ffffff;
  1616. border-radius: 10rpx;
  1617. font-size: 30rpx;
  1618. height: 80rpx;
  1619. line-height: 80rpx;
  1620. width: 90%;
  1621. text-align: center;
  1622. margin: 0;
  1623. }
  1624. .footer {
  1625. height: 100rpx;
  1626. background-color: #000000;
  1627. display: flex;
  1628. justify-content: space-between;
  1629. align-items: center;
  1630. padding: 0 30rpx;
  1631. color: #ffffff;
  1632. }
  1633. .timer {
  1634. font-size: 28rpx;
  1635. }
  1636. .next-step {
  1637. font-size: 28rpx;
  1638. }
  1639. .interview-end-modal {
  1640. position: fixed;
  1641. top: 0;
  1642. left: 0;
  1643. right: 0;
  1644. bottom: 0;
  1645. background-color: rgba(0, 0, 0, 0.5);
  1646. display: flex;
  1647. align-items: center;
  1648. justify-content: center;
  1649. z-index: 999;
  1650. }
  1651. .modal-content {
  1652. width: 80%;
  1653. background-color: #ffffff;
  1654. border-radius: 20rpx;
  1655. padding: 40rpx;
  1656. display: flex;
  1657. flex-direction: column;
  1658. align-items: center;
  1659. }
  1660. .modal-title {
  1661. font-size: 36rpx;
  1662. font-weight: bold;
  1663. margin-bottom: 30rpx;
  1664. }
  1665. .score-display {
  1666. font-size: 48rpx;
  1667. font-weight: bold;
  1668. color: #0039b3;
  1669. margin: 20rpx 0;
  1670. }
  1671. .modal-message {
  1672. font-size: 28rpx;
  1673. color: #666;
  1674. text-align: center;
  1675. margin-bottom: 40rpx;
  1676. }
  1677. .modal-buttons {
  1678. display: flex;
  1679. justify-content: space-between;
  1680. width: 100%;
  1681. margin-top: 20rpx;
  1682. }
  1683. .modal-button {
  1684. width: 45%;
  1685. }
  1686. @keyframes speaking {
  1687. 0% {
  1688. opacity: 0.8;
  1689. }
  1690. 50% {
  1691. opacity: 1;
  1692. }
  1693. 100% {
  1694. opacity: 0.8;
  1695. }
  1696. }
  1697. .speaking {
  1698. animation: speaking 1.5s infinite;
  1699. }
  1700. .digital-avatar {
  1701. display: flex;
  1702. flex-direction: row;
  1703. align-items: flex-start;
  1704. justify-content: space-between;
  1705. width: 100%;
  1706. margin-bottom: 20rpx;
  1707. }
  1708. .message-box {
  1709. width: 65%;
  1710. min-height: 120rpx;
  1711. background-color: #f5f5f5;
  1712. border-radius: 10rpx;
  1713. padding: 15rpx;
  1714. margin-right: 20rpx;
  1715. display: flex;
  1716. align-items: center;
  1717. }
  1718. .message-text {
  1719. font-size: 24rpx;
  1720. color: #333;
  1721. line-height: 1.5;
  1722. }
  1723. .user-avatar {
  1724. width: 110px;
  1725. height: 160px;
  1726. border-radius: 10rpx;
  1727. overflow: hidden;
  1728. }
  1729. .camera {
  1730. width: 100%;
  1731. height: 100%;
  1732. border-radius: 10rpx;
  1733. border: 2rpx solid #e0e0e0;
  1734. }
  1735. .avatar-image {
  1736. width: 100%;
  1737. height: 100%;
  1738. border-radius: 10rpx;
  1739. border: 2rpx solid #e0e0e0;
  1740. }
  1741. .digital-human-webview {
  1742. width: 100%;
  1743. height: 100%;
  1744. border-radius: 10rpx;
  1745. border: 2rpx solid #e0e0e0;
  1746. }
  1747. .interview-complete-screen {
  1748. position: fixed;
  1749. top: 0;
  1750. left: 0;
  1751. right: 0;
  1752. bottom: 0;
  1753. background-color: #f0f5ff;
  1754. display: flex;
  1755. flex-direction: column;
  1756. align-items: center;
  1757. justify-content: center;
  1758. z-index: 1000;
  1759. padding: 40rpx;
  1760. }
  1761. .digital-avatar-large {
  1762. width: 200rpx;
  1763. height: 200rpx;
  1764. margin-bottom: 60rpx;
  1765. }
  1766. .avatar-image-large {
  1767. width: 100%;
  1768. height: 100%;
  1769. border-radius: 30rpx;
  1770. }
  1771. .complete-message {
  1772. font-size: 40rpx;
  1773. font-weight: bold;
  1774. color: #333;
  1775. margin-bottom: 30rpx;
  1776. }
  1777. .complete-description {
  1778. font-size: 28rpx;
  1779. color: #666;
  1780. text-align: center;
  1781. margin-bottom: 80rpx;
  1782. line-height: 1.5;
  1783. }
  1784. .complete-button {
  1785. background-color: #0039b3;
  1786. color: #ffffff;
  1787. border-radius: 10rpx;
  1788. font-size: 32rpx;
  1789. padding: 20rpx 60rpx;
  1790. margin-top: 40rpx;
  1791. }
  1792. /* 添加加载状态样式 */
  1793. .loading-container {
  1794. position: absolute;
  1795. top: 0;
  1796. left: 0;
  1797. right: 0;
  1798. bottom: 0;
  1799. display: flex;
  1800. flex-direction: column;
  1801. align-items: center;
  1802. justify-content: center;
  1803. background-color: rgba(255, 255, 255, 0.9);
  1804. z-index: 100;
  1805. }
  1806. .loading-text {
  1807. margin-top: 20rpx;
  1808. font-size: 28rpx;
  1809. color: #666;
  1810. }
  1811. .error-container {
  1812. text-align: center;
  1813. }
  1814. .error-message {
  1815. font-size: 28rpx;
  1816. color: #ff4d4f;
  1817. margin-bottom: 30rpx;
  1818. }
  1819. .retry-button {
  1820. background-color: #0039b3;
  1821. color: #ffffff;
  1822. border-radius: 10rpx;
  1823. font-size: 28rpx;
  1824. padding: 10rpx 30rpx;
  1825. }
  1826. .question-type {
  1827. display: inline-block;
  1828. /* background-color: #0039b3; */
  1829. color: white;
  1830. font-size: 24rpx;
  1831. /* padding: 4rpx 5rpx; */
  1832. border-radius: 6rpx;
  1833. /* margin-right: 10rpx; */
  1834. }
  1835. /* 新增的开放问题样式 */
  1836. .open-question-container {
  1837. display: flex;
  1838. flex-direction: column;
  1839. width: 100%;
  1840. margin-bottom: 20rpx;
  1841. }
  1842. .open-question-input {
  1843. width: 100%;
  1844. height: 300rpx;
  1845. background-color: #f9f9f9;
  1846. border: 1px solid #e0e0e0;
  1847. border-radius: 10rpx;
  1848. padding: 20rpx;
  1849. font-size: 28rpx;
  1850. color: #333;
  1851. }
  1852. .word-count {
  1853. text-align: right;
  1854. font-size: 24rpx;
  1855. color: #999;
  1856. margin-top: 10rpx;
  1857. }
  1858. .option-prefix {
  1859. margin-right: 10rpx;
  1860. font-weight: bold;
  1861. color: #333;
  1862. min-width: 30rpx;
  1863. }
  1864. /* 新增的图片显示样式 */
  1865. .question-image-container {
  1866. width: 100%;
  1867. margin: 20rpx 0;
  1868. display: flex;
  1869. justify-content: center;
  1870. align-items: center;
  1871. }
  1872. .question-image {
  1873. width: 100%;
  1874. max-width: 600rpx;
  1875. border-radius: 10rpx;
  1876. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  1877. }
  1878. /* 添加滚动视图样式 */
  1879. .content-scroll {
  1880. flex: 1;
  1881. height: calc(100vh - 200px); /* 只减去顶部相机的高度 */
  1882. margin-top: 10px;
  1883. }
  1884. /* 添加底部空白区域,防止内容被固定按钮遮挡 */
  1885. .bottom-space {
  1886. height: 50rpx; /* 减小底部空白区域 */
  1887. }
  1888. /* 添加流式布局相关样式 */
  1889. .interview-content {
  1890. margin-bottom: 40rpx;
  1891. padding: 20rpx;
  1892. border-bottom: 1px solid #eee;
  1893. }
  1894. .option-disabled {
  1895. opacity: 0.7;
  1896. background-color: #f0f0f0;
  1897. }
  1898. .question-button-container {
  1899. margin-top: 20rpx;
  1900. display: flex;
  1901. justify-content: center;
  1902. }
  1903. .bottom-timer-container {
  1904. display: none;
  1905. }
  1906. /* 添加固定相机容器样式 */
  1907. .fixed-camera-container {
  1908. position: sticky;
  1909. top: 0;
  1910. width: 100%;
  1911. padding: 20rpx;
  1912. background-color: #fff;
  1913. z-index: 10;
  1914. display: flex;
  1915. justify-content: flex-start;
  1916. border-bottom: 1px solid #eee;
  1917. }
  1918. .camera-warning {
  1919. animation: camera-warning-flash 1s ease-in-out infinite;
  1920. border: 2px solid #ff0000;
  1921. }
  1922. @keyframes camera-warning-flash {
  1923. 0% {
  1924. border-color: #ff0000;
  1925. box-shadow: 0 0 15px rgba(255, 0, 0, 0.8);
  1926. }
  1927. 50% {
  1928. border-color: rgba(255, 0, 0, 0.3);
  1929. box-shadow: 0 0 5px rgba(255, 0, 0, 0.4);
  1930. }
  1931. 100% {
  1932. border-color: #ff0000;
  1933. box-shadow: 0 0 15px rgba(255, 0, 0, 0.8);
  1934. }
  1935. }
  1936. .user-avatar {
  1937. width: 110px;
  1938. height: 160px;
  1939. border-radius: 10rpx;
  1940. overflow: hidden;
  1941. }
  1942. /* 添加继续按钮样式 */
  1943. .continue-button-container {
  1944. display: flex;
  1945. justify-content: center;
  1946. padding: 20rpx;
  1947. margin-top: 20rpx;
  1948. }
  1949. .continue-button {
  1950. background-color: #0039b3;
  1951. color: #ffffff;
  1952. border-radius: 10rpx;
  1953. font-size: 30rpx;
  1954. height: 80rpx;
  1955. line-height: 80rpx;
  1956. width: 90%;
  1957. text-align: center;
  1958. }
  1959. /* 添加新的样式 */
  1960. .prompt-modal {
  1961. position: fixed;
  1962. top: 0;
  1963. left: 0;
  1964. right: 0;
  1965. bottom: 0;
  1966. background-color: rgba(0, 0, 0, 0.5);
  1967. display: flex;
  1968. align-items: center;
  1969. justify-content: center;
  1970. z-index: 1000;
  1971. }
  1972. .prompt-content {
  1973. width: 85%;
  1974. background-color: #ffffff;
  1975. border-radius: 20rpx;
  1976. padding: 40rpx;
  1977. display: flex;
  1978. flex-direction: column;
  1979. align-items: center;
  1980. }
  1981. .prompt-title {
  1982. font-size: 36rpx;
  1983. font-weight: bold;
  1984. color: #333;
  1985. margin-bottom: 30rpx;
  1986. }
  1987. .prompt-text {
  1988. font-size: 28rpx;
  1989. color: #666;
  1990. line-height: 1.6;
  1991. margin-bottom: 20rpx;
  1992. text-align: justify;
  1993. }
  1994. .bold-text {
  1995. font-weight: bold;
  1996. color: #333;
  1997. }
  1998. .prompt-button {
  1999. background-color: #0039b3;
  2000. color: #ffffff;
  2001. border-radius: 10rpx;
  2002. font-size: 30rpx;
  2003. height: 80rpx;
  2004. line-height: 80rpx;
  2005. width: 60%;
  2006. text-align: center;
  2007. margin-top: 30rpx;
  2008. }
  2009. .custom-navbar {
  2010. position: fixed;
  2011. top: 0;
  2012. left: 0;
  2013. right: 0;
  2014. height: 44px;
  2015. background-color: #ffffff;
  2016. display: flex;
  2017. align-items: center;
  2018. justify-content: center;
  2019. z-index: 999;
  2020. }
  2021. .navbar-title {
  2022. font-size: 16px;
  2023. font-weight: bold;
  2024. }
  2025. .content {
  2026. margin-top: 44px;
  2027. padding-top: var(--status-bar-height);
  2028. }
  2029. /* 填空题样式 */
  2030. .blank-question-container {
  2031. margin: 20rpx 0;
  2032. }
  2033. .blank-question-text {
  2034. line-height: 1.8;
  2035. font-size: 28rpx;
  2036. color: #333;
  2037. padding: 20rpx;
  2038. background-color: #f9f9f9;
  2039. border-radius: 10rpx;
  2040. margin-bottom: 20rpx;
  2041. }
  2042. .blank-inputs {
  2043. display: flex;
  2044. flex-direction: column;
  2045. gap: 15rpx;
  2046. }
  2047. .blank-input-item {
  2048. display: flex;
  2049. align-items: center;
  2050. padding: 10rpx 20rpx;
  2051. background-color: #fff;
  2052. border-radius: 8rpx;
  2053. border: 1px solid #e0e0e0;
  2054. }
  2055. .blank-label {
  2056. font-size: 26rpx;
  2057. color: #666;
  2058. margin-right: 20rpx;
  2059. min-width: 120rpx;
  2060. }
  2061. /* 填空输入框样式 */
  2062. .blank-input {
  2063. flex: 1;
  2064. height: 60rpx;
  2065. border: 1px solid #ccc;
  2066. border-radius: 6rpx;
  2067. padding: 0 15rpx;
  2068. font-size: 26rpx;
  2069. background-color: #fff;
  2070. }
  2071. .blank-input:disabled {
  2072. background-color: #f5f5f5;
  2073. color: #999;
  2074. }
  2075. </style>