interview-question.js 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const common_config = require("../../common/config.js");
  4. const _sfc_main = {
  5. name: "IdentityVerify",
  6. data() {
  7. return {
  8. loading: false,
  9. responses: [],
  10. processedResponses: [],
  11. assistantResponse: "",
  12. audioTranscript: "",
  13. videoPlaying: false,
  14. showDebugInfo: false,
  15. // 设置为true可以显示调试信息
  16. videoUrl: "http://121.36.251.245:9000/minlong/tenant_1/general_uploads/abdaa6fda8494e3a8613304743ed0433.mp4",
  17. // 用于存储AI数字人视频URL
  18. showReplayButton: false,
  19. cameraStream: null,
  20. // 存储摄像头流
  21. cameraError: null,
  22. // 存储摄像头错误信息
  23. useMiniProgramCameraComponent: false,
  24. // 添加小程序相机组件标志
  25. cameraContext: null,
  26. // 添加相机上下文
  27. currentSubtitle: "",
  28. subtitles: [
  29. {
  30. startTime: 0,
  31. // 开始时间(秒)
  32. endTime: 6,
  33. // 结束时间(秒)
  34. text: "您已完成本次面试全部题目,请问您对于这个岗位还有什么想要了解的吗?"
  35. }
  36. ],
  37. // secondVideoSubtitles: [
  38. // {
  39. // startTime: 0,
  40. // endTime: 10,
  41. // text: '请结合您的基本信息与过往履历进行简单的自我介绍,并讲一讲您有哪些优势胜任本岗位:'
  42. // }
  43. // ],
  44. // thirdVideoSubtitles: [
  45. // {
  46. // startTime: 0,
  47. // endTime: 4,
  48. // text: '在工作中,你如何确保个人防护装备的正确使用?'
  49. // }
  50. // ],
  51. // fourthVideoSubtitles: [
  52. // {
  53. // startTime: 0,
  54. // endTime: 4,
  55. // text: '描述一次你与团队合作改善生产流程的经历。'
  56. // }
  57. // ],
  58. // fifthVideoSubtitles: [
  59. // {
  60. // startTime: 0,
  61. // endTime: 6,
  62. // text: '你在团队合作中曾遇到过哪些挑战?如何解决团队内部的分歧?'
  63. // }
  64. // ],
  65. // sixthVideoSubtitles: [
  66. // {
  67. // startTime: 0,
  68. // endTime: 5,
  69. // text: '您已完成本次面试全部题目,请问您对于这个岗位还有什么想要了解的吗?'
  70. // }
  71. // ],
  72. showAnswerButton: false,
  73. // 控制答题按钮显示
  74. currentVideoIndex: 0,
  75. // 当前播放的视频索引
  76. videoList: [
  77. "http://121.36.251.245:9000/minlong/tenant_1/general_uploads/abdaa6fda8494e3a8613304743ed0433.mp4"
  78. //结束
  79. ],
  80. isRecording: false,
  81. recordingTimer: null,
  82. showStopRecordingButton: false,
  83. mediaRecorder: null,
  84. recordedChunks: [],
  85. recorder: null,
  86. lastUploadedVideoUrl: "",
  87. showStartRecordingButton: false,
  88. showRetryButton: false,
  89. // 控制重试按钮显示
  90. lastVideoToRetry: null,
  91. // 存储上次失败的视频URL,用于重试
  92. recordingStartTime: null,
  93. // 录制开始时间
  94. recordingTimerCount: 0,
  95. // 录制计时器计数
  96. recordingTimeDisplay: "00:00",
  97. // 格式化的录制时间显示
  98. // 添加上传队列相关数据
  99. uploadQueue: [],
  100. // 存储待上传的视频
  101. isUploading: false,
  102. // 标记是否正在上传
  103. uploadProgress: {},
  104. // 存储每个视频的上传进度
  105. uploadStatus: {},
  106. // 存储每个视频的上传状态
  107. showUploadStatus: false,
  108. // 是否显示上传状态指示器
  109. uploadStatusText: "",
  110. // 上传状态文本
  111. mediaRecorderTimeout: null,
  112. // 用于存储MediaRecorder的超时机制
  113. maxRecordingTime: 300,
  114. // 最大录制时间(秒)- 从60秒改为300秒(5分钟)
  115. remainingTime: 300,
  116. // 剩余录制时间(秒)- 从60秒改为300秒
  117. // 修改初始视频索引,添加参数控制
  118. startFromLastVideo: false,
  119. // 是否从最后一个视频开始播放
  120. countdownValue: 10,
  121. // 倒计时数值
  122. showCountdown: false,
  123. // 是否显示倒计时蒙层
  124. countdownTimer: null,
  125. showGif: false,
  126. // 控制是否显示GIF
  127. gifUrl: ""
  128. // GIF图片的URL
  129. };
  130. },
  131. onLoad(options) {
  132. if (options && options.startFromLast === "true") {
  133. this.startFromLastVideo = true;
  134. this.currentVideoIndex = this.videoList.length - 1;
  135. }
  136. },
  137. mounted() {
  138. if (this.startFromLastVideo) {
  139. console.log("从最后一个视频开始播放");
  140. this.currentVideoIndex = this.videoList.length - 1;
  141. this.videoUrl = this.videoList[this.currentVideoIndex];
  142. }
  143. this.playDigitalHumanVideo();
  144. this.checkAudioPermission();
  145. this.initCamera();
  146. this.checkIOSCameraRecordPermission();
  147. this.checkAndFixRenderingIssues();
  148. setTimeout(() => {
  149. if (this.cameraStream && !this.useMiniProgramCameraComponent) {
  150. this.testAudioInput();
  151. }
  152. }, 3e3);
  153. common_vendor.index.setKeepScreenOn({
  154. keepScreenOn: true
  155. });
  156. },
  157. beforeDestroy() {
  158. this.stopUserCamera();
  159. },
  160. methods: {
  161. // 初始化相机
  162. async initCamera() {
  163. const systemInfo = common_vendor.index.getSystemInfoSync();
  164. const isMiniProgram = systemInfo.uniPlatform === "mp-weixin" || systemInfo.uniPlatform === "mp-alipay" || systemInfo.uniPlatform === "mp-baidu";
  165. if (isMiniProgram) {
  166. this.useMiniProgramCameraComponent = true;
  167. this.cameraContext = common_vendor.index.createCameraContext();
  168. common_vendor.index.getSetting({
  169. success: (res) => {
  170. if (!res.authSetting["scope.record"]) {
  171. common_vendor.index.authorize({
  172. scope: "scope.record",
  173. success: () => {
  174. console.log("录音权限已获取");
  175. },
  176. fail: (err) => {
  177. console.error("录音权限获取失败:", err);
  178. this.showPermissionDialog("录音");
  179. }
  180. });
  181. }
  182. if (!res.authSetting["scope.camera"]) {
  183. common_vendor.index.authorize({
  184. scope: "scope.camera",
  185. success: () => {
  186. console.log("相机权限已获取");
  187. },
  188. fail: (err) => {
  189. console.error("相机权限获取失败:", err);
  190. this.showPermissionDialog("相机");
  191. }
  192. });
  193. }
  194. const systemInfo2 = common_vendor.index.getSystemInfoSync();
  195. if (systemInfo2.platform === "ios") {
  196. if (!res.authSetting["scope.camera"] || !res.authSetting["scope.record"]) {
  197. console.log("iOS需要同时获取相机和录音权限");
  198. }
  199. }
  200. }
  201. });
  202. } else {
  203. try {
  204. const constraints = {
  205. audio: {
  206. echoCancellation: true,
  207. noiseSuppression: true,
  208. autoGainControl: true
  209. },
  210. video: {
  211. width: { ideal: 640, max: 1280 },
  212. // 控制视频宽度
  213. height: { ideal: 480, max: 720 },
  214. // 控制视频高度
  215. frameRate: { ideal: 15, max: 24 },
  216. // 控制帧率
  217. facingMode: "user"
  218. }
  219. };
  220. const stream = await navigator.mediaDevices.getUserMedia(constraints);
  221. this.cameraStream = stream;
  222. const audioTracks = stream.getAudioTracks();
  223. console.log("音频轨道数量:", audioTracks.length);
  224. if (audioTracks.length > 0) {
  225. console.log("音频轨道已获取:", audioTracks[0].label);
  226. audioTracks[0].enabled = true;
  227. } else {
  228. console.warn("未检测到音频轨道,尝试单独获取音频");
  229. this.tryGetAudioOnly();
  230. }
  231. const videoElement = this.$refs.userCameraVideo;
  232. if (videoElement) {
  233. videoElement.srcObject = stream;
  234. videoElement.muted = true;
  235. }
  236. } catch (error) {
  237. console.error("获取摄像头失败:", error);
  238. this.cameraError = error.message || "无法访问摄像头";
  239. common_vendor.index.showToast({
  240. title: "无法访问摄像头,请检查权限设置",
  241. icon: "none"
  242. });
  243. }
  244. }
  245. },
  246. // 停止用户摄像头
  247. stopUserCamera() {
  248. if (this.cameraStream) {
  249. this.cameraStream.getTracks().forEach((track) => {
  250. track.stop();
  251. });
  252. this.cameraStream = null;
  253. }
  254. },
  255. async fetchData() {
  256. this.loading = true;
  257. this.assistantResponse = "";
  258. this.audioTranscript = "";
  259. this.processedResponses = [];
  260. try {
  261. const requestTask = common_vendor.index.request({
  262. url: "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
  263. method: "POST",
  264. header: {
  265. "Content-Type": "application/json",
  266. "Authorization": "Bearer sk-9e1ec73a7d97493b8613c63f06b6110c"
  267. },
  268. data: {
  269. "model": "qwen-omni-turbo",
  270. "messages": [
  271. {
  272. "role": "user",
  273. "content": [
  274. {
  275. "type": "input_audio",
  276. "input_audio": {
  277. "data": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250211/tixcef/cherry.wav",
  278. "format": "wav"
  279. }
  280. },
  281. {
  282. "type": "text",
  283. "text": "这段音频在说什么"
  284. }
  285. ]
  286. }
  287. ],
  288. "stream": true,
  289. "stream_options": {
  290. "include_usage": true
  291. },
  292. "modalities": ["text", "audio"],
  293. "audio": { "voice": "Cherry", "format": "wav" }
  294. },
  295. success: (res) => {
  296. console.log("请求成功,响应数据:", res.data);
  297. if (typeof res.data === "string" && res.data.includes("data: {")) {
  298. const chunks = res.data.split("data: ").filter((chunk) => chunk.trim() !== "");
  299. chunks.forEach((chunk) => {
  300. this.handleStreamResponse(chunk);
  301. });
  302. } else {
  303. this.handleStreamResponse(res.data);
  304. }
  305. this.playDigitalHumanVideo();
  306. },
  307. fail: (err) => {
  308. console.error("请求失败:", err);
  309. },
  310. complete: () => {
  311. this.loading = false;
  312. }
  313. });
  314. } catch (error) {
  315. console.error("获取数据失败:", error);
  316. this.loading = false;
  317. }
  318. },
  319. handleStreamResponse(data) {
  320. if (typeof data === "string") {
  321. if (data === "[DONE]")
  322. return;
  323. try {
  324. const cleanData = data.trim();
  325. if (cleanData.startsWith("{") && cleanData.endsWith("}")) {
  326. const jsonData = JSON.parse(cleanData);
  327. this.processStreamChunk(jsonData);
  328. }
  329. } catch (e) {
  330. console.error("解析JSON失败:", e, "原始数据:", data);
  331. }
  332. } else {
  333. this.processStreamChunk(data);
  334. }
  335. },
  336. processStreamChunk(chunk) {
  337. if (chunk.choices && chunk.choices.length > 0) {
  338. const choice = chunk.choices[0];
  339. if (choice.delta && choice.delta.content) {
  340. this.assistantResponse += choice.delta.content;
  341. }
  342. if (choice.delta && choice.delta.audio && choice.delta.audio.transcript) {
  343. this.audioTranscript += choice.delta.audio.transcript;
  344. }
  345. if (choice.delta) {
  346. const result = {};
  347. if (choice.delta.role) {
  348. result.role = choice.delta.role;
  349. }
  350. if (choice.delta.audio && choice.delta.audio.transcript) {
  351. result.transcript = choice.delta.audio.transcript;
  352. }
  353. if (Object.keys(result).length > 0) {
  354. this.processedResponses.push(result);
  355. }
  356. }
  357. }
  358. },
  359. processResponseData() {
  360. this.processedResponses = this.responses.map((item) => {
  361. const result = {};
  362. if (item.delta && item.delta.role) {
  363. result.role = item.delta.role;
  364. }
  365. if (item.delta && item.delta.audio && item.delta.audio.transcript) {
  366. result.transcript = item.delta.audio.transcript;
  367. }
  368. return result;
  369. }).filter((item) => Object.keys(item).length > 0);
  370. },
  371. // 播放数字人视频
  372. playDigitalHumanVideo() {
  373. this.videoUrl = this.videoList[this.currentVideoIndex];
  374. this.videoPlaying = true;
  375. console.log(`播放视频 ${this.currentVideoIndex + 1}/${this.videoList.length}: ${this.videoUrl}`);
  376. this.$nextTick(() => {
  377. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  378. if (videoContext) {
  379. videoContext.play();
  380. setTimeout(() => {
  381. if (this.videoPlaying && this.$refs.videoPlayer) {
  382. console.log("视频应该正在播放");
  383. } else {
  384. console.log("视频可能未成功播放,尝试替代方案");
  385. this.tryAlternativeVideoPath();
  386. }
  387. }, 1e3);
  388. } else {
  389. console.error("无法创建视频上下文");
  390. this.tryAlternativeVideoPath();
  391. }
  392. });
  393. },
  394. // 修改 tryAlternativeVideoPath 方法
  395. tryAlternativeVideoPath() {
  396. console.log("尝试使用替代路径");
  397. const alternativePaths = [
  398. "./static/demo.mp4",
  399. "../static/demo.mp4",
  400. "static/demo.mp4",
  401. "/static/demo.mp4",
  402. // 添加绝对路径
  403. `${window.location.origin}/static/demo.mp4`
  404. ];
  405. const currentPathIndex = alternativePaths.indexOf(this.videoUrl);
  406. const nextPathIndex = (currentPathIndex + 1) % alternativePaths.length;
  407. this.videoUrl = alternativePaths[nextPathIndex];
  408. console.log("尝试新路径:", this.videoUrl);
  409. this.$nextTick(() => {
  410. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  411. if (videoContext) {
  412. videoContext.stop();
  413. videoContext.play();
  414. setTimeout(() => {
  415. if (nextPathIndex === alternativePaths.length - 1 && !this.videoPlaying) {
  416. console.log("所有路径均失败,尝试使用uni.getVideoInfo检查视频");
  417. this.checkVideoWithAPI();
  418. }
  419. }, 1e3);
  420. }
  421. });
  422. },
  423. // 添加新方法:使用uni API检查视频
  424. checkVideoWithAPI() {
  425. common_vendor.index.getVideoInfo({
  426. src: "/static/demo.mp4",
  427. success: (res) => {
  428. console.log("视频信息获取成功:", res);
  429. this.videoUrl = "/static/demo.mp4";
  430. this.$nextTick(() => {
  431. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  432. if (videoContext) {
  433. videoContext.play();
  434. }
  435. });
  436. },
  437. fail: (err) => {
  438. console.error("视频信息获取失败:", err);
  439. this.fallbackToLocalVideo();
  440. }
  441. });
  442. },
  443. // 添加新方法:回退到本地视频
  444. fallbackToLocalVideo() {
  445. console.log("尝试使用本地视频资源");
  446. const platform = common_vendor.index.getSystemInfoSync().platform;
  447. if (platform === "android" || platform === "ios") {
  448. this.videoUrl = platform === "android" ? "android.resource://package_name/raw/demo" : "file:///assets/demo.mp4";
  449. this.$nextTick(() => {
  450. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  451. if (videoContext) {
  452. videoContext.play();
  453. }
  454. });
  455. } else {
  456. this.videoPlaying = false;
  457. common_vendor.index.showToast({
  458. title: "视频加载失败,显示静态图片",
  459. icon: "none"
  460. });
  461. }
  462. },
  463. // 修改 handleVideoError 方法
  464. handleVideoError(e) {
  465. console.error("视频加载错误:", e);
  466. if (e && e.detail) {
  467. console.error("详细错误信息:", e.detail);
  468. }
  469. common_vendor.index.getFileInfo({
  470. filePath: this.videoUrl.startsWith("/") ? this.videoUrl.substring(1) : this.videoUrl,
  471. success: (res) => {
  472. console.log("文件存在,大小:", res.size);
  473. this.tryDifferentFormat();
  474. },
  475. fail: (err) => {
  476. console.error("文件不存在或无法访问:", err);
  477. this.tryAlternativeVideoPath();
  478. }
  479. });
  480. common_vendor.index.showToast({
  481. title: "视频加载失败,请检查文件是否存在",
  482. icon: "none",
  483. duration: 2e3
  484. });
  485. },
  486. // 添加新方法:尝试不同格式
  487. tryDifferentFormat() {
  488. console.log("尝试不同的视频格式");
  489. const formats = [
  490. { ext: "mp4", mime: "video/mp4" },
  491. { ext: "webm", mime: "video/webm" },
  492. { ext: "ogg", mime: "video/ogg" },
  493. { ext: "mov", mime: "video/quicktime" }
  494. ];
  495. const currentPath = this.videoUrl;
  496. const basePath = currentPath.substring(0, currentPath.lastIndexOf(".")) || "/static/demo";
  497. let nextFormat = formats.find((f) => !currentPath.endsWith(f.ext));
  498. if (nextFormat) {
  499. this.videoUrl = `${basePath}.${nextFormat.ext}`;
  500. console.log("尝试新格式:", this.videoUrl);
  501. this.$nextTick(() => {
  502. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  503. if (videoContext) {
  504. videoContext.stop();
  505. videoContext.play();
  506. }
  507. });
  508. } else {
  509. this.useBuiltInResource();
  510. }
  511. },
  512. // 添加新方法:使用内置资源
  513. useBuiltInResource() {
  514. console.log("尝试使用内置资源");
  515. const platform = common_vendor.index.getSystemInfoSync().platform;
  516. if (platform === "windows") {
  517. process.env.UNI_INPUT_DIR || "";
  518. this.videoUrl = `./static/demo.mp4`;
  519. console.log("Windows平台尝试路径:", this.videoUrl);
  520. } else if (platform === "android" || platform === "ios") {
  521. this.useNativeVideo();
  522. } else {
  523. const baseUrl = window.location.origin;
  524. this.videoUrl = `${baseUrl}/static/demo.mp4`;
  525. console.log("Web平台尝试URL:", this.videoUrl);
  526. }
  527. this.$nextTick(() => {
  528. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  529. if (videoContext) {
  530. videoContext.play();
  531. }
  532. });
  533. },
  534. // 添加新方法:使用原生视频能力
  535. useNativeVideo() {
  536. console.log("尝试使用原生视频能力");
  537. common_vendor.index.chooseVideo({
  538. sourceType: ["album"],
  539. success: (res) => {
  540. this.videoUrl = res.tempFilePath;
  541. this.$nextTick(() => {
  542. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  543. if (videoContext) {
  544. videoContext.play();
  545. }
  546. });
  547. },
  548. fail: () => {
  549. this.videoPlaying = false;
  550. common_vendor.index.showToast({
  551. title: "无法加载视频,显示静态图片",
  552. icon: "none"
  553. });
  554. }
  555. });
  556. },
  557. // 处理视频结束事件
  558. handleVideoEnded() {
  559. console.log("视频播放结束,当前视频索引:", this.currentVideoIndex);
  560. this.videoPlaying = false;
  561. this.showStartRecordingButton = true;
  562. this.startCountdown();
  563. this.showAnswerButton = false;
  564. },
  565. // 添加新方法:开始倒计时
  566. startCountdown() {
  567. this.showCountdown = true;
  568. this.countdownValue = 10;
  569. this.countdownTimer = setInterval(() => {
  570. this.countdownValue--;
  571. if (this.countdownValue <= 0) {
  572. this.clearCountdown();
  573. this.showStartRecordingButton = false;
  574. this.startRecordingAnswer();
  575. }
  576. }, 1e3);
  577. },
  578. // 添加新方法:清除倒计时
  579. clearCountdown() {
  580. if (this.countdownTimer) {
  581. clearInterval(this.countdownTimer);
  582. this.countdownTimer = null;
  583. }
  584. this.showCountdown = false;
  585. },
  586. // 修改 handleStartRecordingClick 方法,使其可以终止倒计时
  587. handleStartRecordingClick() {
  588. this.showStartRecordingButton = false;
  589. this.clearCountdown();
  590. this.startRecordingAnswer();
  591. },
  592. // 修改 stopRecordingAnswer 方法,确保清除倒计时
  593. stopRecordingAnswer() {
  594. this.clearCountdown();
  595. const recordingDuration = this.getRecordingDuration();
  596. const minimumDuration = 5;
  597. if (recordingDuration < minimumDuration) {
  598. common_vendor.index.showToast({
  599. title: "录制时间过短,请至少录制5秒",
  600. icon: "none",
  601. duration: 2e3
  602. });
  603. return;
  604. }
  605. this.completeRecordingStop();
  606. },
  607. // 添加新方法:开始录制用户回答
  608. startRecordingAnswer() {
  609. console.log("开始录制用户回答");
  610. this.isRecording = true;
  611. this.recordingStartTime = Date.now();
  612. this.recordingTimerCount = 0;
  613. this.remainingTime = this.maxRecordingTime;
  614. this.recordingTimer = setInterval(() => {
  615. this.recordingTimerCount++;
  616. this.remainingTime = Math.max(0, this.maxRecordingTime - this.recordingTimerCount);
  617. this.recordingTimeDisplay = this.formatTime(this.recordingTimerCount) + " / " + this.formatTime(this.maxRecordingTime);
  618. if (this.recordingTimerCount >= this.maxRecordingTime) {
  619. console.log("已达到最大录制时间(60秒),自动停止录制");
  620. this.stopRecordingAnswer();
  621. }
  622. }, 1e3);
  623. const systemInfo = common_vendor.index.getSystemInfoSync();
  624. const isMiniProgram = systemInfo.uniPlatform && systemInfo.uniPlatform.startsWith("mp-");
  625. if (isMiniProgram) {
  626. this.startMiniProgramRecording();
  627. } else {
  628. this.startBrowserRecording();
  629. }
  630. this.showStopRecordingButton = true;
  631. },
  632. // 添加一个新方法:重置相机组件
  633. resetCamera() {
  634. console.log("重置相机组件");
  635. this.useMiniProgramCameraComponent = false;
  636. if (this.cameraContext) {
  637. this.cameraContext = null;
  638. }
  639. setTimeout(() => {
  640. this.useMiniProgramCameraComponent = true;
  641. setTimeout(() => {
  642. this.cameraContext = common_vendor.index.createCameraContext();
  643. console.log("相机组件已重置");
  644. }, 500);
  645. }, 500);
  646. },
  647. // 修改 startMiniProgramRecording 方法
  648. startMiniProgramRecording() {
  649. console.log("开始小程序录制方法");
  650. const systemInfo = common_vendor.index.getSystemInfoSync();
  651. const isIOS = systemInfo.platform === "ios";
  652. if (isIOS) {
  653. this.resetCamera();
  654. setTimeout(() => {
  655. this.actualStartRecording(isIOS);
  656. }, 1e3);
  657. } else {
  658. this.actualStartRecording(isIOS);
  659. }
  660. },
  661. // 添加新方法:实际开始录制
  662. actualStartRecording(isIOS) {
  663. if (!this.cameraContext) {
  664. this.cameraContext = common_vendor.index.createCameraContext();
  665. console.log("创建新的相机上下文");
  666. }
  667. common_vendor.index.getSetting({
  668. success: (res) => {
  669. const hasRecordAuth = res.authSetting["scope.record"];
  670. const hasCameraAuth = res.authSetting["scope.camera"];
  671. if (!hasRecordAuth || !hasCameraAuth) {
  672. console.warn("缺少必要权限,请求权限");
  673. this.requestMiniProgramPermissions();
  674. return;
  675. }
  676. if (isIOS) {
  677. console.log("iOS: 检查相机状态");
  678. const options = {
  679. timeout: 3e5,
  680. // 300秒超时 (5分钟)
  681. quality: "low",
  682. // 降低质量
  683. compressed: true,
  684. success: () => {
  685. console.log("iOS录制开始成功");
  686. },
  687. fail: (err) => {
  688. console.error("iOS录制失败:", err);
  689. this.useAlternativeRecordingMethod();
  690. }
  691. };
  692. try {
  693. console.log("尝试开始录制");
  694. this.recorder = this.cameraContext.startRecord(options);
  695. } catch (e) {
  696. console.error("开始录制异常:", e);
  697. this.useAlternativeRecordingMethod();
  698. }
  699. } else {
  700. const options = {
  701. timeout: 3e5,
  702. // 300秒超时 (5分钟)
  703. quality: "medium",
  704. compressed: true,
  705. success: () => {
  706. console.log("Android录制开始成功");
  707. },
  708. fail: (err) => {
  709. console.error("Android录制失败:", err);
  710. common_vendor.index.showToast({
  711. title: "录制失败,请检查相机权限",
  712. icon: "none"
  713. });
  714. this.proceedToNextQuestion();
  715. }
  716. };
  717. this.recorder = this.cameraContext.startRecord(options);
  718. }
  719. }
  720. });
  721. },
  722. // 添加新方法:使用替代录制方法
  723. useAlternativeRecordingMethod() {
  724. console.log("使用替代录制方法");
  725. common_vendor.index.showActionSheet({
  726. itemList: ["使用相册中的视频", "跳过此问题"],
  727. success: (res) => {
  728. if (res.tapIndex === 0) {
  729. common_vendor.index.chooseVideo({
  730. sourceType: ["album"],
  731. maxDuration: 300,
  732. // 从60秒改为300秒
  733. camera: "front",
  734. success: (res2) => {
  735. console.log("选择视频成功:", res2.tempFilePath);
  736. this.isRecording = false;
  737. this.showStopRecordingButton = false;
  738. this.uploadRecordedVideo(res2.tempFilePath);
  739. },
  740. fail: () => {
  741. console.log("用户取消选择视频");
  742. this.proceedToNextQuestion();
  743. }
  744. });
  745. } else {
  746. console.log("用户选择跳过问题");
  747. this.proceedToNextQuestion();
  748. }
  749. },
  750. fail: () => {
  751. console.log("操作取消");
  752. this.proceedToNextQuestion();
  753. }
  754. });
  755. },
  756. // 添加新方法:请求小程序权限
  757. requestMiniProgramPermissions() {
  758. common_vendor.index.authorize({
  759. scope: "scope.record",
  760. success: () => {
  761. console.log("录音权限已获取");
  762. common_vendor.index.authorize({
  763. scope: "scope.camera",
  764. success: () => {
  765. console.log("相机权限已获取");
  766. this.startMiniProgramRecording();
  767. },
  768. fail: (err) => {
  769. console.error("相机权限获取失败:", err);
  770. this.showPermissionDialog("相机");
  771. }
  772. });
  773. },
  774. fail: (err) => {
  775. console.error("录音权限获取失败:", err);
  776. this.showPermissionDialog("录音");
  777. }
  778. });
  779. },
  780. // 修改浏览器环境下的录制方法
  781. startBrowserRecording() {
  782. if (!this.cameraStream) {
  783. console.error("没有可用的摄像头流");
  784. common_vendor.index.showToast({
  785. title: "录制失败,摄像头未就绪",
  786. icon: "none"
  787. });
  788. this.proceedToNextQuestion();
  789. return;
  790. }
  791. try {
  792. const hasAudio = this.cameraStream.getAudioTracks().length > 0;
  793. if (!hasAudio) {
  794. console.warn("警告:媒体流中没有音频轨道,尝试重新获取带音频的媒体流");
  795. navigator.mediaDevices.getUserMedia({
  796. audio: {
  797. echoCancellation: true,
  798. noiseSuppression: true,
  799. autoGainControl: true
  800. },
  801. video: true
  802. }).then((newStream) => {
  803. const audioTracks = newStream.getAudioTracks();
  804. if (audioTracks.length > 0) {
  805. console.log("成功获取音频轨道:", audioTracks[0].label);
  806. const videoTrack = this.cameraStream.getVideoTracks()[0];
  807. const audioTrack = newStream.getAudioTracks()[0];
  808. const combinedStream = new MediaStream();
  809. if (videoTrack)
  810. combinedStream.addTrack(videoTrack);
  811. if (audioTrack)
  812. combinedStream.addTrack(audioTrack);
  813. this.cameraStream = combinedStream;
  814. const videoElement = this.$refs.userCameraVideo;
  815. if (videoElement) {
  816. videoElement.srcObject = combinedStream;
  817. videoElement.muted = true;
  818. }
  819. this.setupMediaRecorder(combinedStream);
  820. } else {
  821. console.warn("仍然无法获取音频轨道");
  822. this.setupMediaRecorder(this.cameraStream);
  823. }
  824. }).catch((err) => {
  825. console.error("获取音频失败:", err);
  826. this.setupMediaRecorder(this.cameraStream);
  827. });
  828. } else {
  829. console.log("检测到音频轨道,直接使用");
  830. this.setupMediaRecorder(this.cameraStream);
  831. }
  832. } catch (error) {
  833. console.error("浏览器录制失败:", error);
  834. common_vendor.index.showToast({
  835. title: "录制失败,浏览器可能不支持此功能",
  836. icon: "none"
  837. });
  838. this.proceedToNextQuestion();
  839. }
  840. },
  841. // 修改 setupMediaRecorder 方法
  842. setupMediaRecorder(stream) {
  843. const videoTracks = stream.getVideoTracks();
  844. const audioTracks = stream.getAudioTracks();
  845. console.log("设置MediaRecorder - 视频轨道:", videoTracks.length, "音频轨道:", audioTracks.length);
  846. let mimeType = "";
  847. const supportedTypes = [
  848. "video/webm;codecs=vp9,opus",
  849. "video/webm;codecs=vp8,opus",
  850. "video/webm;codecs=h264,opus",
  851. "video/mp4;codecs=h264,aac",
  852. "video/webm",
  853. "video/mp4"
  854. ];
  855. for (const type of supportedTypes) {
  856. if (MediaRecorder.isTypeSupported(type)) {
  857. mimeType = type;
  858. console.log("使用支持的MIME类型:", mimeType);
  859. break;
  860. }
  861. }
  862. const options = {
  863. mimeType: mimeType || "",
  864. audioBitsPerSecond: 64e3,
  865. // 降低音频比特率
  866. videoBitsPerSecond: 1e6
  867. // 降低视频比特率到1Mbps
  868. };
  869. try {
  870. this.mediaRecorder = new MediaRecorder(stream, options);
  871. console.log("MediaRecorder创建成功,使用选项:", options);
  872. } catch (e) {
  873. console.warn("使用指定选项创建MediaRecorder失败,尝试使用默认选项");
  874. this.mediaRecorder = new MediaRecorder(stream);
  875. }
  876. this.recordedChunks = [];
  877. this.mediaRecorder.ondataavailable = (event) => {
  878. if (event.data && event.data.size > 0) {
  879. this.recordedChunks.push(event.data);
  880. console.log(`收到数据块: ${event.data.size} 字节`);
  881. }
  882. };
  883. this.mediaRecorder.onstop = async () => {
  884. console.log("MediaRecorder停止,数据块数量:", this.recordedChunks.length);
  885. if (this.recordedChunks.length === 0) {
  886. console.error("没有录制到数据");
  887. common_vendor.index.showToast({
  888. title: "录制失败,未捕获到数据",
  889. icon: "none"
  890. });
  891. this.proceedToNextQuestion();
  892. return;
  893. }
  894. const mimeType2 = this.mediaRecorder.mimeType || "video/webm";
  895. const blob = new Blob(this.recordedChunks, { type: mimeType2 });
  896. console.log("创建Blob,原始大小:", blob.size, "类型:", mimeType2);
  897. common_vendor.index.showLoading({
  898. title: "正在处理视频...",
  899. mask: true
  900. });
  901. try {
  902. const compressedBlob = await this.compressVideo(blob);
  903. const fileName = `answer_${this.currentVideoIndex}_${Date.now()}.webm`;
  904. const file = new File([compressedBlob], fileName, { type: mimeType2 });
  905. common_vendor.index.hideLoading();
  906. this.uploadRecordedVideo(file);
  907. } catch (error) {
  908. console.error("视频处理失败:", error);
  909. common_vendor.index.hideLoading();
  910. const fileName = `answer_${this.currentVideoIndex}_${Date.now()}.webm`;
  911. const file = new File([blob], fileName, { type: mimeType2 });
  912. this.uploadRecordedVideo(file);
  913. }
  914. };
  915. this.mediaRecorder.onerror = (event) => {
  916. console.error("MediaRecorder错误:", event.error);
  917. };
  918. try {
  919. this.mediaRecorder.start(1e3);
  920. console.log("MediaRecorder开始录制");
  921. this.mediaRecorderTimeout = setTimeout(() => {
  922. if (this.mediaRecorder && this.mediaRecorder.state === "recording") {
  923. console.log("MediaRecorder备份超时机制触发,停止录制");
  924. this.mediaRecorder.stop();
  925. }
  926. }, 3e5);
  927. } catch (e) {
  928. console.error("开始录制失败:", e);
  929. }
  930. },
  931. // 添加新方法:停止录制用户回答
  932. stopRecordingAnswer() {
  933. console.log("停止录制用户回答");
  934. if (this.countdownTimer) {
  935. clearInterval(this.countdownTimer);
  936. this.countdownTimer = null;
  937. this.showCountdown = false;
  938. }
  939. const recordingDuration = this.getRecordingDuration();
  940. const minimumDuration = 5;
  941. if (recordingDuration < minimumDuration) {
  942. common_vendor.index.showToast({
  943. title: "录制时间过短,请至少录制5秒",
  944. icon: "none",
  945. duration: 2e3
  946. });
  947. return;
  948. }
  949. this.completeRecordingStop();
  950. },
  951. // 添加新方法:获取录制时长
  952. getRecordingDuration() {
  953. if (this.recordingStartTime) {
  954. return (Date.now() - this.recordingStartTime) / 1e3;
  955. }
  956. if (this.mediaRecorder && this.$refs.userCameraVideo) {
  957. return this.$refs.userCameraVideo.currentTime || 0;
  958. }
  959. if (this.recordingTimerCount) {
  960. return this.recordingTimerCount;
  961. }
  962. return 0;
  963. },
  964. // 添加新方法:重置录制
  965. resetRecording() {
  966. if (this.recordingTimer) {
  967. clearTimeout(this.recordingTimer);
  968. }
  969. this.recordingStartTime = Date.now();
  970. this.recordingTimerCount = 0;
  971. if (this.mediaRecorder && this.mediaRecorder.state !== "inactive") {
  972. this.mediaRecorder.stop();
  973. this.recordedChunks = [];
  974. setTimeout(() => {
  975. this.startBrowserRecording();
  976. }, 500);
  977. } else if (this.cameraContext) {
  978. this.cameraContext.stopRecord({
  979. success: () => {
  980. console.log("重置录制:停止当前录制成功");
  981. setTimeout(() => {
  982. this.startMiniProgramRecording();
  983. }, 500);
  984. },
  985. fail: (err) => {
  986. console.error("重置录制:停止当前录制失败", err);
  987. this.startMiniProgramRecording();
  988. }
  989. });
  990. }
  991. common_vendor.index.showToast({
  992. title: "请重新开始回答",
  993. icon: "none",
  994. duration: 2e3
  995. });
  996. },
  997. // 添加新方法:完成录制停止流程
  998. completeRecordingStop() {
  999. this.isRecording = false;
  1000. if (this.recordingTimer) {
  1001. clearInterval(this.recordingTimer);
  1002. this.recordingTimer = null;
  1003. }
  1004. if (this.mediaRecorderTimeout) {
  1005. clearTimeout(this.mediaRecorderTimeout);
  1006. this.mediaRecorderTimeout = null;
  1007. }
  1008. common_vendor.index.hideLoading();
  1009. this.showStopRecordingButton = false;
  1010. const systemInfo = common_vendor.index.getSystemInfoSync();
  1011. const isMiniProgram = systemInfo.uniPlatform && systemInfo.uniPlatform.startsWith("mp-");
  1012. if (isMiniProgram) {
  1013. this.stopMiniProgramRecording();
  1014. } else {
  1015. this.stopBrowserRecording();
  1016. }
  1017. },
  1018. // 修改 stopMiniProgramRecording 方法
  1019. stopMiniProgramRecording() {
  1020. if (!this.cameraContext) {
  1021. console.error("相机上下文不存在");
  1022. this.proceedToNextQuestion();
  1023. return;
  1024. }
  1025. const systemInfo = common_vendor.index.getSystemInfoSync();
  1026. const isIOS = systemInfo.platform === "ios";
  1027. const stopOptions = {
  1028. success: (res) => {
  1029. console.log("小程序录像停止成功:", res);
  1030. const tempFilePath = res.tempVideoPath;
  1031. if (!tempFilePath) {
  1032. console.error("未获取到视频文件路径");
  1033. common_vendor.index.showToast({
  1034. title: "录制失败,未获取到视频文件",
  1035. icon: "none"
  1036. });
  1037. this.proceedToNextQuestion();
  1038. return;
  1039. }
  1040. if (isIOS) {
  1041. common_vendor.index.getFileInfo({
  1042. filePath: tempFilePath,
  1043. success: () => {
  1044. this.uploadRecordedVideo(tempFilePath);
  1045. },
  1046. fail: (err) => {
  1047. console.error("视频文件不存在:", err);
  1048. common_vendor.index.showToast({
  1049. title: "录制失败,视频文件不存在",
  1050. icon: "none"
  1051. });
  1052. this.proceedToNextQuestion();
  1053. }
  1054. });
  1055. } else {
  1056. this.uploadRecordedVideo(tempFilePath);
  1057. }
  1058. },
  1059. fail: (err) => {
  1060. console.error("小程序录像停止失败:", err);
  1061. common_vendor.index.showToast({
  1062. title: "录制失败",
  1063. icon: "none"
  1064. });
  1065. this.proceedToNextQuestion();
  1066. }
  1067. };
  1068. this.cameraContext.stopRecord(stopOptions);
  1069. },
  1070. // 添加新方法:停止浏览器录制
  1071. stopBrowserRecording() {
  1072. if (this.mediaRecorder && this.mediaRecorder.state !== "inactive") {
  1073. this.mediaRecorder.stop();
  1074. console.log("浏览器录制停止成功");
  1075. } else {
  1076. console.error("MediaRecorder不存在或已经停止");
  1077. this.proceedToNextQuestion();
  1078. }
  1079. },
  1080. // 修改上传录制的视频方法
  1081. uploadRecordedVideo(fileOrPath) {
  1082. console.log("准备上传视频:", typeof fileOrPath === "string" ? fileOrPath : fileOrPath.name);
  1083. let questionId = 10;
  1084. const uploadTask = {
  1085. id: Date.now().toString(),
  1086. // 生成唯一ID
  1087. file: fileOrPath,
  1088. questionId,
  1089. attempts: 0,
  1090. // 上传尝试次数
  1091. maxAttempts: 3
  1092. // 最大尝试次数
  1093. };
  1094. this.uploadQueue.push(uploadTask);
  1095. this.uploadProgress[uploadTask.id] = 0;
  1096. this.uploadStatus[uploadTask.id] = "pending";
  1097. common_vendor.index.showToast({
  1098. title: "已完成回答",
  1099. icon: "none",
  1100. duration: 1500
  1101. });
  1102. this.updateUploadStatusText();
  1103. if (!this.isUploading) {
  1104. this.processUploadQueue();
  1105. }
  1106. this.proceedToNextQuestion();
  1107. },
  1108. // 修改 processUploadQueue 方法,添加后台上传支持
  1109. processUploadQueue() {
  1110. if (this.uploadQueue.length === 0) {
  1111. this.isUploading = false;
  1112. this.showUploadStatus = false;
  1113. try {
  1114. common_vendor.index.removeStorageSync("videoUploadStatus");
  1115. } catch (e) {
  1116. console.error("清除上传状态失败:", e);
  1117. }
  1118. this.notifyUploadComplete();
  1119. return;
  1120. }
  1121. this.isUploading = true;
  1122. this.showUploadStatus = true;
  1123. const task = this.uploadQueue[0];
  1124. this.uploadStatus[task.id] = "uploading";
  1125. this.updateUploadStatusText();
  1126. task.attempts++;
  1127. if (typeof task.file !== "string") {
  1128. this.uploadFileWithXHR(task);
  1129. } else {
  1130. this.uploadFileWithUni(task);
  1131. }
  1132. this.saveUploadStatus();
  1133. },
  1134. // 添加新方法:发送上传完成通知
  1135. notifyUploadComplete() {
  1136. try {
  1137. common_vendor.index.$emit("videoUploadComplete", {
  1138. timestamp: Date.now()
  1139. });
  1140. console.log("发送上传完成通知");
  1141. } catch (e) {
  1142. console.error("发送上传完成通知失败:", e);
  1143. }
  1144. const systemInfo = common_vendor.index.getSystemInfoSync();
  1145. if (systemInfo.platform === "android" || systemInfo.platform === "ios") {
  1146. if (plus && plus.push) {
  1147. plus.push.createMessage("视频上传完成", "您的面试视频已成功上传", {});
  1148. }
  1149. }
  1150. },
  1151. // 添加新方法:使用XMLHttpRequest上传文件
  1152. uploadFileWithXHR(task) {
  1153. const userInfo = common_vendor.index.getStorageSync("userInfo");
  1154. const openid = userInfo ? JSON.parse(userInfo).openid || "" : "";
  1155. const tenant_id = common_vendor.index.getStorageSync("tenant_id") || "1";
  1156. const formData = new FormData();
  1157. formData.append("file", task.file);
  1158. formData.append("openid", openid);
  1159. formData.append("tenant_id", tenant_id);
  1160. formData.append("application_id", common_vendor.index.getStorageSync("appId"));
  1161. formData.append("question_id", task.questionId);
  1162. formData.append("video_duration", 0);
  1163. formData.append("has_audio", "true");
  1164. const xhr = new XMLHttpRequest();
  1165. xhr.open("POST", `${common_config.apiBaseUrl}/api/upload/`, true);
  1166. xhr.timeout = 12e4;
  1167. xhr.upload.onprogress = (event) => {
  1168. if (event.lengthComputable) {
  1169. const percentComplete = Math.round(event.loaded / event.total * 100);
  1170. this.uploadProgress[task.id] = percentComplete;
  1171. this.updateUploadStatusText();
  1172. }
  1173. };
  1174. xhr.onload = () => {
  1175. if (xhr.status === 200) {
  1176. try {
  1177. const res = JSON.parse(xhr.responseText);
  1178. console.log("上传响应:", res);
  1179. if (res.code === 2e3) {
  1180. const videoUrl = res.data.url || res.data.photoUrl || "";
  1181. if (videoUrl) {
  1182. this.uploadStatus[task.id] = "success";
  1183. this.updateUploadStatusText();
  1184. this.submitVideoToInterview(videoUrl, task);
  1185. } else {
  1186. this.handleUploadFailure(task, "视频URL获取失败");
  1187. }
  1188. } else {
  1189. this.handleUploadFailure(task, res.msg || "上传失败");
  1190. }
  1191. } catch (e) {
  1192. this.handleUploadFailure(task, "解析响应失败");
  1193. }
  1194. } else {
  1195. this.handleUploadFailure(task, "HTTP状态: " + xhr.status);
  1196. }
  1197. };
  1198. xhr.onerror = () => {
  1199. this.handleUploadFailure(task, "网络错误");
  1200. };
  1201. xhr.ontimeout = () => {
  1202. this.handleUploadFailure(task, "上传超时");
  1203. };
  1204. xhr.send(formData);
  1205. },
  1206. // 添加新方法:使用uni.uploadFile上传文件
  1207. uploadFileWithUni(task) {
  1208. const userInfo = common_vendor.index.getStorageSync("userInfo");
  1209. const openid = userInfo ? JSON.parse(userInfo).openid || "" : "";
  1210. const tenant_id = common_vendor.index.getStorageSync("tenant_id") || "1";
  1211. const uploadTask = common_vendor.index.uploadFile({
  1212. url: `${common_config.apiBaseUrl}/api/upload/`,
  1213. filePath: task.file,
  1214. name: "file",
  1215. formData: {
  1216. openid,
  1217. tenant_id,
  1218. application_id: common_vendor.index.getStorageSync("appId"),
  1219. question_id: task.questionId,
  1220. video_duration: 0,
  1221. has_audio: "true"
  1222. },
  1223. success: (uploadRes) => {
  1224. try {
  1225. const res = JSON.parse(uploadRes.data);
  1226. console.log("上传响应:", res);
  1227. if (res.code === 2e3) {
  1228. const videoUrl = res.data.permanent_link || res.data.url || "";
  1229. if (videoUrl) {
  1230. this.uploadStatus[task.id] = "success";
  1231. this.updateUploadStatusText();
  1232. this.submitVideoToInterview(videoUrl, task);
  1233. } else {
  1234. this.handleUploadFailure(task, "视频URL获取失败");
  1235. }
  1236. } else {
  1237. this.handleUploadFailure(task, res.msg || "上传失败");
  1238. }
  1239. } catch (e) {
  1240. this.handleUploadFailure(task, "解析响应失败");
  1241. }
  1242. },
  1243. fail: (err) => {
  1244. this.handleUploadFailure(task, err.errMsg || "上传失败");
  1245. }
  1246. });
  1247. uploadTask.onProgressUpdate((res) => {
  1248. this.uploadProgress[task.id] = res.progress;
  1249. this.updateUploadStatusText();
  1250. });
  1251. },
  1252. // 添加新方法:处理上传失败
  1253. handleUploadFailure(task, errorMsg) {
  1254. console.error("上传失败:", errorMsg);
  1255. this.uploadStatus[task.id] = "failed";
  1256. this.updateUploadStatusText();
  1257. if (task.attempts < task.maxAttempts) {
  1258. console.log(`将在5秒后重试上传,当前尝试次数: ${task.attempts}/${task.maxAttempts}`);
  1259. setTimeout(() => {
  1260. this.uploadProgress[task.id] = 0;
  1261. if (typeof task.file !== "string") {
  1262. this.uploadFileWithXHR(task);
  1263. } else {
  1264. this.uploadFileWithUni(task);
  1265. }
  1266. }, 5e3);
  1267. } else {
  1268. console.log("超过最大重试次数,放弃上传");
  1269. common_vendor.index.showToast({
  1270. title: "视频上传失败,请稍后重试",
  1271. icon: "none",
  1272. duration: 2e3
  1273. });
  1274. this.uploadQueue.shift();
  1275. this.processUploadQueue();
  1276. }
  1277. },
  1278. // 修改 submitVideoToInterview 方法
  1279. submitVideoToInterview(videoUrl, task = null) {
  1280. console.log("提交视频URL到面试接口:", videoUrl);
  1281. let questionId;
  1282. if (task) {
  1283. questionId = task.questionId;
  1284. } else {
  1285. switch (this.currentVideoIndex) {
  1286. case 1:
  1287. questionId = 36;
  1288. break;
  1289. case 2:
  1290. questionId = 11;
  1291. break;
  1292. case 3:
  1293. questionId = 12;
  1294. break;
  1295. case 4:
  1296. questionId = 13;
  1297. break;
  1298. default:
  1299. questionId = 10;
  1300. }
  1301. }
  1302. const requestData = {
  1303. application_id: common_vendor.index.getStorageSync("appId"),
  1304. question_id: questionId,
  1305. video_url: videoUrl,
  1306. tenant_id: common_vendor.index.getStorageSync("tenant_id") || "1"
  1307. };
  1308. common_vendor.index.request({
  1309. url: `${common_config.apiBaseUrl}/api/job/upload_video`,
  1310. method: "POST",
  1311. data: requestData,
  1312. header: {
  1313. "content-type": "application/x-www-form-urlencoded"
  1314. },
  1315. success: (res) => {
  1316. console.log("面试接口提交成功:", res);
  1317. if (res.data.code === 0 || res.data.code === 2e3) {
  1318. if (task) {
  1319. this.uploadQueue.shift();
  1320. this.processUploadQueue();
  1321. } else {
  1322. common_vendor.index.showToast({
  1323. title: "回答已提交",
  1324. icon: "success"
  1325. });
  1326. this.lastUploadedVideoUrl = videoUrl;
  1327. this.showRetryButton = false;
  1328. this.lastVideoToRetry = null;
  1329. }
  1330. } else {
  1331. if (task) {
  1332. this.handleSubmitFailure(task, res.data.msg || "提交失败");
  1333. } else {
  1334. common_vendor.index.showToast({
  1335. title: res.data.msg || "提交失败,请重试",
  1336. icon: "none"
  1337. });
  1338. this.lastVideoToRetry = videoUrl;
  1339. this.showRetryButton = true;
  1340. }
  1341. }
  1342. },
  1343. fail: (err) => {
  1344. console.error("面试接口提交失败:", err);
  1345. if (task) {
  1346. this.handleSubmitFailure(task, err.errMsg || "网络错误");
  1347. } else {
  1348. common_vendor.index.hideLoading();
  1349. common_vendor.index.showToast({
  1350. title: "网络错误,请重试",
  1351. icon: "none"
  1352. });
  1353. this.lastVideoToRetry = videoUrl;
  1354. this.showRetryButton = true;
  1355. }
  1356. }
  1357. });
  1358. },
  1359. // 添加新方法:处理提交失败
  1360. handleSubmitFailure(task, errorMsg) {
  1361. console.error("提交失败:", errorMsg);
  1362. this.uploadStatus[task.id] = "failed";
  1363. this.updateUploadStatusText();
  1364. if (task.attempts < task.maxAttempts) {
  1365. console.log(`将在5秒后重试提交,当前尝试次数: ${task.attempts}/${task.maxAttempts}`);
  1366. setTimeout(() => {
  1367. this.submitVideoToInterview(task.videoUrl, task);
  1368. }, 5e3);
  1369. } else {
  1370. console.log("超过最大重试次数,放弃提交");
  1371. common_vendor.index.showToast({
  1372. title: "视频提交失败,请稍后重试",
  1373. icon: "none",
  1374. duration: 2e3
  1375. });
  1376. this.uploadQueue.shift();
  1377. this.processUploadQueue();
  1378. }
  1379. },
  1380. // 添加新方法:更新上传状态文本
  1381. updateUploadStatusText() {
  1382. if (this.uploadQueue.length === 0) {
  1383. this.uploadStatusText = "";
  1384. return;
  1385. }
  1386. const currentTask = this.uploadQueue[0];
  1387. const progress = this.uploadProgress[currentTask.id] || 0;
  1388. const status = this.uploadStatus[currentTask.id] || "pending";
  1389. let statusText = "";
  1390. switch (status) {
  1391. case "pending":
  1392. statusText = "等待上传";
  1393. break;
  1394. case "uploading":
  1395. statusText = `上传中 ${progress}%`;
  1396. break;
  1397. case "success":
  1398. statusText = "上传成功,提交中...";
  1399. break;
  1400. case "failed":
  1401. statusText = `上传失败,${currentTask.attempts < currentTask.maxAttempts ? "即将重试" : "已放弃"}`;
  1402. break;
  1403. }
  1404. this.uploadStatusText = `问题${currentTask.questionId - 9}:${statusText}`;
  1405. if (this.uploadQueue.length > 1) {
  1406. this.uploadStatusText += ` (${this.uploadQueue.length}个视频待处理)`;
  1407. }
  1408. },
  1409. // 修改 proceedToNextQuestion 方法
  1410. proceedToNextQuestion() {
  1411. console.log("准备跳转到下一页面");
  1412. this.navigateToNextPage();
  1413. if (this.uploadQueue.length > 0) {
  1414. console.log("上传队列将在后台继续处理...");
  1415. this.saveUploadStatus();
  1416. }
  1417. },
  1418. // 修改 navigateToNextPage 方法
  1419. navigateToNextPage() {
  1420. console.log("导航到下一个页面");
  1421. common_vendor.index.navigateTo({
  1422. url: "/pages/interview-result/interview-result?uploading=" + (this.uploadQueue.length > 0 ? "true" : "false"),
  1423. success: () => {
  1424. console.log("成功跳转到结果页面");
  1425. },
  1426. fail: (err) => {
  1427. console.error("跳转失败:", err);
  1428. common_vendor.index.navigateTo({
  1429. url: "/pages/interview/interview",
  1430. fail: (err2) => {
  1431. console.error("备用跳转也失败:", err2);
  1432. common_vendor.index.navigateBack({
  1433. delta: 1
  1434. });
  1435. }
  1436. });
  1437. }
  1438. });
  1439. },
  1440. // 修改 handleAnswerButtonClick 方法
  1441. handleAnswerButtonClick() {
  1442. this.showAnswerButton = false;
  1443. common_vendor.index.showToast({
  1444. title: "面试完成",
  1445. icon: "success",
  1446. duration: 500
  1447. // 只显示0.5秒
  1448. });
  1449. setTimeout(() => {
  1450. this.navigateToNextPage();
  1451. }, 500);
  1452. },
  1453. // 处理相机错误
  1454. handleCameraError(e) {
  1455. console.error("相机错误:", e);
  1456. const systemInfo = common_vendor.index.getSystemInfoSync();
  1457. const isIOS = systemInfo.platform === "ios";
  1458. if (isIOS) {
  1459. console.log("iOS相机错误,尝试重新初始化");
  1460. common_vendor.index.showToast({
  1461. title: "相机初始化中...",
  1462. icon: "loading",
  1463. duration: 2e3
  1464. });
  1465. this.resetCamera();
  1466. if (this.isRecording) {
  1467. this.isRecording = false;
  1468. this.showStopRecordingButton = false;
  1469. setTimeout(() => {
  1470. this.useAlternativeRecordingMethod();
  1471. }, 1e3);
  1472. }
  1473. } else {
  1474. common_vendor.index.showToast({
  1475. title: "相机初始化失败,请检查权限设置",
  1476. icon: "none"
  1477. });
  1478. this.tryFallbackOptions();
  1479. }
  1480. },
  1481. // 添加新方法:尝试备用选项
  1482. tryFallbackOptions() {
  1483. const systemInfo = common_vendor.index.getSystemInfoSync();
  1484. if (systemInfo.uniPlatform === "mp-weixin" || systemInfo.uniPlatform === "mp-alipay") {
  1485. this.useMiniProgramCamera();
  1486. } else {
  1487. this.showStaticCameraPlaceholder();
  1488. }
  1489. },
  1490. // 添加新方法:使用小程序相机API
  1491. useMiniProgramCamera() {
  1492. console.log("尝试使用小程序相机组件");
  1493. this.useMiniProgramCameraComponent = true;
  1494. },
  1495. // 添加新方法:显示静态图像
  1496. showStaticCameraPlaceholder() {
  1497. console.log("显示静态摄像头占位图");
  1498. const img = document.createElement("img");
  1499. img.src = "/static/images/camera-placeholder.png";
  1500. img.className = "static-camera-image";
  1501. img.style.width = "100%";
  1502. img.style.height = "100%";
  1503. img.style.objectFit = "cover";
  1504. const container = this.$refs.userCameraVideo.parentNode;
  1505. container.appendChild(img);
  1506. },
  1507. // 处理视频时间更新事件
  1508. handleTimeUpdate(e) {
  1509. const currentTime = e.target.currentTime;
  1510. if (this.isRecording && this.recordingTimerCount) {
  1511. this.recordingTimeDisplay = this.formatTime(this.recordingTimerCount);
  1512. }
  1513. let currentSubtitles;
  1514. if (this.currentVideoIndex === 0) {
  1515. currentSubtitles = this.subtitles;
  1516. } else if (this.currentVideoIndex === 1) {
  1517. currentSubtitles = this.secondVideoSubtitles;
  1518. } else if (this.currentVideoIndex === 2) {
  1519. currentSubtitles = this.thirdVideoSubtitles;
  1520. } else if (this.currentVideoIndex === 3) {
  1521. currentSubtitles = this.fourthVideoSubtitles;
  1522. } else if (this.currentVideoIndex === 4) {
  1523. currentSubtitles = this.fifthVideoSubtitles;
  1524. } else if (this.currentVideoIndex === 5) {
  1525. currentSubtitles = this.sixthVideoSubtitles;
  1526. } else {
  1527. currentSubtitles = [];
  1528. }
  1529. const subtitle = currentSubtitles.find(
  1530. (sub) => currentTime >= sub.startTime && currentTime < sub.endTime
  1531. );
  1532. this.currentSubtitle = subtitle ? subtitle.text : "";
  1533. },
  1534. // Add a new method to handle the "Start Recording" button click
  1535. handleStartRecordingClick() {
  1536. this.showStartRecordingButton = false;
  1537. this.clearCountdown();
  1538. this.startRecordingAnswer();
  1539. },
  1540. // 修改 checkAudioPermission 方法,确保在录制前获取音频权限
  1541. checkAudioPermission() {
  1542. const systemInfo = common_vendor.index.getSystemInfoSync();
  1543. const isMiniProgram = systemInfo.uniPlatform && systemInfo.uniPlatform.startsWith("mp-");
  1544. if (isMiniProgram) {
  1545. common_vendor.index.getSetting({
  1546. success: (res) => {
  1547. if (!res.authSetting["scope.record"]) {
  1548. common_vendor.index.authorize({
  1549. scope: "scope.record",
  1550. success: () => {
  1551. console.log("录音权限已获取");
  1552. },
  1553. fail: (err) => {
  1554. console.error("录音权限获取失败:", err);
  1555. this.showPermissionDialog("录音");
  1556. }
  1557. });
  1558. }
  1559. if (!res.authSetting["scope.camera"]) {
  1560. common_vendor.index.authorize({
  1561. scope: "scope.camera",
  1562. success: () => {
  1563. console.log("相机权限已获取");
  1564. },
  1565. fail: (err) => {
  1566. console.error("相机权限获取失败:", err);
  1567. this.showPermissionDialog("相机");
  1568. }
  1569. });
  1570. }
  1571. }
  1572. });
  1573. }
  1574. },
  1575. // 添加新方法:测试音频输入
  1576. testAudioInput() {
  1577. if (!this.cameraStream) {
  1578. console.warn("没有可用的媒体流,无法测试音频");
  1579. return;
  1580. }
  1581. const audioTracks = this.cameraStream.getAudioTracks();
  1582. if (audioTracks.length === 0) {
  1583. console.warn("没有检测到音频轨道,尝试重新获取");
  1584. this.tryGetAudioOnly();
  1585. return;
  1586. }
  1587. console.log("音频轨道信息:", audioTracks[0].getSettings());
  1588. try {
  1589. const AudioContext = window.AudioContext || window.webkitAudioContext;
  1590. if (!AudioContext) {
  1591. console.warn("浏览器不支持AudioContext");
  1592. return;
  1593. }
  1594. const audioContext = new AudioContext();
  1595. const analyser = audioContext.createAnalyser();
  1596. const microphone = audioContext.createMediaStreamSource(this.cameraStream);
  1597. microphone.connect(analyser);
  1598. analyser.fftSize = 256;
  1599. const bufferLength = analyser.frequencyBinCount;
  1600. const dataArray = new Uint8Array(bufferLength);
  1601. let silenceCounter = 0;
  1602. const checkAudio = () => {
  1603. if (this.isRecording)
  1604. return;
  1605. analyser.getByteFrequencyData(dataArray);
  1606. let sum = 0;
  1607. for (let i = 0; i < bufferLength; i++) {
  1608. sum += dataArray[i];
  1609. }
  1610. const average = sum / bufferLength;
  1611. if (average > 10) {
  1612. console.log("检测到音频输入,音量:", average);
  1613. silenceCounter = 0;
  1614. } else {
  1615. silenceCounter++;
  1616. if (silenceCounter > 10) {
  1617. console.warn("持续检测不到音频输入,可能麦克风未正常工作");
  1618. silenceCounter = 0;
  1619. }
  1620. }
  1621. requestAnimationFrame(checkAudio);
  1622. };
  1623. checkAudio();
  1624. } catch (e) {
  1625. console.error("音频测试失败:", e);
  1626. }
  1627. },
  1628. // 添加新方法:尝试单独获取音频
  1629. tryGetAudioOnly() {
  1630. navigator.mediaDevices.getUserMedia({ audio: true }).then((audioStream) => {
  1631. if (this.cameraStream) {
  1632. const videoTrack = this.cameraStream.getVideoTracks()[0];
  1633. const audioTrack = audioStream.getAudioTracks()[0];
  1634. const combinedStream = new MediaStream();
  1635. if (videoTrack)
  1636. combinedStream.addTrack(videoTrack);
  1637. if (audioTrack)
  1638. combinedStream.addTrack(audioTrack);
  1639. this.cameraStream = combinedStream;
  1640. const videoElement = this.$refs.userCameraVideo;
  1641. if (videoElement) {
  1642. videoElement.srcObject = combinedStream;
  1643. videoElement.muted = true;
  1644. }
  1645. console.log("成功合并音频和视频轨道");
  1646. } else {
  1647. console.warn("没有视频流可合并");
  1648. }
  1649. }).catch((err) => {
  1650. console.error("单独获取音频失败:", err);
  1651. });
  1652. },
  1653. // 添加新方法:显示权限对话框
  1654. showPermissionDialog(permissionType) {
  1655. common_vendor.index.showModal({
  1656. title: "需要权限",
  1657. content: `请允许使用${permissionType}权限,否则可能影响面试功能`,
  1658. confirmText: "去设置",
  1659. success: (res) => {
  1660. if (res.confirm) {
  1661. common_vendor.index.openSetting({
  1662. success: (settingRes) => {
  1663. console.log("设置页面打开成功", settingRes);
  1664. }
  1665. });
  1666. }
  1667. }
  1668. });
  1669. },
  1670. // 添加重试上传方法
  1671. retryVideoUpload() {
  1672. if (this.lastVideoToRetry) {
  1673. this.showRetryButton = false;
  1674. common_vendor.index.showLoading({
  1675. title: "正在重新提交...",
  1676. mask: true
  1677. });
  1678. this.submitVideoToInterview(this.lastVideoToRetry);
  1679. } else {
  1680. common_vendor.index.showToast({
  1681. title: "没有可重试的视频",
  1682. icon: "none"
  1683. });
  1684. }
  1685. },
  1686. // 添加一个新方法用于压缩视频
  1687. async compressVideo(videoBlob) {
  1688. if (videoBlob.size < 5 * 1024 * 1024) {
  1689. return videoBlob;
  1690. }
  1691. console.log("开始压缩视频,原始大小:", videoBlob.size);
  1692. const videoElement = document.createElement("video");
  1693. videoElement.muted = true;
  1694. videoElement.autoplay = false;
  1695. const canvas = document.createElement("canvas");
  1696. const ctx = canvas.getContext("2d");
  1697. videoElement.src = URL.createObjectURL(videoBlob);
  1698. return new Promise((resolve) => {
  1699. videoElement.onloadedmetadata = () => {
  1700. const width = Math.floor(videoElement.videoWidth / 2);
  1701. const height = Math.floor(videoElement.videoHeight / 2);
  1702. canvas.width = width;
  1703. canvas.height = height;
  1704. const stream = canvas.captureStream(15);
  1705. if (videoElement.captureStream) {
  1706. const originalStream = videoElement.captureStream();
  1707. const audioTracks = originalStream.getAudioTracks();
  1708. if (audioTracks.length > 0) {
  1709. stream.addTrack(audioTracks[0]);
  1710. }
  1711. }
  1712. const options = {
  1713. mimeType: "video/webm;codecs=vp8,opus",
  1714. audioBitsPerSecond: 64e3,
  1715. videoBitsPerSecond: 8e5
  1716. // 800kbps
  1717. };
  1718. const mediaRecorder = new MediaRecorder(stream, options);
  1719. const chunks = [];
  1720. mediaRecorder.ondataavailable = (e) => {
  1721. if (e.data.size > 0) {
  1722. chunks.push(e.data);
  1723. }
  1724. };
  1725. mediaRecorder.onstop = () => {
  1726. const compressedBlob = new Blob(chunks, { type: "video/webm" });
  1727. console.log("视频压缩完成,压缩后大小:", compressedBlob.size);
  1728. resolve(compressedBlob);
  1729. };
  1730. videoElement.onplay = () => {
  1731. mediaRecorder.start(100);
  1732. const drawFrame = () => {
  1733. if (videoElement.paused || videoElement.ended) {
  1734. mediaRecorder.stop();
  1735. return;
  1736. }
  1737. ctx.drawImage(videoElement, 0, 0, width, height);
  1738. requestAnimationFrame(drawFrame);
  1739. };
  1740. drawFrame();
  1741. };
  1742. videoElement.play();
  1743. };
  1744. });
  1745. },
  1746. // 修改 checkIOSCameraRecordPermission 方法
  1747. checkIOSCameraRecordPermission() {
  1748. const systemInfo = common_vendor.index.getSystemInfoSync();
  1749. if (systemInfo.platform !== "ios")
  1750. return;
  1751. common_vendor.index.getSetting({
  1752. success: (res) => {
  1753. if (!res.authSetting["scope.camera"]) {
  1754. common_vendor.index.authorize({
  1755. scope: "scope.camera",
  1756. success: () => {
  1757. console.log("iOS相机权限已获取");
  1758. },
  1759. fail: (err) => {
  1760. console.error("iOS相机权限获取失败:", err);
  1761. this.showPermissionDialog("相机");
  1762. }
  1763. });
  1764. }
  1765. if (!res.authSetting["scope.record"]) {
  1766. common_vendor.index.authorize({
  1767. scope: "scope.record",
  1768. success: () => {
  1769. console.log("iOS录音权限已获取");
  1770. },
  1771. fail: (err) => {
  1772. console.error("iOS录音权限获取失败:", err);
  1773. this.showPermissionDialog("录音");
  1774. }
  1775. });
  1776. }
  1777. }
  1778. });
  1779. },
  1780. // 添加新方法:检查并修复渲染问题
  1781. checkAndFixRenderingIssues() {
  1782. try {
  1783. if (typeof u !== "undefined" && u) {
  1784. if (!u.currentQuestion) {
  1785. console.log("修复: 创建缺失的currentQuestion对象");
  1786. u.currentQuestion = {};
  1787. }
  1788. if (u.currentQuestion && typeof u.currentQuestion.isImportant === "undefined") {
  1789. console.log("修复: 设置缺失的isImportant属性");
  1790. u.currentQuestion.isImportant = false;
  1791. }
  1792. }
  1793. } catch (e) {
  1794. console.log("防御性检查异常:", e);
  1795. }
  1796. },
  1797. // 添加格式化时间的辅助方法
  1798. formatTime(seconds) {
  1799. if (!seconds && seconds !== 0)
  1800. return "03:30";
  1801. const minutes = Math.floor(seconds / 60);
  1802. const remainingSeconds = seconds % 60;
  1803. return `${minutes.toString().padStart(2, "0")}:${remainingSeconds.toString().padStart(2, "0")}`;
  1804. },
  1805. // 添加新方法:保存上传状态到本地存储
  1806. saveUploadStatus() {
  1807. const uploadStatus = {
  1808. isUploading: this.isUploading,
  1809. uploadQueue: this.uploadQueue.length,
  1810. timestamp: Date.now()
  1811. };
  1812. try {
  1813. common_vendor.index.setStorageSync("videoUploadStatus", JSON.stringify(uploadStatus));
  1814. } catch (e) {
  1815. console.error("保存上传状态失败:", e);
  1816. }
  1817. }
  1818. }
  1819. };
  1820. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  1821. return common_vendor.e({
  1822. a: $data.videoUrl,
  1823. b: common_vendor.o((...args) => $options.handleVideoError && $options.handleVideoError(...args)),
  1824. c: common_vendor.o((...args) => $options.handleVideoEnded && $options.handleVideoEnded(...args)),
  1825. d: common_vendor.o((...args) => $options.handleTimeUpdate && $options.handleTimeUpdate(...args)),
  1826. e: $data.showAnswerButton
  1827. }, $data.showAnswerButton ? {
  1828. f: common_vendor.o((...args) => $options.handleAnswerButtonClick && $options.handleAnswerButtonClick(...args))
  1829. } : {}, {
  1830. g: $data.currentSubtitle
  1831. }, $data.currentSubtitle ? {
  1832. h: common_vendor.t($data.currentSubtitle)
  1833. } : {}, {
  1834. i: $data.useMiniProgramCameraComponent
  1835. }, $data.useMiniProgramCameraComponent ? {
  1836. j: common_vendor.o((...args) => $options.handleCameraError && $options.handleCameraError(...args))
  1837. } : {}, {
  1838. k: $data.loading
  1839. }, $data.loading ? {} : {}, {
  1840. l: $data.showDebugInfo
  1841. }, $data.showDebugInfo ? common_vendor.e({
  1842. m: $data.assistantResponse
  1843. }, $data.assistantResponse ? {
  1844. n: common_vendor.t($data.assistantResponse)
  1845. } : {}, {
  1846. o: $data.audioTranscript
  1847. }, $data.audioTranscript ? {
  1848. p: common_vendor.t($data.audioTranscript)
  1849. } : {}, {
  1850. q: common_vendor.f($data.processedResponses, (item, index, i0) => {
  1851. return common_vendor.e({
  1852. a: item.role
  1853. }, item.role ? {
  1854. b: common_vendor.t(item.role)
  1855. } : {}, {
  1856. c: item.transcript
  1857. }, item.transcript ? {
  1858. d: common_vendor.t(item.transcript)
  1859. } : {}, {
  1860. e: index
  1861. });
  1862. })
  1863. }) : {}, {
  1864. r: $data.showStopRecordingButton
  1865. }, $data.showStopRecordingButton ? {
  1866. s: common_vendor.o((...args) => $options.stopRecordingAnswer && $options.stopRecordingAnswer(...args))
  1867. } : {}, {
  1868. t: $data.isRecording
  1869. }, $data.isRecording ? {
  1870. v: common_vendor.t($data.recordingTimeDisplay || "00:00 / 05:00")
  1871. } : {}, {
  1872. w: $data.showStartRecordingButton
  1873. }, $data.showStartRecordingButton ? {
  1874. x: common_vendor.o((...args) => $options.handleStartRecordingClick && $options.handleStartRecordingClick(...args))
  1875. } : {}, {
  1876. y: $data.showRetryButton
  1877. }, $data.showRetryButton ? {
  1878. z: common_vendor.o((...args) => $options.retryVideoUpload && $options.retryVideoUpload(...args))
  1879. } : {}, {
  1880. A: $data.showCountdown
  1881. }, $data.showCountdown ? {
  1882. B: common_vendor.t($data.countdownValue)
  1883. } : {});
  1884. }
  1885. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-2a02c54e"]]);
  1886. wx.createPage(MiniProgramPage);