identity-verify.js 65 KB

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