camera.vue 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271
  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: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 = 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. questions.forEach(q => {
  1016. if (q.category === 5) {
  1017. group1.push(q);
  1018. } else {
  1019. group2.push(q);
  1020. }
  1021. });
  1022. // 将填空题添加到适当的分组中
  1023. if (this.blankQuestions && this.blankQuestions.length > 0) {
  1024. this.blankQuestions.forEach(q => {
  1025. if (q.category === 5) {
  1026. group1.push(q);
  1027. } else {
  1028. group2.push(q);
  1029. }
  1030. });
  1031. }
  1032. // 按照要求的顺序组合题目组:先显示其他题目,再显示 category 为 5 的题目
  1033. this.questionGroups = [group2, group1].filter(group => group.length > 0);
  1034. // 设置当前显示的题目
  1035. this.questions = this.questionGroups[0] || [];
  1036. },
  1037. // 处理继续按钮点击
  1038. handleContinue() {
  1039. if (this.currentGroupIndex < this.questionGroups.length - 1) {
  1040. // 检查是否是第一组结束
  1041. if (this.currentGroupIndex === 0) {
  1042. this.showPromptModal = true; // 显示提示弹窗
  1043. } else {
  1044. this.proceedToNextGroup();
  1045. }
  1046. } else {
  1047. // 所有组都完成了,跳转到下一个页面
  1048. if(this.positionConfig.enable_posture_check){
  1049. uni.navigateTo({
  1050. url: '/pages/posture-guide/posture-guide'
  1051. });
  1052. }else{
  1053. uni.navigateTo({
  1054. url: '/pages/interview-question/interview-question'
  1055. });
  1056. }
  1057. }
  1058. },
  1059. // 添加新的方法处理弹窗确认
  1060. handlePromptConfirm() {
  1061. this.showPromptModal = false;
  1062. this.proceedToNextGroup();
  1063. },
  1064. // 添加新的方法处理组切换逻辑
  1065. proceedToNextGroup() {
  1066. this.currentGroupIndex++;
  1067. this.questions = this.questionGroups[this.currentGroupIndex];
  1068. this.currentQuestionIndex = 0;
  1069. this.showContinueButton = false;
  1070. this.currentScrollId = 'question-0';
  1071. // 重置滚动位置
  1072. this.scrollTop = 0;
  1073. // 重置相关状态
  1074. this.selectedOption = null;
  1075. this.selectedOptions = [];
  1076. this.showResult = false;
  1077. },
  1078. // 保存当前题目的答案
  1079. saveAnswer() {
  1080. let answer;
  1081. if (this.currentQuestion.questionType === 0) { // 开放问题
  1082. answer = {
  1083. questionId: this.currentQuestion.id,
  1084. questionType: this.currentQuestion.questionType,
  1085. answer: this.openQuestionAnswer,
  1086. answerDuration: this.getAnswerDuration() // 添加答题时长
  1087. };
  1088. } else if (this.currentQuestion.questionType === 1 || this.currentQuestion.questionType === 3 || this.currentQuestion.questionType === 4) { // 单选题、看图答题或类型4题目
  1089. answer = {
  1090. questionId: this.currentQuestion.id,
  1091. questionType: this.currentQuestion.questionType,
  1092. answer: this.selectedOption,
  1093. answerDuration: this.getAnswerDuration() // 添加答题时长
  1094. };
  1095. } else if (this.currentQuestion.questionType === 6) { // 填空题
  1096. answer = {
  1097. questionId: this.currentQuestion.id,
  1098. questionType: this.currentQuestion.questionType,
  1099. answer: this.currentBlankAnswers[this.currentQuestion.id] || {},
  1100. answerDuration: this.getAnswerDuration() // 添加答题时长
  1101. };
  1102. } else { // 多选题
  1103. answer = {
  1104. questionId: this.currentQuestion.id,
  1105. questionType: this.currentQuestion.questionType,
  1106. answer: this.selectedOptions,
  1107. answerDuration: this.getAnswerDuration() // 添加答题时长
  1108. };
  1109. }
  1110. // 检查是否已存在该题目的答案,如果存在则更新
  1111. const existingIndex = this.answers.findIndex(a => a.questionId === answer.questionId);
  1112. if (existingIndex > -1) {
  1113. this.answers[existingIndex] = answer;
  1114. } else {
  1115. this.answers.push(answer);
  1116. }
  1117. // 保存当前答案以便提交
  1118. this.currentAnswer = answer;
  1119. console.log('已保存答案:', this.answers);
  1120. },
  1121. // 获取答题时长(秒)
  1122. getAnswerDuration() {
  1123. // 这里假设每题默认30秒,根据剩余时间计算用时
  1124. // 您可以根据实际情况调整计算逻辑
  1125. const remainingTimeArr = this.remainingTime.split(':');
  1126. const remainingSeconds = parseInt(remainingTimeArr[0]) * 60 + parseInt(remainingTimeArr[1]);
  1127. return 30 - remainingSeconds; // 假设每题30秒
  1128. },
  1129. // 提交当前答案
  1130. async submitCurrentAnswer() {
  1131. if (!this.currentAnswer || this.isSubmitting) return; // 如果正在提交或没有答案,则不执行
  1132. try {
  1133. // 设置提交状态为true
  1134. this.isSubmitting = true;
  1135. // 显示提交中提示
  1136. /* uni.showLoading({
  1137. title: '正在提交答案...'
  1138. }); */
  1139. // 构建提交数据
  1140. let answerContent = '';
  1141. let answerOptions = [];
  1142. let blankAnswers = [];
  1143. if (this.currentAnswer.questionType === 0) {
  1144. // 开放题直接使用文本答案
  1145. answerContent = this.currentAnswer.answer;
  1146. answerOptions = [];
  1147. } else if (this.currentAnswer.questionType === 1 || this.currentAnswer.questionType === 3 || this.currentAnswer.questionType === 4) {
  1148. // 单选题或看图答题,获取选项ID而不是索引
  1149. const selectedIndex = this.currentAnswer.answer;
  1150. const selectedOption = this.currentQuestion.options[selectedIndex];
  1151. console.log('selectedOption',selectedOption);
  1152. const optionId = selectedOption.id ? selectedOption.id : selectedIndex;
  1153. answerContent = optionId.toString();
  1154. answerOptions = [optionId];
  1155. } else if (this.currentAnswer.questionType === 2) {
  1156. // 多选题,将选项ID数组转为逗号分隔的字符串
  1157. const selectedIndices = this.currentAnswer.answer;
  1158. const selectedOptionIds = selectedIndices.map(index => {
  1159. const option = this.currentQuestion.options[index];
  1160. // 使用选项的ID或其他唯一标识符
  1161. return option.id ? option.id : index;
  1162. });
  1163. answerOptions = selectedOptionIds;
  1164. } else if (this.currentAnswer.questionType === 6) {
  1165. // 填空题,构造填空答案数组
  1166. const blankAnswerObj = this.currentAnswer.answer;
  1167. if (blankAnswerObj && typeof blankAnswerObj === 'object') {
  1168. blankAnswers = Object.entries(blankAnswerObj).map(([key, value]) => ({
  1169. blank_index: parseInt(key),
  1170. answer_text: value || ''
  1171. }));
  1172. }
  1173. }
  1174. const submitData = {
  1175. position_id: JSON.parse(uni.getStorageSync('selectedJob')).id,
  1176. applicant_id: JSON.parse(uni.getStorageSync('userInfo')).id,
  1177. job_position_question_id: this.currentAnswer.questionId,
  1178. // answer_content: answerContent,
  1179. answer_options: answerOptions,
  1180. answer_duration: this.currentAnswer.answerDuration || 0,
  1181. tenant_id:JSON.parse(uni.getStorageSync('userInfo')).tenant_id || 1
  1182. };
  1183. // 如果是填空题,添加 blank_answers 字段
  1184. if (this.currentAnswer.questionType === 6 && blankAnswers.length > 0) {
  1185. submitData.blank_answers = blankAnswers;
  1186. }
  1187. console.log('提交数据:', submitData);
  1188. // 调用API提交答案
  1189. const res = await this.$http.post(`${apiBaseUrl}/api/job/submit_answer`, submitData);
  1190. console.log('提交答案响应:', res);
  1191. return res;
  1192. } catch (error) {
  1193. console.error('提交答案失败:', error);
  1194. // 显示错误提示
  1195. uni.showToast({
  1196. title: '提交答案失败,请重试',
  1197. icon: 'none'
  1198. });
  1199. throw error;
  1200. } finally {
  1201. // 隐藏加载提示
  1202. uni.hideLoading();
  1203. // 重置提交状态
  1204. this.isSubmitting = false;
  1205. }
  1206. },
  1207. // 修改 goToNextQuestion 方法
  1208. async goToNextQuestion() {
  1209. // 检查是否完成当前组的所有题目
  1210. if (this.currentQuestionIndex >= this.questions.length - 1) {
  1211. // 当前组的所有题目都已完成,显示继续按钮
  1212. this.showContinueButton = true;
  1213. // 使用延时确保按钮渲染完成后再滚动
  1214. setTimeout(() => {
  1215. // 先重置 scrollTop,然后再设置新值,强制触发更新
  1216. this.scrollTop = 0;
  1217. // 使用 nextTick 确保视图已更新
  1218. this.$nextTick(() => {
  1219. // 延迟设置新的滚动位置
  1220. setTimeout(() => {
  1221. this.scrollTop = 10000; // 一个足够大的值
  1222. }, 100);
  1223. });
  1224. }, 200);
  1225. return;
  1226. }
  1227. // 如果还有下一题,继续下一题
  1228. this.currentQuestionIndex++;
  1229. this.currentScrollId = 'question-' + this.currentQuestionIndex;
  1230. // 重置状态(只在非最后一题时重置)
  1231. this.showResult = false;
  1232. this.selectedOption = null;
  1233. this.selectedOptions = [];
  1234. this.openQuestionAnswer = '';
  1235. // 如果有下一题的详情
  1236. if (this.questions[this.currentQuestionIndex]) {
  1237. // 更新进度
  1238. this.progressWidth = (this.currentQuestionIndex + 1) / this.questions.length * 100;
  1239. // 重置计时器
  1240. this.resetTimer();
  1241. // 播放AI介绍下一题
  1242. this.playAiSpeaking();
  1243. setTimeout(() => {
  1244. this.pauseAiSpeaking();
  1245. }, 2000);
  1246. }
  1247. },
  1248. // 填空题相关方法
  1249. // 获取填空值
  1250. getBlankValue(questionId, blankIndex) {
  1251. if (this.currentBlankAnswers[questionId] && this.currentBlankAnswers[questionId][blankIndex]) {
  1252. return this.currentBlankAnswers[questionId][blankIndex];
  1253. }
  1254. return '';
  1255. },
  1256. // 处理填空输入
  1257. handleBlankInput(questionId, blankIndex, event) {
  1258. const value = event.detail.value;
  1259. if (!this.currentBlankAnswers[questionId]) {
  1260. this.$set(this.currentBlankAnswers, questionId, {});
  1261. }
  1262. this.$set(this.currentBlankAnswers[questionId], blankIndex, value);
  1263. // 保存到填空答案数组中
  1264. const existingAnswerIndex = this.blankAnswers.findIndex(answer => answer.questionId === questionId);
  1265. if (existingAnswerIndex > -1) {
  1266. this.blankAnswers[existingAnswerIndex].answer = this.currentBlankAnswers[questionId];
  1267. } else {
  1268. this.blankAnswers.push({
  1269. questionId: questionId,
  1270. answer: this.currentBlankAnswers[questionId]
  1271. });
  1272. }
  1273. },
  1274. // 检查是否有填空答案
  1275. hasBlankAnswers(question) {
  1276. const answers = this.currentBlankAnswers[question.id];
  1277. if (!answers) return false;
  1278. // 检查是否至少有一个空白被填写
  1279. return Object.values(answers).some(value => value && value.trim() !== '');
  1280. },
  1281. // 提交填空题
  1282. submitBlankQuestion(qIndex) {
  1283. const question = this.questions[qIndex];
  1284. // 检查答案
  1285. this.checkAnswer();
  1286. // 保存当前题目的答案
  1287. this.saveAnswer();
  1288. // 提交答案
  1289. this.submitCurrentAnswer().then(() => {
  1290. // 提交成功后,短暂延迟后自动进入下一题
  1291. setTimeout(() => {
  1292. this.goToNextQuestion();
  1293. }, 500);
  1294. }).catch(error => {
  1295. console.error('提交答案失败:', error);
  1296. // 即使提交失败也继续下一题
  1297. setTimeout(() => {
  1298. this.goToNextQuestion();
  1299. }, 1000);
  1300. });
  1301. }
  1302. },
  1303. // 添加生命周期钩子,确保在组件销毁时清除计时器
  1304. beforeDestroy() {
  1305. if (this.timerInterval) {
  1306. clearInterval(this.timerInterval);
  1307. }
  1308. }
  1309. }
  1310. </script>
  1311. <style>
  1312. .camera-container {
  1313. position: relative;
  1314. margin-top: 25px;
  1315. width: 100%;
  1316. height: 96vh;
  1317. background-color: #ffffff;
  1318. display: flex;
  1319. flex-direction: column;
  1320. overflow: hidden; /* 防止内容溢出 */
  1321. }
  1322. .header {
  1323. height: 90rpx;
  1324. /* background-color: #000000; */
  1325. display: flex;
  1326. align-items: center;
  1327. padding: 0 30rpx;
  1328. /* color: #ffffff; */
  1329. }
  1330. .back-button {
  1331. width: 60rpx;
  1332. height: 60rpx;
  1333. display: flex;
  1334. align-items: center;
  1335. justify-content: center;
  1336. }
  1337. .title {
  1338. flex: 1;
  1339. text-align: center;
  1340. font-size: 32rpx;
  1341. font-weight: bold;
  1342. }
  1343. .controls {
  1344. display: flex;
  1345. gap: 30rpx;
  1346. }
  1347. .iconfont {
  1348. font-size: 40rpx;
  1349. }
  1350. .content {
  1351. flex: 1;
  1352. display: flex;
  1353. flex-direction: column;
  1354. position: relative;
  1355. padding: 50rpx 20rpx 0;
  1356. }
  1357. .progress-container {
  1358. display: flex;
  1359. flex-direction: column;
  1360. justify-content: space-between;
  1361. margin-bottom: 20rpx;
  1362. }
  1363. .progress-step {
  1364. display: flex;
  1365. align-items: center;
  1366. margin-bottom: 10rpx;
  1367. }
  1368. .step-circle {
  1369. width: 40rpx;
  1370. height: 40rpx;
  1371. border-radius: 50%;
  1372. background-color: #e0e0e0;
  1373. display: flex;
  1374. align-items: center;
  1375. justify-content: center;
  1376. font-size: 24rpx;
  1377. margin-right: 10rpx;
  1378. }
  1379. .step-circle.active {
  1380. background-color: #ff9500;
  1381. color: #ffffff;
  1382. }
  1383. .step-text {
  1384. font-size: 24rpx;
  1385. color: #666666;
  1386. }
  1387. .progress-bar {
  1388. height: 10rpx;
  1389. background-color: #e0e0e0;
  1390. border-radius: 5rpx;
  1391. overflow: hidden;
  1392. margin-bottom: 20rpx;
  1393. }
  1394. .progress-fill {
  1395. height: 100%;
  1396. background-color: #00c853;
  1397. transition: width 0.3s;
  1398. }
  1399. .interview-content {
  1400. flex: 1;
  1401. display: flex;
  1402. flex-direction: column;
  1403. margin-bottom: 40rpx;
  1404. padding: 20rpx;
  1405. border-bottom: 1px solid #eee;
  1406. }
  1407. .video-area {
  1408. display: flex;
  1409. /* flex-direction: column; */
  1410. justify-content: space-between;
  1411. height: auto;
  1412. margin-bottom: 20rpx;
  1413. }
  1414. .video-camera {
  1415. display: flex;
  1416. flex-direction: row;
  1417. align-items: center;
  1418. justify-content: space-between;
  1419. width: 65%;
  1420. }
  1421. .interviewer {
  1422. background-color: #f5f5f5;
  1423. display: flex;
  1424. align-items: center;
  1425. justify-content: center;
  1426. position: relative;
  1427. width: 48% !important;
  1428. height: 300rpx;
  1429. }
  1430. .interviewer-video {
  1431. width: 100%;
  1432. height: 100%;
  1433. object-fit: cover;
  1434. }
  1435. .interviewer-avatar {
  1436. width: 80%;
  1437. height: 80%;
  1438. object-fit: contain;
  1439. }
  1440. .user-camera-container {
  1441. width: 48%;
  1442. height: 300rpx;
  1443. border-radius: 10rpx;
  1444. overflow: hidden;
  1445. border: 4rpx solid #ffffff;
  1446. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.2);
  1447. }
  1448. .question-area {
  1449. flex: 1;
  1450. display: flex;
  1451. flex-direction: column;
  1452. }
  1453. .question-number {
  1454. font-size: 28rpx;
  1455. color: #666;
  1456. margin-bottom: 20rpx;
  1457. }
  1458. .question-importance {
  1459. background-color: #f9f9f9;
  1460. padding: 20rpx;
  1461. border-radius: 10rpx;
  1462. margin-bottom: 20rpx;
  1463. font-size: 28rpx;
  1464. color: #333;
  1465. }
  1466. .question-importance text {
  1467. color: #ff0000;
  1468. /* margin-right: 10rpx; */
  1469. }
  1470. .options {
  1471. display: flex;
  1472. flex-direction: column;
  1473. gap: 20rpx;
  1474. margin-bottom: 30rpx;
  1475. }
  1476. .option-item {
  1477. padding: 20rpx;
  1478. background-color: #f5f5f5;
  1479. border-radius: 10rpx;
  1480. font-size: 28rpx;
  1481. transition: all 0.3s;
  1482. border: 1px solid #e0e0e0;
  1483. display: flex;
  1484. align-items: center;
  1485. cursor: pointer; /* 添加指针样式 */
  1486. }
  1487. .option-item:active {
  1488. transform: scale(0.98); /* 点击时轻微缩小效果 */
  1489. opacity: 0.9;
  1490. }
  1491. .option-selected {
  1492. background-color: #e6f7ff;
  1493. border: 1px solid #1890ff;
  1494. }
  1495. /* 添加选中后的动画效果 */
  1496. @keyframes selectedPulse {
  1497. 0% { box-shadow: 0 0 0 0 rgba(24, 144, 255, 0.4); }
  1498. 70% { box-shadow: 0 0 0 10px rgba(24, 144, 255, 0); }
  1499. 100% { box-shadow: 0 0 0 0 rgba(24, 144, 255, 0); }
  1500. }
  1501. .option-selected {
  1502. animation: selectedPulse 1.5s ease-out;
  1503. }
  1504. .option-correct {
  1505. background-color: #d4f7d4;
  1506. border: 1px solid #52c41a;
  1507. }
  1508. .option-wrong {
  1509. background-color: #fff1f0;
  1510. border: 1px solid #ff4d4f;
  1511. }
  1512. .option-text {
  1513. color: #333;
  1514. }
  1515. .timer-container {
  1516. text-align: right;
  1517. margin: 20rpx 0;
  1518. }
  1519. .timer-text {
  1520. font-size: 24rpx;
  1521. color: #666;
  1522. background-color: #f0f0f0;
  1523. padding: 6rpx 12rpx;
  1524. border-radius: 6rpx;
  1525. }
  1526. .bottom-button-container {
  1527. position: fixed;
  1528. bottom: 50px;
  1529. left: 5%;
  1530. right: 0;
  1531. padding: 20rpx;
  1532. display: flex;
  1533. justify-content: center;
  1534. z-index: 10;
  1535. }
  1536. .bottom-button-wrapper {
  1537. display: flex;
  1538. width: 100%;
  1539. justify-content: space-between;
  1540. align-items: center;
  1541. }
  1542. .timer-display {
  1543. font-size: 28rpx;
  1544. color: #666;
  1545. padding: 10rpx 20rpx;
  1546. border-radius: 6rpx;
  1547. }
  1548. .next-button {
  1549. background-color: #0039b3;
  1550. color: #ffffff;
  1551. border-radius: 10rpx;
  1552. font-size: 30rpx;
  1553. height: 80rpx;
  1554. line-height: 80rpx;
  1555. width: 90%;
  1556. text-align: center;
  1557. margin: 0;
  1558. }
  1559. .footer {
  1560. height: 100rpx;
  1561. background-color: #000000;
  1562. display: flex;
  1563. justify-content: space-between;
  1564. align-items: center;
  1565. padding: 0 30rpx;
  1566. color: #ffffff;
  1567. }
  1568. .timer {
  1569. font-size: 28rpx;
  1570. }
  1571. .next-step {
  1572. font-size: 28rpx;
  1573. }
  1574. .interview-end-modal {
  1575. position: fixed;
  1576. top: 0;
  1577. left: 0;
  1578. right: 0;
  1579. bottom: 0;
  1580. background-color: rgba(0, 0, 0, 0.5);
  1581. display: flex;
  1582. align-items: center;
  1583. justify-content: center;
  1584. z-index: 999;
  1585. }
  1586. .modal-content {
  1587. width: 80%;
  1588. background-color: #ffffff;
  1589. border-radius: 20rpx;
  1590. padding: 40rpx;
  1591. display: flex;
  1592. flex-direction: column;
  1593. align-items: center;
  1594. }
  1595. .modal-title {
  1596. font-size: 36rpx;
  1597. font-weight: bold;
  1598. margin-bottom: 30rpx;
  1599. }
  1600. .score-display {
  1601. font-size: 48rpx;
  1602. font-weight: bold;
  1603. color: #0039b3;
  1604. margin: 20rpx 0;
  1605. }
  1606. .modal-message {
  1607. font-size: 28rpx;
  1608. color: #666;
  1609. text-align: center;
  1610. margin-bottom: 40rpx;
  1611. }
  1612. .modal-buttons {
  1613. display: flex;
  1614. justify-content: space-between;
  1615. width: 100%;
  1616. margin-top: 20rpx;
  1617. }
  1618. .modal-button {
  1619. width: 45%;
  1620. }
  1621. @keyframes speaking {
  1622. 0% {
  1623. opacity: 0.8;
  1624. }
  1625. 50% {
  1626. opacity: 1;
  1627. }
  1628. 100% {
  1629. opacity: 0.8;
  1630. }
  1631. }
  1632. .speaking {
  1633. animation: speaking 1.5s infinite;
  1634. }
  1635. .digital-avatar {
  1636. display: flex;
  1637. flex-direction: row;
  1638. align-items: flex-start;
  1639. justify-content: space-between;
  1640. width: 100%;
  1641. margin-bottom: 20rpx;
  1642. }
  1643. .message-box {
  1644. width: 65%;
  1645. min-height: 120rpx;
  1646. background-color: #f5f5f5;
  1647. border-radius: 10rpx;
  1648. padding: 15rpx;
  1649. margin-right: 20rpx;
  1650. display: flex;
  1651. align-items: center;
  1652. }
  1653. .message-text {
  1654. font-size: 24rpx;
  1655. color: #333;
  1656. line-height: 1.5;
  1657. }
  1658. .user-avatar {
  1659. width: 110px;
  1660. height: 160px;
  1661. border-radius: 10rpx;
  1662. overflow: hidden;
  1663. }
  1664. .camera {
  1665. width: 100%;
  1666. height: 100%;
  1667. border-radius: 10rpx;
  1668. border: 2rpx solid #e0e0e0;
  1669. }
  1670. .avatar-image {
  1671. width: 100%;
  1672. height: 100%;
  1673. border-radius: 10rpx;
  1674. border: 2rpx solid #e0e0e0;
  1675. }
  1676. .digital-human-webview {
  1677. width: 100%;
  1678. height: 100%;
  1679. border-radius: 10rpx;
  1680. border: 2rpx solid #e0e0e0;
  1681. }
  1682. .interview-complete-screen {
  1683. position: fixed;
  1684. top: 0;
  1685. left: 0;
  1686. right: 0;
  1687. bottom: 0;
  1688. background-color: #f0f5ff;
  1689. display: flex;
  1690. flex-direction: column;
  1691. align-items: center;
  1692. justify-content: center;
  1693. z-index: 1000;
  1694. padding: 40rpx;
  1695. }
  1696. .digital-avatar-large {
  1697. width: 200rpx;
  1698. height: 200rpx;
  1699. margin-bottom: 60rpx;
  1700. }
  1701. .avatar-image-large {
  1702. width: 100%;
  1703. height: 100%;
  1704. border-radius: 30rpx;
  1705. }
  1706. .complete-message {
  1707. font-size: 40rpx;
  1708. font-weight: bold;
  1709. color: #333;
  1710. margin-bottom: 30rpx;
  1711. }
  1712. .complete-description {
  1713. font-size: 28rpx;
  1714. color: #666;
  1715. text-align: center;
  1716. margin-bottom: 80rpx;
  1717. line-height: 1.5;
  1718. }
  1719. .complete-button {
  1720. background-color: #0039b3;
  1721. color: #ffffff;
  1722. border-radius: 10rpx;
  1723. font-size: 32rpx;
  1724. padding: 20rpx 60rpx;
  1725. margin-top: 40rpx;
  1726. }
  1727. /* 添加加载状态样式 */
  1728. .loading-container {
  1729. position: absolute;
  1730. top: 0;
  1731. left: 0;
  1732. right: 0;
  1733. bottom: 0;
  1734. display: flex;
  1735. flex-direction: column;
  1736. align-items: center;
  1737. justify-content: center;
  1738. background-color: rgba(255, 255, 255, 0.9);
  1739. z-index: 100;
  1740. }
  1741. .loading-text {
  1742. margin-top: 20rpx;
  1743. font-size: 28rpx;
  1744. color: #666;
  1745. }
  1746. .error-container {
  1747. text-align: center;
  1748. }
  1749. .error-message {
  1750. font-size: 28rpx;
  1751. color: #ff4d4f;
  1752. margin-bottom: 30rpx;
  1753. }
  1754. .retry-button {
  1755. background-color: #0039b3;
  1756. color: #ffffff;
  1757. border-radius: 10rpx;
  1758. font-size: 28rpx;
  1759. padding: 10rpx 30rpx;
  1760. }
  1761. .question-type {
  1762. display: inline-block;
  1763. /* background-color: #0039b3; */
  1764. color: white;
  1765. font-size: 24rpx;
  1766. /* padding: 4rpx 5rpx; */
  1767. border-radius: 6rpx;
  1768. /* margin-right: 10rpx; */
  1769. }
  1770. /* 新增的开放问题样式 */
  1771. .open-question-container {
  1772. display: flex;
  1773. flex-direction: column;
  1774. width: 100%;
  1775. margin-bottom: 20rpx;
  1776. }
  1777. .open-question-input {
  1778. width: 100%;
  1779. height: 300rpx;
  1780. background-color: #f9f9f9;
  1781. border: 1px solid #e0e0e0;
  1782. border-radius: 10rpx;
  1783. padding: 20rpx;
  1784. font-size: 28rpx;
  1785. color: #333;
  1786. }
  1787. .word-count {
  1788. text-align: right;
  1789. font-size: 24rpx;
  1790. color: #999;
  1791. margin-top: 10rpx;
  1792. }
  1793. .option-prefix {
  1794. margin-right: 10rpx;
  1795. font-weight: bold;
  1796. color: #333;
  1797. min-width: 30rpx;
  1798. }
  1799. /* 新增的图片显示样式 */
  1800. .question-image-container {
  1801. width: 100%;
  1802. margin: 20rpx 0;
  1803. display: flex;
  1804. justify-content: center;
  1805. align-items: center;
  1806. }
  1807. .question-image {
  1808. width: 100%;
  1809. max-width: 600rpx;
  1810. border-radius: 10rpx;
  1811. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  1812. }
  1813. /* 添加滚动视图样式 */
  1814. .content-scroll {
  1815. flex: 1;
  1816. height: calc(100vh - 200px); /* 只减去顶部相机的高度 */
  1817. margin-top: 10px;
  1818. }
  1819. /* 添加底部空白区域,防止内容被固定按钮遮挡 */
  1820. .bottom-space {
  1821. height: 50rpx; /* 减小底部空白区域 */
  1822. }
  1823. /* 添加流式布局相关样式 */
  1824. .interview-content {
  1825. margin-bottom: 40rpx;
  1826. padding: 20rpx;
  1827. border-bottom: 1px solid #eee;
  1828. }
  1829. .option-disabled {
  1830. opacity: 0.7;
  1831. background-color: #f0f0f0;
  1832. }
  1833. .question-button-container {
  1834. margin-top: 20rpx;
  1835. display: flex;
  1836. justify-content: center;
  1837. }
  1838. .bottom-timer-container {
  1839. display: none;
  1840. }
  1841. /* 添加固定相机容器样式 */
  1842. .fixed-camera-container {
  1843. position: sticky;
  1844. top: 0;
  1845. width: 100%;
  1846. padding: 20rpx;
  1847. background-color: #fff;
  1848. z-index: 10;
  1849. display: flex;
  1850. justify-content: flex-start;
  1851. border-bottom: 1px solid #eee;
  1852. }
  1853. .camera-warning {
  1854. animation: camera-warning-flash 1s ease-in-out infinite;
  1855. border: 2px solid #ff0000;
  1856. }
  1857. @keyframes camera-warning-flash {
  1858. 0% {
  1859. border-color: #ff0000;
  1860. box-shadow: 0 0 15px rgba(255, 0, 0, 0.8);
  1861. }
  1862. 50% {
  1863. border-color: rgba(255, 0, 0, 0.3);
  1864. box-shadow: 0 0 5px rgba(255, 0, 0, 0.4);
  1865. }
  1866. 100% {
  1867. border-color: #ff0000;
  1868. box-shadow: 0 0 15px rgba(255, 0, 0, 0.8);
  1869. }
  1870. }
  1871. .user-avatar {
  1872. width: 110px;
  1873. height: 160px;
  1874. border-radius: 10rpx;
  1875. overflow: hidden;
  1876. }
  1877. /* 添加继续按钮样式 */
  1878. .continue-button-container {
  1879. display: flex;
  1880. justify-content: center;
  1881. padding: 20rpx;
  1882. margin-top: 20rpx;
  1883. }
  1884. .continue-button {
  1885. background-color: #0039b3;
  1886. color: #ffffff;
  1887. border-radius: 10rpx;
  1888. font-size: 30rpx;
  1889. height: 80rpx;
  1890. line-height: 80rpx;
  1891. width: 90%;
  1892. text-align: center;
  1893. }
  1894. /* 添加新的样式 */
  1895. .prompt-modal {
  1896. position: fixed;
  1897. top: 0;
  1898. left: 0;
  1899. right: 0;
  1900. bottom: 0;
  1901. background-color: rgba(0, 0, 0, 0.5);
  1902. display: flex;
  1903. align-items: center;
  1904. justify-content: center;
  1905. z-index: 1000;
  1906. }
  1907. .prompt-content {
  1908. width: 85%;
  1909. background-color: #ffffff;
  1910. border-radius: 20rpx;
  1911. padding: 40rpx;
  1912. display: flex;
  1913. flex-direction: column;
  1914. align-items: center;
  1915. }
  1916. .prompt-title {
  1917. font-size: 36rpx;
  1918. font-weight: bold;
  1919. color: #333;
  1920. margin-bottom: 30rpx;
  1921. }
  1922. .prompt-text {
  1923. font-size: 28rpx;
  1924. color: #666;
  1925. line-height: 1.6;
  1926. margin-bottom: 20rpx;
  1927. text-align: justify;
  1928. }
  1929. .bold-text {
  1930. font-weight: bold;
  1931. color: #333;
  1932. }
  1933. .prompt-button {
  1934. background-color: #0039b3;
  1935. color: #ffffff;
  1936. border-radius: 10rpx;
  1937. font-size: 30rpx;
  1938. height: 80rpx;
  1939. line-height: 80rpx;
  1940. width: 60%;
  1941. text-align: center;
  1942. margin-top: 30rpx;
  1943. }
  1944. .custom-navbar {
  1945. position: fixed;
  1946. top: 0;
  1947. left: 0;
  1948. right: 0;
  1949. height: 44px;
  1950. background-color: #ffffff;
  1951. display: flex;
  1952. align-items: center;
  1953. justify-content: center;
  1954. z-index: 999;
  1955. }
  1956. .navbar-title {
  1957. font-size: 16px;
  1958. font-weight: bold;
  1959. }
  1960. .content {
  1961. margin-top: 44px;
  1962. padding-top: var(--status-bar-height);
  1963. }
  1964. /* 填空题样式 */
  1965. .blank-question-container {
  1966. margin: 20rpx 0;
  1967. }
  1968. .blank-question-text {
  1969. line-height: 1.8;
  1970. font-size: 28rpx;
  1971. color: #333;
  1972. padding: 20rpx;
  1973. background-color: #f9f9f9;
  1974. border-radius: 10rpx;
  1975. margin-bottom: 20rpx;
  1976. }
  1977. .blank-inputs {
  1978. display: flex;
  1979. flex-direction: column;
  1980. gap: 15rpx;
  1981. }
  1982. .blank-input-item {
  1983. display: flex;
  1984. align-items: center;
  1985. padding: 10rpx 20rpx;
  1986. background-color: #fff;
  1987. border-radius: 8rpx;
  1988. border: 1px solid #e0e0e0;
  1989. }
  1990. .blank-label {
  1991. font-size: 26rpx;
  1992. color: #666;
  1993. margin-right: 20rpx;
  1994. min-width: 120rpx;
  1995. }
  1996. /* 填空输入框样式 */
  1997. .blank-input {
  1998. flex: 1;
  1999. height: 60rpx;
  2000. border: 1px solid #ccc;
  2001. border-radius: 6rpx;
  2002. padding: 0 15rpx;
  2003. font-size: 26rpx;
  2004. background-color: #fff;
  2005. }
  2006. .blank-input:disabled {
  2007. background-color: #f5f5f5;
  2008. color: #999;
  2009. }
  2010. </style>