identity-verify.js 65 KB

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