identity-verify.js 45 KB

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