identity-verify.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  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. };
  98. },
  99. mounted() {
  100. this.playDigitalHumanVideo();
  101. this.initCamera();
  102. },
  103. beforeDestroy() {
  104. this.stopUserCamera();
  105. },
  106. methods: {
  107. // 初始化相机
  108. initCamera() {
  109. const systemInfo = common_vendor.index.getSystemInfoSync();
  110. const isMiniProgram = systemInfo.uniPlatform === "mp-weixin" || systemInfo.uniPlatform === "mp-alipay" || systemInfo.uniPlatform === "mp-baidu" || systemInfo.uniPlatform === "mp-toutiao";
  111. this.useMiniProgramCameraComponent = isMiniProgram;
  112. if (isMiniProgram) {
  113. this.$nextTick(() => {
  114. this.cameraContext = common_vendor.index.createCameraContext();
  115. });
  116. } else {
  117. this.startUserCamera();
  118. }
  119. },
  120. // 启动用户摄像头
  121. async startUserCamera() {
  122. try {
  123. const systemInfo = common_vendor.index.getSystemInfoSync();
  124. const isMiniProgram = systemInfo.uniPlatform && systemInfo.uniPlatform.startsWith("mp-");
  125. if (isMiniProgram) {
  126. console.log("小程序环境不支持 getUserMedia API");
  127. return;
  128. }
  129. if (!navigator || !navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
  130. throw new Error("您的浏览器不支持摄像头访问");
  131. }
  132. const stream = await navigator.mediaDevices.getUserMedia({
  133. video: {
  134. width: { ideal: 200 },
  135. height: { ideal: 150 },
  136. facingMode: "user"
  137. // 使用前置摄像头
  138. },
  139. audio: true
  140. // 不需要音频
  141. });
  142. this.cameraStream = stream;
  143. this.$nextTick(() => {
  144. if (this.$refs.userCameraVideo) {
  145. this.$refs.userCameraVideo.srcObject = stream;
  146. }
  147. });
  148. } catch (error) {
  149. console.error("无法访问摄像头:", error);
  150. this.cameraError = error.message;
  151. let errorMessage = "无法访问摄像头,请检查权限设置";
  152. if (error.name === "NotAllowedError" || error.name === "PermissionDeniedError") {
  153. errorMessage = "摄像头访问被拒绝,请在浏览器设置中允许摄像头访问";
  154. } else if (error.name === "NotFoundError" || error.name === "DevicesNotFoundError") {
  155. errorMessage = "未检测到摄像头设备";
  156. } else if (error.name === "NotReadableError" || error.name === "TrackStartError") {
  157. errorMessage = "摄像头可能被其他应用占用";
  158. } else if (error.name === "OverconstrainedError") {
  159. errorMessage = "摄像头不满足指定的要求";
  160. } else if (error.name === "TypeError" || error.message.includes("SSL")) {
  161. errorMessage = "请确保在HTTPS环境下访问";
  162. }
  163. common_vendor.index.showToast({
  164. title: errorMessage,
  165. icon: "none",
  166. duration: 3e3
  167. });
  168. this.handleCameraError(errorMessage);
  169. }
  170. },
  171. // 停止用户摄像头
  172. stopUserCamera() {
  173. if (this.cameraStream) {
  174. this.cameraStream.getTracks().forEach((track) => {
  175. track.stop();
  176. });
  177. this.cameraStream = null;
  178. }
  179. },
  180. async fetchData() {
  181. this.loading = true;
  182. this.assistantResponse = "";
  183. this.audioTranscript = "";
  184. this.processedResponses = [];
  185. try {
  186. const requestTask = common_vendor.index.request({
  187. url: "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
  188. method: "POST",
  189. header: {
  190. "Content-Type": "application/json",
  191. "Authorization": "Bearer sk-9e1ec73a7d97493b8613c63f06b6110c"
  192. },
  193. data: {
  194. "model": "qwen-omni-turbo",
  195. "messages": [
  196. {
  197. "role": "user",
  198. "content": [
  199. {
  200. "type": "input_audio",
  201. "input_audio": {
  202. "data": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250211/tixcef/cherry.wav",
  203. "format": "wav"
  204. }
  205. },
  206. {
  207. "type": "text",
  208. "text": "这段音频在说什么"
  209. }
  210. ]
  211. }
  212. ],
  213. "stream": true,
  214. "stream_options": {
  215. "include_usage": true
  216. },
  217. "modalities": ["text", "audio"],
  218. "audio": { "voice": "Cherry", "format": "wav" }
  219. },
  220. success: (res) => {
  221. console.log("请求成功,响应数据:", res.data);
  222. if (typeof res.data === "string" && res.data.includes("data: {")) {
  223. const chunks = res.data.split("data: ").filter((chunk) => chunk.trim() !== "");
  224. chunks.forEach((chunk) => {
  225. this.handleStreamResponse(chunk);
  226. });
  227. } else {
  228. this.handleStreamResponse(res.data);
  229. }
  230. this.playDigitalHumanVideo();
  231. },
  232. fail: (err) => {
  233. console.error("请求失败:", err);
  234. },
  235. complete: () => {
  236. this.loading = false;
  237. }
  238. });
  239. } catch (error) {
  240. console.error("获取数据失败:", error);
  241. this.loading = false;
  242. }
  243. },
  244. handleStreamResponse(data) {
  245. if (typeof data === "string") {
  246. if (data === "[DONE]")
  247. return;
  248. try {
  249. const cleanData = data.trim();
  250. if (cleanData.startsWith("{") && cleanData.endsWith("}")) {
  251. const jsonData = JSON.parse(cleanData);
  252. this.processStreamChunk(jsonData);
  253. }
  254. } catch (e) {
  255. console.error("解析JSON失败:", e, "原始数据:", data);
  256. }
  257. } else {
  258. this.processStreamChunk(data);
  259. }
  260. },
  261. processStreamChunk(chunk) {
  262. if (chunk.choices && chunk.choices.length > 0) {
  263. const choice = chunk.choices[0];
  264. if (choice.delta && choice.delta.content) {
  265. this.assistantResponse += choice.delta.content;
  266. }
  267. if (choice.delta && choice.delta.audio && choice.delta.audio.transcript) {
  268. this.audioTranscript += choice.delta.audio.transcript;
  269. }
  270. if (choice.delta) {
  271. const result = {};
  272. if (choice.delta.role) {
  273. result.role = choice.delta.role;
  274. }
  275. if (choice.delta.audio && choice.delta.audio.transcript) {
  276. result.transcript = choice.delta.audio.transcript;
  277. }
  278. if (Object.keys(result).length > 0) {
  279. this.processedResponses.push(result);
  280. }
  281. }
  282. }
  283. },
  284. processResponseData() {
  285. this.processedResponses = this.responses.map((item) => {
  286. const result = {};
  287. if (item.delta && item.delta.role) {
  288. result.role = item.delta.role;
  289. }
  290. if (item.delta && item.delta.audio && item.delta.audio.transcript) {
  291. result.transcript = item.delta.audio.transcript;
  292. }
  293. return result;
  294. }).filter((item) => Object.keys(item).length > 0);
  295. },
  296. // 播放数字人视频
  297. playDigitalHumanVideo() {
  298. this.videoUrl = this.videoList[this.currentVideoIndex];
  299. this.videoPlaying = true;
  300. this.$nextTick(() => {
  301. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  302. if (videoContext) {
  303. videoContext.play();
  304. setTimeout(() => {
  305. if (this.videoPlaying && this.$refs.videoPlayer) {
  306. console.log("视频应该正在播放");
  307. } else {
  308. console.log("视频可能未成功播放,尝试替代方案");
  309. this.tryAlternativeVideoPath();
  310. }
  311. }, 1e3);
  312. } else {
  313. console.error("无法创建视频上下文");
  314. this.tryAlternativeVideoPath();
  315. }
  316. });
  317. },
  318. // 修改 tryAlternativeVideoPath 方法
  319. tryAlternativeVideoPath() {
  320. console.log("尝试使用替代路径");
  321. const alternativePaths = [
  322. "./static/demo.mp4",
  323. "../static/demo.mp4",
  324. "static/demo.mp4",
  325. "/static/demo.mp4",
  326. // 添加绝对路径
  327. `${window.location.origin}/static/demo.mp4`
  328. ];
  329. const currentPathIndex = alternativePaths.indexOf(this.videoUrl);
  330. const nextPathIndex = (currentPathIndex + 1) % alternativePaths.length;
  331. this.videoUrl = alternativePaths[nextPathIndex];
  332. console.log("尝试新路径:", this.videoUrl);
  333. this.$nextTick(() => {
  334. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  335. if (videoContext) {
  336. videoContext.stop();
  337. videoContext.play();
  338. setTimeout(() => {
  339. if (nextPathIndex === alternativePaths.length - 1 && !this.videoPlaying) {
  340. console.log("所有路径均失败,尝试使用uni.getVideoInfo检查视频");
  341. this.checkVideoWithAPI();
  342. }
  343. }, 1e3);
  344. }
  345. });
  346. },
  347. // 添加新方法:使用uni API检查视频
  348. checkVideoWithAPI() {
  349. common_vendor.index.getVideoInfo({
  350. src: "/static/demo.mp4",
  351. success: (res) => {
  352. console.log("视频信息获取成功:", res);
  353. this.videoUrl = "/static/demo.mp4";
  354. this.$nextTick(() => {
  355. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  356. if (videoContext) {
  357. videoContext.play();
  358. }
  359. });
  360. },
  361. fail: (err) => {
  362. console.error("视频信息获取失败:", err);
  363. this.fallbackToLocalVideo();
  364. }
  365. });
  366. },
  367. // 添加新方法:回退到本地视频
  368. fallbackToLocalVideo() {
  369. console.log("尝试使用本地视频资源");
  370. const platform = common_vendor.index.getSystemInfoSync().platform;
  371. if (platform === "android" || platform === "ios") {
  372. this.videoUrl = platform === "android" ? "android.resource://package_name/raw/demo" : "file:///assets/demo.mp4";
  373. this.$nextTick(() => {
  374. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  375. if (videoContext) {
  376. videoContext.play();
  377. }
  378. });
  379. } else {
  380. this.videoPlaying = false;
  381. common_vendor.index.showToast({
  382. title: "视频加载失败,显示静态图片",
  383. icon: "none"
  384. });
  385. }
  386. },
  387. // 修改 handleVideoError 方法
  388. handleVideoError(e) {
  389. console.error("视频加载错误:", e);
  390. if (e && e.detail) {
  391. console.error("详细错误信息:", e.detail);
  392. }
  393. common_vendor.index.getFileInfo({
  394. filePath: this.videoUrl.startsWith("/") ? this.videoUrl.substring(1) : this.videoUrl,
  395. success: (res) => {
  396. console.log("文件存在,大小:", res.size);
  397. this.tryDifferentFormat();
  398. },
  399. fail: (err) => {
  400. console.error("文件不存在或无法访问:", err);
  401. this.tryAlternativeVideoPath();
  402. }
  403. });
  404. common_vendor.index.showToast({
  405. title: "视频加载失败,请检查文件是否存在",
  406. icon: "none",
  407. duration: 2e3
  408. });
  409. },
  410. // 添加新方法:尝试不同格式
  411. tryDifferentFormat() {
  412. console.log("尝试不同的视频格式");
  413. const formats = [
  414. { ext: "mp4", mime: "video/mp4" },
  415. { ext: "webm", mime: "video/webm" },
  416. { ext: "ogg", mime: "video/ogg" },
  417. { ext: "mov", mime: "video/quicktime" }
  418. ];
  419. const currentPath = this.videoUrl;
  420. const basePath = currentPath.substring(0, currentPath.lastIndexOf(".")) || "/static/demo";
  421. let nextFormat = formats.find((f) => !currentPath.endsWith(f.ext));
  422. if (nextFormat) {
  423. this.videoUrl = `${basePath}.${nextFormat.ext}`;
  424. console.log("尝试新格式:", this.videoUrl);
  425. this.$nextTick(() => {
  426. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  427. if (videoContext) {
  428. videoContext.stop();
  429. videoContext.play();
  430. }
  431. });
  432. } else {
  433. this.useBuiltInResource();
  434. }
  435. },
  436. // 添加新方法:使用内置资源
  437. useBuiltInResource() {
  438. console.log("尝试使用内置资源");
  439. const platform = common_vendor.index.getSystemInfoSync().platform;
  440. if (platform === "windows") {
  441. process.env.UNI_INPUT_DIR || "";
  442. this.videoUrl = `./static/demo.mp4`;
  443. console.log("Windows平台尝试路径:", this.videoUrl);
  444. } else if (platform === "android" || platform === "ios") {
  445. this.useNativeVideo();
  446. } else {
  447. const baseUrl = window.location.origin;
  448. this.videoUrl = `${baseUrl}/static/demo.mp4`;
  449. console.log("Web平台尝试URL:", this.videoUrl);
  450. }
  451. this.$nextTick(() => {
  452. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  453. if (videoContext) {
  454. videoContext.play();
  455. }
  456. });
  457. },
  458. // 添加新方法:使用原生视频能力
  459. useNativeVideo() {
  460. console.log("尝试使用原生视频能力");
  461. common_vendor.index.chooseVideo({
  462. sourceType: ["album"],
  463. success: (res) => {
  464. this.videoUrl = res.tempFilePath;
  465. this.$nextTick(() => {
  466. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  467. if (videoContext) {
  468. videoContext.play();
  469. }
  470. });
  471. },
  472. fail: () => {
  473. this.videoPlaying = false;
  474. common_vendor.index.showToast({
  475. title: "无法加载视频,显示静态图片",
  476. icon: "none"
  477. });
  478. }
  479. });
  480. },
  481. // 处理视频结束事件
  482. handleVideoEnded() {
  483. console.log("视频播放结束");
  484. this.videoPlaying = false;
  485. this.showAnswerButton = true;
  486. },
  487. // 处理答题按钮点击
  488. handleAnswerButtonClick() {
  489. this.showAnswerButton = false;
  490. this.currentVideoIndex++;
  491. if (this.currentVideoIndex < this.videoList.length) {
  492. this.videoUrl = this.videoList[this.currentVideoIndex];
  493. this.videoPlaying = true;
  494. this.currentSubtitle = "";
  495. this.$nextTick(() => {
  496. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  497. if (videoContext) {
  498. videoContext.play();
  499. }
  500. });
  501. } else {
  502. common_vendor.index.showToast({
  503. title: "面试完成",
  504. icon: "success",
  505. duration: 2e3
  506. });
  507. setTimeout(() => {
  508. common_vendor.index.navigateTo({
  509. url: "/pages/interview-result/interview-result"
  510. });
  511. }, 2e3);
  512. }
  513. },
  514. // 处理相机错误
  515. handleCameraError(e) {
  516. console.error("相机错误:", e);
  517. common_vendor.index.showToast({
  518. title: "相机初始化失败,请检查权限设置",
  519. icon: "none"
  520. });
  521. this.tryFallbackOptions();
  522. },
  523. // 添加新方法:尝试备用选项
  524. tryFallbackOptions() {
  525. const systemInfo = common_vendor.index.getSystemInfoSync();
  526. if (systemInfo.uniPlatform === "mp-weixin" || systemInfo.uniPlatform === "mp-alipay") {
  527. this.useMiniProgramCamera();
  528. } else {
  529. this.showStaticCameraPlaceholder();
  530. }
  531. },
  532. // 添加新方法:使用小程序相机API
  533. useMiniProgramCamera() {
  534. console.log("尝试使用小程序相机组件");
  535. this.useMiniProgramCameraComponent = true;
  536. },
  537. // 添加新方法:显示静态图像
  538. showStaticCameraPlaceholder() {
  539. console.log("显示静态摄像头占位图");
  540. const img = document.createElement("img");
  541. img.src = "/static/images/camera-placeholder.png";
  542. img.className = "static-camera-image";
  543. img.style.width = "100%";
  544. img.style.height = "100%";
  545. img.style.objectFit = "cover";
  546. const container = this.$refs.userCameraVideo.parentNode;
  547. container.appendChild(img);
  548. },
  549. // 处理视频时间更新事件
  550. handleTimeUpdate(e) {
  551. const currentTime = e.target.currentTime;
  552. let currentSubtitles;
  553. if (this.currentVideoIndex === 0) {
  554. currentSubtitles = this.subtitles;
  555. } else if (this.currentVideoIndex === 1) {
  556. currentSubtitles = this.secondVideoSubtitles;
  557. } else if (this.currentVideoIndex === 2) {
  558. currentSubtitles = this.thirdVideoSubtitles;
  559. } else if (this.currentVideoIndex === 3) {
  560. currentSubtitles = this.fourthVideoSubtitles;
  561. } else if (this.currentVideoIndex === 4) {
  562. currentSubtitles = this.fifthVideoSubtitles;
  563. } else if (this.currentVideoIndex === 5) {
  564. currentSubtitles = this.sixthVideoSubtitles;
  565. } else {
  566. currentSubtitles = [];
  567. }
  568. const subtitle = currentSubtitles.find(
  569. (sub) => currentTime >= sub.startTime && currentTime < sub.endTime
  570. );
  571. this.currentSubtitle = subtitle ? subtitle.text : "";
  572. }
  573. }
  574. };
  575. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  576. return common_vendor.e({
  577. a: $data.videoUrl,
  578. b: common_vendor.o((...args) => $options.handleVideoError && $options.handleVideoError(...args)),
  579. c: common_vendor.o((...args) => $options.handleVideoEnded && $options.handleVideoEnded(...args)),
  580. d: common_vendor.o((...args) => $options.handleTimeUpdate && $options.handleTimeUpdate(...args)),
  581. e: $data.currentSubtitle
  582. }, $data.currentSubtitle ? {
  583. f: common_vendor.t($data.currentSubtitle)
  584. } : {}, {
  585. g: $data.showAnswerButton
  586. }, $data.showAnswerButton ? {
  587. h: common_vendor.o((...args) => $options.handleAnswerButtonClick && $options.handleAnswerButtonClick(...args))
  588. } : {}, {
  589. i: $data.useMiniProgramCameraComponent
  590. }, $data.useMiniProgramCameraComponent ? {
  591. j: common_vendor.o((...args) => $options.handleCameraError && $options.handleCameraError(...args))
  592. } : {}, {
  593. k: $data.loading
  594. }, $data.loading ? {} : {}, {
  595. l: $data.showDebugInfo
  596. }, $data.showDebugInfo ? common_vendor.e({
  597. m: $data.assistantResponse
  598. }, $data.assistantResponse ? {
  599. n: common_vendor.t($data.assistantResponse)
  600. } : {}, {
  601. o: $data.audioTranscript
  602. }, $data.audioTranscript ? {
  603. p: common_vendor.t($data.audioTranscript)
  604. } : {}, {
  605. q: common_vendor.f($data.processedResponses, (item, index, i0) => {
  606. return common_vendor.e({
  607. a: item.role
  608. }, item.role ? {
  609. b: common_vendor.t(item.role)
  610. } : {}, {
  611. c: item.transcript
  612. }, item.transcript ? {
  613. d: common_vendor.t(item.transcript)
  614. } : {}, {
  615. e: index
  616. });
  617. })
  618. }) : {});
  619. }
  620. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-464e78c6"]]);
  621. wx.createPage(MiniProgramPage);