camera.vue 60 KB

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