identity-verify.js 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308
  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: 3,
  58. text: "在工作中,你如何确保个人防护装备的正确使用?"
  59. }
  60. ],
  61. fourthVideoSubtitles: [
  62. {
  63. startTime: 0,
  64. endTime: 3,
  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/9c139c99-a613-49f2-986b-8a3ac20a9b1b.mp4",
  88. // 第一段视频
  89. "http://121.36.251.245:9000/minlong/15467aca-2c1e-4d40-bebc-11fc984f0a24.mp4",
  90. // 第二段视频
  91. "http://121.36.251.245:9000/minlong/a96f295c-ecba-4b08-b627-0ed0dc72d727.mp4",
  92. // 第三段视频
  93. "http://121.36.251.245:9000/minlong/e152eb38-7e03-4bb0-8b8d-73d51342d2aa.mp4",
  94. "http://121.36.251.245:9000/minlong/6381eec3-1373-400f-aa8c-e229b60522ea.mp4",
  95. "http://121.36.251.245:9000/minlong/2a11fe78-38d5-4af3-91c8-a080feb122e0.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. };
  111. },
  112. mounted() {
  113. this.playDigitalHumanVideo();
  114. this.checkAudioPermission();
  115. this.initCamera();
  116. setTimeout(() => {
  117. if (this.cameraStream && !this.useMiniProgramCameraComponent) {
  118. this.testAudioInput();
  119. }
  120. }, 3e3);
  121. },
  122. beforeDestroy() {
  123. this.stopUserCamera();
  124. },
  125. methods: {
  126. // 初始化相机
  127. async initCamera() {
  128. const systemInfo = common_vendor.index.getSystemInfoSync();
  129. const isMiniProgram = systemInfo.uniPlatform === "mp-weixin" || systemInfo.uniPlatform === "mp-alipay" || systemInfo.uniPlatform === "mp-baidu";
  130. if (isMiniProgram) {
  131. this.useMiniProgramCameraComponent = true;
  132. this.cameraContext = common_vendor.index.createCameraContext();
  133. common_vendor.index.getSetting({
  134. success: (res) => {
  135. if (!res.authSetting["scope.record"]) {
  136. common_vendor.index.authorize({
  137. scope: "scope.record",
  138. success: () => {
  139. console.log("录音权限已获取");
  140. },
  141. fail: (err) => {
  142. console.error("录音权限获取失败:", err);
  143. this.showPermissionDialog("录音");
  144. }
  145. });
  146. }
  147. if (!res.authSetting["scope.camera"]) {
  148. common_vendor.index.authorize({
  149. scope: "scope.camera",
  150. success: () => {
  151. console.log("相机权限已获取");
  152. },
  153. fail: (err) => {
  154. console.error("相机权限获取失败:", err);
  155. this.showPermissionDialog("相机");
  156. }
  157. });
  158. }
  159. }
  160. });
  161. } else {
  162. try {
  163. const constraints = {
  164. audio: {
  165. echoCancellation: true,
  166. noiseSuppression: true,
  167. autoGainControl: true
  168. },
  169. video: {
  170. width: { ideal: 640 },
  171. height: { ideal: 480 },
  172. facingMode: "user"
  173. }
  174. };
  175. const stream = await navigator.mediaDevices.getUserMedia(constraints);
  176. this.cameraStream = stream;
  177. const audioTracks = stream.getAudioTracks();
  178. console.log("音频轨道数量:", audioTracks.length);
  179. if (audioTracks.length > 0) {
  180. console.log("音频轨道已获取:", audioTracks[0].label);
  181. audioTracks[0].enabled = true;
  182. } else {
  183. console.warn("未检测到音频轨道,尝试单独获取音频");
  184. this.tryGetAudioOnly();
  185. }
  186. const videoElement = this.$refs.userCameraVideo;
  187. if (videoElement) {
  188. videoElement.srcObject = stream;
  189. videoElement.muted = true;
  190. }
  191. } catch (error) {
  192. console.error("获取摄像头失败:", error);
  193. this.cameraError = error.message || "无法访问摄像头";
  194. common_vendor.index.showToast({
  195. title: "无法访问摄像头,请检查权限设置",
  196. icon: "none"
  197. });
  198. }
  199. }
  200. },
  201. // 停止用户摄像头
  202. stopUserCamera() {
  203. if (this.cameraStream) {
  204. this.cameraStream.getTracks().forEach((track) => {
  205. track.stop();
  206. });
  207. this.cameraStream = null;
  208. }
  209. },
  210. async fetchData() {
  211. this.loading = true;
  212. this.assistantResponse = "";
  213. this.audioTranscript = "";
  214. this.processedResponses = [];
  215. try {
  216. const requestTask = common_vendor.index.request({
  217. url: "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
  218. method: "POST",
  219. header: {
  220. "Content-Type": "application/json",
  221. "Authorization": "Bearer sk-9e1ec73a7d97493b8613c63f06b6110c"
  222. },
  223. data: {
  224. "model": "qwen-omni-turbo",
  225. "messages": [
  226. {
  227. "role": "user",
  228. "content": [
  229. {
  230. "type": "input_audio",
  231. "input_audio": {
  232. "data": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250211/tixcef/cherry.wav",
  233. "format": "wav"
  234. }
  235. },
  236. {
  237. "type": "text",
  238. "text": "这段音频在说什么"
  239. }
  240. ]
  241. }
  242. ],
  243. "stream": true,
  244. "stream_options": {
  245. "include_usage": true
  246. },
  247. "modalities": ["text", "audio"],
  248. "audio": { "voice": "Cherry", "format": "wav" }
  249. },
  250. success: (res) => {
  251. console.log("请求成功,响应数据:", res.data);
  252. if (typeof res.data === "string" && res.data.includes("data: {")) {
  253. const chunks = res.data.split("data: ").filter((chunk) => chunk.trim() !== "");
  254. chunks.forEach((chunk) => {
  255. this.handleStreamResponse(chunk);
  256. });
  257. } else {
  258. this.handleStreamResponse(res.data);
  259. }
  260. this.playDigitalHumanVideo();
  261. },
  262. fail: (err) => {
  263. console.error("请求失败:", err);
  264. },
  265. complete: () => {
  266. this.loading = false;
  267. }
  268. });
  269. } catch (error) {
  270. console.error("获取数据失败:", error);
  271. this.loading = false;
  272. }
  273. },
  274. handleStreamResponse(data) {
  275. if (typeof data === "string") {
  276. if (data === "[DONE]")
  277. return;
  278. try {
  279. const cleanData = data.trim();
  280. if (cleanData.startsWith("{") && cleanData.endsWith("}")) {
  281. const jsonData = JSON.parse(cleanData);
  282. this.processStreamChunk(jsonData);
  283. }
  284. } catch (e) {
  285. console.error("解析JSON失败:", e, "原始数据:", data);
  286. }
  287. } else {
  288. this.processStreamChunk(data);
  289. }
  290. },
  291. processStreamChunk(chunk) {
  292. if (chunk.choices && chunk.choices.length > 0) {
  293. const choice = chunk.choices[0];
  294. if (choice.delta && choice.delta.content) {
  295. this.assistantResponse += choice.delta.content;
  296. }
  297. if (choice.delta && choice.delta.audio && choice.delta.audio.transcript) {
  298. this.audioTranscript += choice.delta.audio.transcript;
  299. }
  300. if (choice.delta) {
  301. const result = {};
  302. if (choice.delta.role) {
  303. result.role = choice.delta.role;
  304. }
  305. if (choice.delta.audio && choice.delta.audio.transcript) {
  306. result.transcript = choice.delta.audio.transcript;
  307. }
  308. if (Object.keys(result).length > 0) {
  309. this.processedResponses.push(result);
  310. }
  311. }
  312. }
  313. },
  314. processResponseData() {
  315. this.processedResponses = this.responses.map((item) => {
  316. const result = {};
  317. if (item.delta && item.delta.role) {
  318. result.role = item.delta.role;
  319. }
  320. if (item.delta && item.delta.audio && item.delta.audio.transcript) {
  321. result.transcript = item.delta.audio.transcript;
  322. }
  323. return result;
  324. }).filter((item) => Object.keys(item).length > 0);
  325. },
  326. // 播放数字人视频
  327. playDigitalHumanVideo() {
  328. this.videoUrl = this.videoList[this.currentVideoIndex];
  329. this.videoPlaying = true;
  330. this.$nextTick(() => {
  331. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  332. if (videoContext) {
  333. videoContext.play();
  334. setTimeout(() => {
  335. if (this.videoPlaying && this.$refs.videoPlayer) {
  336. console.log("视频应该正在播放");
  337. } else {
  338. console.log("视频可能未成功播放,尝试替代方案");
  339. this.tryAlternativeVideoPath();
  340. }
  341. }, 1e3);
  342. } else {
  343. console.error("无法创建视频上下文");
  344. this.tryAlternativeVideoPath();
  345. }
  346. });
  347. },
  348. // 修改 tryAlternativeVideoPath 方法
  349. tryAlternativeVideoPath() {
  350. console.log("尝试使用替代路径");
  351. const alternativePaths = [
  352. "./static/demo.mp4",
  353. "../static/demo.mp4",
  354. "static/demo.mp4",
  355. "/static/demo.mp4",
  356. // 添加绝对路径
  357. `${window.location.origin}/static/demo.mp4`
  358. ];
  359. const currentPathIndex = alternativePaths.indexOf(this.videoUrl);
  360. const nextPathIndex = (currentPathIndex + 1) % alternativePaths.length;
  361. this.videoUrl = alternativePaths[nextPathIndex];
  362. console.log("尝试新路径:", this.videoUrl);
  363. this.$nextTick(() => {
  364. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  365. if (videoContext) {
  366. videoContext.stop();
  367. videoContext.play();
  368. setTimeout(() => {
  369. if (nextPathIndex === alternativePaths.length - 1 && !this.videoPlaying) {
  370. console.log("所有路径均失败,尝试使用uni.getVideoInfo检查视频");
  371. this.checkVideoWithAPI();
  372. }
  373. }, 1e3);
  374. }
  375. });
  376. },
  377. // 添加新方法:使用uni API检查视频
  378. checkVideoWithAPI() {
  379. common_vendor.index.getVideoInfo({
  380. src: "/static/demo.mp4",
  381. success: (res) => {
  382. console.log("视频信息获取成功:", res);
  383. this.videoUrl = "/static/demo.mp4";
  384. this.$nextTick(() => {
  385. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  386. if (videoContext) {
  387. videoContext.play();
  388. }
  389. });
  390. },
  391. fail: (err) => {
  392. console.error("视频信息获取失败:", err);
  393. this.fallbackToLocalVideo();
  394. }
  395. });
  396. },
  397. // 添加新方法:回退到本地视频
  398. fallbackToLocalVideo() {
  399. console.log("尝试使用本地视频资源");
  400. const platform = common_vendor.index.getSystemInfoSync().platform;
  401. if (platform === "android" || platform === "ios") {
  402. this.videoUrl = platform === "android" ? "android.resource://package_name/raw/demo" : "file:///assets/demo.mp4";
  403. this.$nextTick(() => {
  404. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  405. if (videoContext) {
  406. videoContext.play();
  407. }
  408. });
  409. } else {
  410. this.videoPlaying = false;
  411. common_vendor.index.showToast({
  412. title: "视频加载失败,显示静态图片",
  413. icon: "none"
  414. });
  415. }
  416. },
  417. // 修改 handleVideoError 方法
  418. handleVideoError(e) {
  419. console.error("视频加载错误:", e);
  420. if (e && e.detail) {
  421. console.error("详细错误信息:", e.detail);
  422. }
  423. common_vendor.index.getFileInfo({
  424. filePath: this.videoUrl.startsWith("/") ? this.videoUrl.substring(1) : this.videoUrl,
  425. success: (res) => {
  426. console.log("文件存在,大小:", res.size);
  427. this.tryDifferentFormat();
  428. },
  429. fail: (err) => {
  430. console.error("文件不存在或无法访问:", err);
  431. this.tryAlternativeVideoPath();
  432. }
  433. });
  434. common_vendor.index.showToast({
  435. title: "视频加载失败,请检查文件是否存在",
  436. icon: "none",
  437. duration: 2e3
  438. });
  439. },
  440. // 添加新方法:尝试不同格式
  441. tryDifferentFormat() {
  442. console.log("尝试不同的视频格式");
  443. const formats = [
  444. { ext: "mp4", mime: "video/mp4" },
  445. { ext: "webm", mime: "video/webm" },
  446. { ext: "ogg", mime: "video/ogg" },
  447. { ext: "mov", mime: "video/quicktime" }
  448. ];
  449. const currentPath = this.videoUrl;
  450. const basePath = currentPath.substring(0, currentPath.lastIndexOf(".")) || "/static/demo";
  451. let nextFormat = formats.find((f) => !currentPath.endsWith(f.ext));
  452. if (nextFormat) {
  453. this.videoUrl = `${basePath}.${nextFormat.ext}`;
  454. console.log("尝试新格式:", this.videoUrl);
  455. this.$nextTick(() => {
  456. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  457. if (videoContext) {
  458. videoContext.stop();
  459. videoContext.play();
  460. }
  461. });
  462. } else {
  463. this.useBuiltInResource();
  464. }
  465. },
  466. // 添加新方法:使用内置资源
  467. useBuiltInResource() {
  468. console.log("尝试使用内置资源");
  469. const platform = common_vendor.index.getSystemInfoSync().platform;
  470. if (platform === "windows") {
  471. process.env.UNI_INPUT_DIR || "";
  472. this.videoUrl = `./static/demo.mp4`;
  473. console.log("Windows平台尝试路径:", this.videoUrl);
  474. } else if (platform === "android" || platform === "ios") {
  475. this.useNativeVideo();
  476. } else {
  477. const baseUrl = window.location.origin;
  478. this.videoUrl = `${baseUrl}/static/demo.mp4`;
  479. console.log("Web平台尝试URL:", this.videoUrl);
  480. }
  481. this.$nextTick(() => {
  482. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  483. if (videoContext) {
  484. videoContext.play();
  485. }
  486. });
  487. },
  488. // 添加新方法:使用原生视频能力
  489. useNativeVideo() {
  490. console.log("尝试使用原生视频能力");
  491. common_vendor.index.chooseVideo({
  492. sourceType: ["album"],
  493. success: (res) => {
  494. this.videoUrl = res.tempFilePath;
  495. this.$nextTick(() => {
  496. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  497. if (videoContext) {
  498. videoContext.play();
  499. }
  500. });
  501. },
  502. fail: () => {
  503. this.videoPlaying = false;
  504. common_vendor.index.showToast({
  505. title: "无法加载视频,显示静态图片",
  506. icon: "none"
  507. });
  508. }
  509. });
  510. },
  511. // 处理视频结束事件
  512. handleVideoEnded() {
  513. console.log("视频播放结束");
  514. this.videoPlaying = false;
  515. if (this.currentVideoIndex >= 1) {
  516. this.showStartRecordingButton = true;
  517. } else {
  518. this.showAnswerButton = true;
  519. }
  520. },
  521. // 添加新方法:开始录制用户回答
  522. startRecordingAnswer() {
  523. console.log("开始录制用户回答");
  524. this.isRecording = true;
  525. const systemInfo = common_vendor.index.getSystemInfoSync();
  526. const isMiniProgram = systemInfo.uniPlatform && systemInfo.uniPlatform.startsWith("mp-");
  527. if (isMiniProgram) {
  528. this.startMiniProgramRecording();
  529. } else {
  530. this.startBrowserRecording();
  531. }
  532. this.showStopRecordingButton = true;
  533. },
  534. // 修改小程序环境下的录制方法
  535. startMiniProgramRecording() {
  536. if (!this.cameraContext) {
  537. this.cameraContext = common_vendor.index.createCameraContext();
  538. }
  539. common_vendor.index.getSetting({
  540. success: (res) => {
  541. const hasRecordAuth = res.authSetting["scope.record"];
  542. const hasCameraAuth = res.authSetting["scope.camera"];
  543. if (!hasRecordAuth || !hasCameraAuth) {
  544. console.warn("缺少必要权限,请求权限");
  545. this.requestMiniProgramPermissions();
  546. return;
  547. }
  548. const options = {
  549. timeout: 6e4,
  550. // 最长录制60秒
  551. success: () => {
  552. console.log("小程序录像开始成功");
  553. },
  554. fail: (err) => {
  555. console.error("小程序录像开始失败:", err);
  556. common_vendor.index.showToast({
  557. title: "录制失败,请检查相机权限",
  558. icon: "none"
  559. });
  560. this.proceedToNextQuestion();
  561. },
  562. timeoutCallback: () => {
  563. console.log("录制超时自动停止");
  564. this.stopRecordingAnswer();
  565. }
  566. };
  567. this.recorder = this.cameraContext.startRecord(options);
  568. }
  569. });
  570. },
  571. // 添加新方法:请求小程序权限
  572. requestMiniProgramPermissions() {
  573. common_vendor.index.authorize({
  574. scope: "scope.record",
  575. success: () => {
  576. console.log("录音权限已获取");
  577. common_vendor.index.authorize({
  578. scope: "scope.camera",
  579. success: () => {
  580. console.log("相机权限已获取");
  581. this.startMiniProgramRecording();
  582. },
  583. fail: (err) => {
  584. console.error("相机权限获取失败:", err);
  585. this.showPermissionDialog("相机");
  586. }
  587. });
  588. },
  589. fail: (err) => {
  590. console.error("录音权限获取失败:", err);
  591. this.showPermissionDialog("录音");
  592. }
  593. });
  594. },
  595. // 修改浏览器环境下的录制方法
  596. startBrowserRecording() {
  597. if (!this.cameraStream) {
  598. console.error("没有可用的摄像头流");
  599. common_vendor.index.showToast({
  600. title: "录制失败,摄像头未就绪",
  601. icon: "none"
  602. });
  603. this.proceedToNextQuestion();
  604. return;
  605. }
  606. try {
  607. const hasAudio = this.cameraStream.getAudioTracks().length > 0;
  608. if (!hasAudio) {
  609. console.warn("警告:媒体流中没有音频轨道,尝试重新获取带音频的媒体流");
  610. navigator.mediaDevices.getUserMedia({
  611. audio: {
  612. echoCancellation: true,
  613. noiseSuppression: true,
  614. autoGainControl: true
  615. },
  616. video: true
  617. }).then((newStream) => {
  618. const audioTracks = newStream.getAudioTracks();
  619. if (audioTracks.length > 0) {
  620. console.log("成功获取音频轨道:", audioTracks[0].label);
  621. const videoTrack = this.cameraStream.getVideoTracks()[0];
  622. const audioTrack = newStream.getAudioTracks()[0];
  623. const combinedStream = new MediaStream();
  624. if (videoTrack)
  625. combinedStream.addTrack(videoTrack);
  626. if (audioTrack)
  627. combinedStream.addTrack(audioTrack);
  628. this.cameraStream = combinedStream;
  629. const videoElement = this.$refs.userCameraVideo;
  630. if (videoElement) {
  631. videoElement.srcObject = combinedStream;
  632. videoElement.muted = true;
  633. }
  634. this.setupMediaRecorder(combinedStream);
  635. } else {
  636. console.warn("仍然无法获取音频轨道");
  637. this.setupMediaRecorder(this.cameraStream);
  638. }
  639. }).catch((err) => {
  640. console.error("获取音频失败:", err);
  641. this.setupMediaRecorder(this.cameraStream);
  642. });
  643. } else {
  644. console.log("检测到音频轨道,直接使用");
  645. this.setupMediaRecorder(this.cameraStream);
  646. }
  647. } catch (error) {
  648. console.error("浏览器录制失败:", error);
  649. common_vendor.index.showToast({
  650. title: "录制失败,浏览器可能不支持此功能",
  651. icon: "none"
  652. });
  653. this.proceedToNextQuestion();
  654. }
  655. },
  656. // 修改 setupMediaRecorder 方法
  657. setupMediaRecorder(stream) {
  658. const videoTracks = stream.getVideoTracks();
  659. const audioTracks = stream.getAudioTracks();
  660. console.log("设置MediaRecorder - 视频轨道:", videoTracks.length, "音频轨道:", audioTracks.length);
  661. let mimeType = "";
  662. const supportedTypes = [
  663. "video/webm;codecs=vp9,opus",
  664. "video/webm;codecs=vp8,opus",
  665. "video/webm;codecs=h264,opus",
  666. "video/mp4;codecs=h264,aac",
  667. "video/webm",
  668. "video/mp4"
  669. ];
  670. for (const type of supportedTypes) {
  671. if (MediaRecorder.isTypeSupported(type)) {
  672. mimeType = type;
  673. console.log("使用支持的MIME类型:", mimeType);
  674. break;
  675. }
  676. }
  677. const options = {
  678. mimeType: mimeType || "",
  679. audioBitsPerSecond: 128e3,
  680. videoBitsPerSecond: 25e5
  681. };
  682. try {
  683. this.mediaRecorder = new MediaRecorder(stream, options);
  684. console.log("MediaRecorder创建成功,使用选项:", options);
  685. } catch (e) {
  686. console.warn("使用指定选项创建MediaRecorder失败,尝试使用默认选项");
  687. this.mediaRecorder = new MediaRecorder(stream);
  688. }
  689. this.recordedChunks = [];
  690. this.mediaRecorder.ondataavailable = (event) => {
  691. if (event.data && event.data.size > 0) {
  692. this.recordedChunks.push(event.data);
  693. console.log(`收到数据块: ${event.data.size} 字节`);
  694. }
  695. };
  696. this.mediaRecorder.onstop = () => {
  697. console.log("MediaRecorder停止,数据块数量:", this.recordedChunks.length);
  698. if (this.recordedChunks.length === 0) {
  699. console.error("没有录制到数据");
  700. common_vendor.index.showToast({
  701. title: "录制失败,未捕获到数据",
  702. icon: "none"
  703. });
  704. this.proceedToNextQuestion();
  705. return;
  706. }
  707. const mimeType2 = this.mediaRecorder.mimeType || "video/webm";
  708. const blob = new Blob(this.recordedChunks, { type: mimeType2 });
  709. console.log("创建Blob,大小:", blob.size, "类型:", mimeType2);
  710. const fileName = `answer_${this.currentVideoIndex}_${Date.now()}.webm`;
  711. const file = new File([blob], fileName, { type: mimeType2 });
  712. this.uploadRecordedVideo(file);
  713. };
  714. this.mediaRecorder.onerror = (event) => {
  715. console.error("MediaRecorder错误:", event.error);
  716. };
  717. try {
  718. this.mediaRecorder.start(1e3);
  719. console.log("MediaRecorder开始录制");
  720. } catch (e) {
  721. console.error("开始录制失败:", e);
  722. }
  723. },
  724. // 添加新方法:停止录制用户回答
  725. stopRecordingAnswer() {
  726. console.log("停止录制用户回答");
  727. this.isRecording = false;
  728. if (this.recordingTimer) {
  729. clearTimeout(this.recordingTimer);
  730. this.recordingTimer = null;
  731. }
  732. common_vendor.index.hideLoading();
  733. this.showStopRecordingButton = false;
  734. const systemInfo = common_vendor.index.getSystemInfoSync();
  735. const isMiniProgram = systemInfo.uniPlatform && systemInfo.uniPlatform.startsWith("mp-");
  736. if (isMiniProgram) {
  737. this.stopMiniProgramRecording();
  738. } else {
  739. this.stopBrowserRecording();
  740. }
  741. },
  742. // 添加新方法:停止小程序录制
  743. stopMiniProgramRecording() {
  744. if (!this.cameraContext) {
  745. console.error("相机上下文不存在");
  746. this.proceedToNextQuestion();
  747. return;
  748. }
  749. this.cameraContext.stopRecord({
  750. success: (res) => {
  751. console.log("小程序录像停止成功:", res);
  752. const tempFilePath = res.tempVideoPath;
  753. this.uploadRecordedVideo(tempFilePath);
  754. },
  755. fail: (err) => {
  756. console.error("小程序录像停止失败:", err);
  757. common_vendor.index.showToast({
  758. title: "录制失败",
  759. icon: "none"
  760. });
  761. this.proceedToNextQuestion();
  762. }
  763. });
  764. },
  765. // 添加新方法:停止浏览器录制
  766. stopBrowserRecording() {
  767. if (this.mediaRecorder && this.mediaRecorder.state !== "inactive") {
  768. this.mediaRecorder.stop();
  769. console.log("浏览器录制停止成功");
  770. } else {
  771. console.error("MediaRecorder不存在或已经停止");
  772. this.proceedToNextQuestion();
  773. }
  774. },
  775. // 修改上传录制的视频方法
  776. uploadRecordedVideo(fileOrPath) {
  777. console.log("准备上传视频:", typeof fileOrPath === "string" ? fileOrPath : fileOrPath.name);
  778. common_vendor.index.showLoading({
  779. title: "正在上传...",
  780. mask: true
  781. });
  782. const userInfo = common_vendor.index.getStorageSync("userInfo");
  783. const openid = userInfo ? JSON.parse(userInfo).openid || "" : "";
  784. const tenant_id = common_vendor.index.getStorageSync("tenant_id") || "1";
  785. let questionId;
  786. switch (this.currentVideoIndex) {
  787. case 1:
  788. questionId = 10;
  789. break;
  790. case 2:
  791. questionId = 11;
  792. break;
  793. case 3:
  794. questionId = 12;
  795. break;
  796. case 4:
  797. questionId = 13;
  798. break;
  799. default:
  800. questionId = 10;
  801. }
  802. if (typeof fileOrPath !== "string") {
  803. const formData = new FormData();
  804. formData.append("file", fileOrPath);
  805. formData.append("openid", openid);
  806. formData.append("tenant_id", tenant_id);
  807. formData.append("application_id", 1);
  808. formData.append("question_id", questionId);
  809. formData.append("video_duration", 0);
  810. formData.append("has_audio", "true");
  811. const xhr = new XMLHttpRequest();
  812. xhr.open("POST", `${common_config.apiBaseUrl}/api/system/upload/`, true);
  813. xhr.onload = () => {
  814. common_vendor.index.hideLoading();
  815. if (xhr.status === 200) {
  816. try {
  817. const res = JSON.parse(xhr.responseText);
  818. console.log("上传响应:", res);
  819. if (res.code === 2e3) {
  820. const videoUrl = res.data.url || res.data.photoUrl || "";
  821. if (videoUrl) {
  822. this.submitVideoToInterview(videoUrl);
  823. } else {
  824. common_vendor.index.showToast({
  825. title: "视频URL获取失败",
  826. icon: "none"
  827. });
  828. }
  829. } else {
  830. common_vendor.index.showToast({
  831. title: res.msg || "上传失败,请重试",
  832. icon: "none"
  833. });
  834. }
  835. } catch (e) {
  836. console.error("解析响应失败:", e);
  837. common_vendor.index.showToast({
  838. title: "解析响应失败",
  839. icon: "none"
  840. });
  841. }
  842. } else {
  843. common_vendor.index.showToast({
  844. title: "上传失败,HTTP状态: " + xhr.status,
  845. icon: "none"
  846. });
  847. }
  848. };
  849. xhr.onerror = () => {
  850. common_vendor.index.hideLoading();
  851. console.error("上传网络错误");
  852. common_vendor.index.showToast({
  853. title: "网络错误,请重试",
  854. icon: "none"
  855. });
  856. };
  857. xhr.upload.onprogress = (event) => {
  858. if (event.lengthComputable) {
  859. const percentComplete = Math.round(event.loaded / event.total * 100);
  860. console.log("上传进度:", percentComplete + "%");
  861. }
  862. };
  863. xhr.send(formData);
  864. return;
  865. }
  866. common_vendor.index.uploadFile({
  867. url: `${common_config.apiBaseUrl}/api/system/upload/`,
  868. filePath: fileOrPath,
  869. name: "file",
  870. formData: {
  871. openid,
  872. tenant_id,
  873. application_id: 1,
  874. question_id: questionId,
  875. video_duration: 0,
  876. has_audio: "true"
  877. // 明确标记视频包含音频
  878. },
  879. success: (uploadRes) => {
  880. try {
  881. const res = JSON.parse(uploadRes.data);
  882. console.log("上传响应:", res);
  883. if (res.code === 2e3) {
  884. const videoUrl = res.data.permanent_link || res.data.url || "";
  885. if (videoUrl) {
  886. this.submitVideoToInterview(videoUrl);
  887. } else {
  888. common_vendor.index.showToast({
  889. title: "视频URL获取失败",
  890. icon: "none"
  891. });
  892. }
  893. } else {
  894. common_vendor.index.showToast({
  895. title: res.msg || "上传失败,请重试",
  896. icon: "none"
  897. });
  898. }
  899. } catch (e) {
  900. console.error("解析响应失败:", e);
  901. common_vendor.index.showToast({
  902. title: "解析响应失败",
  903. icon: "none"
  904. });
  905. }
  906. },
  907. fail: (err) => {
  908. console.error("上传失败:", err);
  909. common_vendor.index.showToast({
  910. title: "上传失败,请重试",
  911. icon: "none"
  912. });
  913. },
  914. complete: () => {
  915. common_vendor.index.hideLoading();
  916. }
  917. });
  918. },
  919. // 修改 submitVideoToInterview 方法
  920. submitVideoToInterview(videoUrl) {
  921. console.log("提交视频URL到面试接口:", videoUrl);
  922. common_vendor.index.showLoading({
  923. title: "正在提交...",
  924. mask: true
  925. });
  926. let questionId;
  927. switch (this.currentVideoIndex) {
  928. case 1:
  929. questionId = 10;
  930. break;
  931. case 2:
  932. questionId = 11;
  933. break;
  934. case 3:
  935. questionId = 12;
  936. break;
  937. case 4:
  938. questionId = 13;
  939. break;
  940. default:
  941. questionId = 10;
  942. }
  943. const requestData = {
  944. application_id: 1,
  945. question_id: questionId,
  946. video_url: videoUrl,
  947. tenant_id: common_vendor.index.getStorageSync("tenant_id") || "1"
  948. };
  949. common_vendor.index.request({
  950. url: `${common_config.apiBaseUrl}/api/job/upload_question_video`,
  951. method: "POST",
  952. data: requestData,
  953. // 使用data而不是formData
  954. header: {
  955. "content-type": "application/x-www-form-urlencoded"
  956. // 修改为form-data格式的content-type
  957. },
  958. success: (res) => {
  959. console.log("面试接口提交成功:", res);
  960. common_vendor.index.hideLoading();
  961. if (res.data.code === 0 || res.data.code === 2e3) {
  962. common_vendor.index.showToast({
  963. title: "回答已提交",
  964. icon: "success"
  965. });
  966. this.lastUploadedVideoUrl = videoUrl;
  967. this.showRetryButton = false;
  968. this.lastVideoToRetry = null;
  969. setTimeout(() => {
  970. if (this.currentVideoIndex === 4) {
  971. common_vendor.index.navigateTo({
  972. url: "/pages/camera/camera"
  973. });
  974. } else {
  975. this.proceedToNextQuestion();
  976. }
  977. }, 1500);
  978. } else {
  979. common_vendor.index.showToast({
  980. title: res.data.msg || "提交失败,请重试",
  981. icon: "none"
  982. });
  983. this.lastVideoToRetry = videoUrl;
  984. this.showRetryButton = true;
  985. }
  986. },
  987. fail: (err) => {
  988. console.error("面试接口提交失败:", err);
  989. common_vendor.index.hideLoading();
  990. common_vendor.index.showToast({
  991. title: "网络错误,请重试",
  992. icon: "none"
  993. });
  994. this.lastVideoToRetry = videoUrl;
  995. this.showRetryButton = true;
  996. }
  997. });
  998. },
  999. // 修改 proceedToNextQuestion 方法
  1000. proceedToNextQuestion() {
  1001. if (this.currentVideoIndex === 4) {
  1002. common_vendor.index.navigateTo({
  1003. url: "/pages/camera/camera"
  1004. });
  1005. return;
  1006. }
  1007. this.currentVideoIndex++;
  1008. if (this.currentVideoIndex < this.videoList.length) {
  1009. this.videoUrl = this.videoList[this.currentVideoIndex];
  1010. this.videoPlaying = true;
  1011. this.currentSubtitle = "";
  1012. this.$nextTick(() => {
  1013. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  1014. if (videoContext) {
  1015. videoContext.play();
  1016. }
  1017. });
  1018. } else {
  1019. common_vendor.index.showToast({
  1020. title: "面试完成",
  1021. icon: "success",
  1022. duration: 2e3
  1023. });
  1024. setTimeout(() => {
  1025. common_vendor.index.navigateTo({
  1026. url: "/pages/interview-result/interview-result"
  1027. });
  1028. }, 2e3);
  1029. }
  1030. },
  1031. // 修改 handleAnswerButtonClick 方法
  1032. handleAnswerButtonClick() {
  1033. this.showAnswerButton = false;
  1034. this.proceedToNextQuestion();
  1035. },
  1036. // 处理相机错误
  1037. handleCameraError(e) {
  1038. console.error("相机错误:", e);
  1039. common_vendor.index.showToast({
  1040. title: "相机初始化失败,请检查权限设置",
  1041. icon: "none"
  1042. });
  1043. this.tryFallbackOptions();
  1044. },
  1045. // 添加新方法:尝试备用选项
  1046. tryFallbackOptions() {
  1047. const systemInfo = common_vendor.index.getSystemInfoSync();
  1048. if (systemInfo.uniPlatform === "mp-weixin" || systemInfo.uniPlatform === "mp-alipay") {
  1049. this.useMiniProgramCamera();
  1050. } else {
  1051. this.showStaticCameraPlaceholder();
  1052. }
  1053. },
  1054. // 添加新方法:使用小程序相机API
  1055. useMiniProgramCamera() {
  1056. console.log("尝试使用小程序相机组件");
  1057. this.useMiniProgramCameraComponent = true;
  1058. },
  1059. // 添加新方法:显示静态图像
  1060. showStaticCameraPlaceholder() {
  1061. console.log("显示静态摄像头占位图");
  1062. const img = document.createElement("img");
  1063. img.src = "/static/images/camera-placeholder.png";
  1064. img.className = "static-camera-image";
  1065. img.style.width = "100%";
  1066. img.style.height = "100%";
  1067. img.style.objectFit = "cover";
  1068. const container = this.$refs.userCameraVideo.parentNode;
  1069. container.appendChild(img);
  1070. },
  1071. // 处理视频时间更新事件
  1072. handleTimeUpdate(e) {
  1073. const currentTime = e.target.currentTime;
  1074. let currentSubtitles;
  1075. if (this.currentVideoIndex === 0) {
  1076. currentSubtitles = this.subtitles;
  1077. } else if (this.currentVideoIndex === 1) {
  1078. currentSubtitles = this.secondVideoSubtitles;
  1079. } else if (this.currentVideoIndex === 2) {
  1080. currentSubtitles = this.thirdVideoSubtitles;
  1081. } else if (this.currentVideoIndex === 3) {
  1082. currentSubtitles = this.fourthVideoSubtitles;
  1083. } else if (this.currentVideoIndex === 4) {
  1084. currentSubtitles = this.fifthVideoSubtitles;
  1085. } else if (this.currentVideoIndex === 5) {
  1086. currentSubtitles = this.sixthVideoSubtitles;
  1087. } else {
  1088. currentSubtitles = [];
  1089. }
  1090. const subtitle = currentSubtitles.find(
  1091. (sub) => currentTime >= sub.startTime && currentTime < sub.endTime
  1092. );
  1093. this.currentSubtitle = subtitle ? subtitle.text : "";
  1094. },
  1095. // Add a new method to handle the "Start Recording" button click
  1096. handleStartRecordingClick() {
  1097. this.showStartRecordingButton = false;
  1098. this.startRecordingAnswer();
  1099. },
  1100. // 修改 checkAudioPermission 方法,确保在录制前获取音频权限
  1101. checkAudioPermission() {
  1102. const systemInfo = common_vendor.index.getSystemInfoSync();
  1103. const isMiniProgram = systemInfo.uniPlatform && systemInfo.uniPlatform.startsWith("mp-");
  1104. if (isMiniProgram) {
  1105. common_vendor.index.getSetting({
  1106. success: (res) => {
  1107. if (!res.authSetting["scope.record"]) {
  1108. common_vendor.index.authorize({
  1109. scope: "scope.record",
  1110. success: () => {
  1111. console.log("录音权限已获取");
  1112. },
  1113. fail: (err) => {
  1114. console.error("录音权限获取失败:", err);
  1115. this.showPermissionDialog("录音");
  1116. }
  1117. });
  1118. }
  1119. if (!res.authSetting["scope.camera"]) {
  1120. common_vendor.index.authorize({
  1121. scope: "scope.camera",
  1122. success: () => {
  1123. console.log("相机权限已获取");
  1124. },
  1125. fail: (err) => {
  1126. console.error("相机权限获取失败:", err);
  1127. this.showPermissionDialog("相机");
  1128. }
  1129. });
  1130. }
  1131. }
  1132. });
  1133. }
  1134. },
  1135. // 添加新方法:测试音频输入
  1136. testAudioInput() {
  1137. if (!this.cameraStream) {
  1138. console.warn("没有可用的媒体流,无法测试音频");
  1139. return;
  1140. }
  1141. const audioTracks = this.cameraStream.getAudioTracks();
  1142. if (audioTracks.length === 0) {
  1143. console.warn("没有检测到音频轨道,尝试重新获取");
  1144. this.tryGetAudioOnly();
  1145. return;
  1146. }
  1147. console.log("音频轨道信息:", audioTracks[0].getSettings());
  1148. try {
  1149. const AudioContext = window.AudioContext || window.webkitAudioContext;
  1150. if (!AudioContext) {
  1151. console.warn("浏览器不支持AudioContext");
  1152. return;
  1153. }
  1154. const audioContext = new AudioContext();
  1155. const analyser = audioContext.createAnalyser();
  1156. const microphone = audioContext.createMediaStreamSource(this.cameraStream);
  1157. microphone.connect(analyser);
  1158. analyser.fftSize = 256;
  1159. const bufferLength = analyser.frequencyBinCount;
  1160. const dataArray = new Uint8Array(bufferLength);
  1161. let silenceCounter = 0;
  1162. const checkAudio = () => {
  1163. if (this.isRecording)
  1164. return;
  1165. analyser.getByteFrequencyData(dataArray);
  1166. let sum = 0;
  1167. for (let i = 0; i < bufferLength; i++) {
  1168. sum += dataArray[i];
  1169. }
  1170. const average = sum / bufferLength;
  1171. if (average > 10) {
  1172. console.log("检测到音频输入,音量:", average);
  1173. silenceCounter = 0;
  1174. } else {
  1175. silenceCounter++;
  1176. if (silenceCounter > 10) {
  1177. console.warn("持续检测不到音频输入,可能麦克风未正常工作");
  1178. silenceCounter = 0;
  1179. }
  1180. }
  1181. requestAnimationFrame(checkAudio);
  1182. };
  1183. checkAudio();
  1184. } catch (e) {
  1185. console.error("音频测试失败:", e);
  1186. }
  1187. },
  1188. // 添加新方法:尝试单独获取音频
  1189. tryGetAudioOnly() {
  1190. navigator.mediaDevices.getUserMedia({ audio: true }).then((audioStream) => {
  1191. if (this.cameraStream) {
  1192. const videoTrack = this.cameraStream.getVideoTracks()[0];
  1193. const audioTrack = audioStream.getAudioTracks()[0];
  1194. const combinedStream = new MediaStream();
  1195. if (videoTrack)
  1196. combinedStream.addTrack(videoTrack);
  1197. if (audioTrack)
  1198. combinedStream.addTrack(audioTrack);
  1199. this.cameraStream = combinedStream;
  1200. const videoElement = this.$refs.userCameraVideo;
  1201. if (videoElement) {
  1202. videoElement.srcObject = combinedStream;
  1203. videoElement.muted = true;
  1204. }
  1205. console.log("成功合并音频和视频轨道");
  1206. } else {
  1207. console.warn("没有视频流可合并");
  1208. }
  1209. }).catch((err) => {
  1210. console.error("单独获取音频失败:", err);
  1211. });
  1212. },
  1213. // 添加新方法:显示权限对话框
  1214. showPermissionDialog(permissionType) {
  1215. common_vendor.index.showModal({
  1216. title: "需要权限",
  1217. content: `请允许使用${permissionType}权限,否则可能影响面试功能`,
  1218. confirmText: "去设置",
  1219. success: (res) => {
  1220. if (res.confirm) {
  1221. common_vendor.index.openSetting({
  1222. success: (settingRes) => {
  1223. console.log("设置页面打开成功", settingRes);
  1224. }
  1225. });
  1226. }
  1227. }
  1228. });
  1229. },
  1230. // 添加重试上传方法
  1231. retryVideoUpload() {
  1232. if (this.lastVideoToRetry) {
  1233. this.showRetryButton = false;
  1234. common_vendor.index.showLoading({
  1235. title: "正在重新提交...",
  1236. mask: true
  1237. });
  1238. this.submitVideoToInterview(this.lastVideoToRetry);
  1239. } else {
  1240. common_vendor.index.showToast({
  1241. title: "没有可重试的视频",
  1242. icon: "none"
  1243. });
  1244. }
  1245. }
  1246. }
  1247. };
  1248. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  1249. return common_vendor.e({
  1250. a: $data.videoUrl,
  1251. b: common_vendor.o((...args) => $options.handleVideoError && $options.handleVideoError(...args)),
  1252. c: common_vendor.o((...args) => $options.handleVideoEnded && $options.handleVideoEnded(...args)),
  1253. d: common_vendor.o((...args) => $options.handleTimeUpdate && $options.handleTimeUpdate(...args)),
  1254. e: $data.currentSubtitle
  1255. }, $data.currentSubtitle ? {
  1256. f: common_vendor.t($data.currentSubtitle)
  1257. } : {}, {
  1258. g: $data.showAnswerButton
  1259. }, $data.showAnswerButton ? {
  1260. h: common_vendor.o((...args) => $options.handleAnswerButtonClick && $options.handleAnswerButtonClick(...args))
  1261. } : {}, {
  1262. i: $data.useMiniProgramCameraComponent
  1263. }, $data.useMiniProgramCameraComponent ? {
  1264. j: common_vendor.o((...args) => $options.handleCameraError && $options.handleCameraError(...args))
  1265. } : {}, {
  1266. k: $data.loading
  1267. }, $data.loading ? {} : {}, {
  1268. l: $data.showDebugInfo
  1269. }, $data.showDebugInfo ? common_vendor.e({
  1270. m: $data.assistantResponse
  1271. }, $data.assistantResponse ? {
  1272. n: common_vendor.t($data.assistantResponse)
  1273. } : {}, {
  1274. o: $data.audioTranscript
  1275. }, $data.audioTranscript ? {
  1276. p: common_vendor.t($data.audioTranscript)
  1277. } : {}, {
  1278. q: common_vendor.f($data.processedResponses, (item, index, i0) => {
  1279. return common_vendor.e({
  1280. a: item.role
  1281. }, item.role ? {
  1282. b: common_vendor.t(item.role)
  1283. } : {}, {
  1284. c: item.transcript
  1285. }, item.transcript ? {
  1286. d: common_vendor.t(item.transcript)
  1287. } : {}, {
  1288. e: index
  1289. });
  1290. })
  1291. }) : {}, {
  1292. r: $data.showStopRecordingButton
  1293. }, $data.showStopRecordingButton ? {
  1294. s: common_vendor.o((...args) => $options.stopRecordingAnswer && $options.stopRecordingAnswer(...args))
  1295. } : {}, {
  1296. t: $data.isRecording
  1297. }, $data.isRecording ? {} : {}, {
  1298. v: $data.showStartRecordingButton
  1299. }, $data.showStartRecordingButton ? {
  1300. w: common_vendor.o((...args) => $options.handleStartRecordingClick && $options.handleStartRecordingClick(...args))
  1301. } : {}, {
  1302. x: $data.showRetryButton
  1303. }, $data.showRetryButton ? {
  1304. y: common_vendor.o((...args) => $options.retryVideoUpload && $options.retryVideoUpload(...args))
  1305. } : {});
  1306. }
  1307. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-464e78c6"]]);
  1308. wx.createPage(MiniProgramPage);