camera.vue 62 KB

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