identity-verify.js 85 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333
  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: "",
  17. // 修改为空字符串,将通过API获取
  18. showReplayButton: false,
  19. cameraStream: null,
  20. // 存储摄像头流
  21. cameraError: null,
  22. // 存储摄像头错误信息
  23. useMiniProgramCameraComponent: false,
  24. // 添加小程序相机组件标志
  25. cameraContext: null,
  26. // 添加相机上下文
  27. currentSubtitle: "",
  28. currentTranslation: "",
  29. // 添加翻译文本
  30. subtitles: [],
  31. // 修改为空数组,将通过API获取
  32. // 移除硬编码的字幕数组
  33. // secondVideoSubtitles: [...],
  34. // thirdVideoSubtitles: [...],
  35. // 等等...
  36. showAnswerButton: false,
  37. // 控制答题按钮显示
  38. currentVideoIndex: 0,
  39. // 当前播放的视频索引
  40. videoList: [],
  41. // 修改为空数组,将通过API获取
  42. // 其他属性保持不变...
  43. questions: [],
  44. // 添加新属性存储API返回的问题数据
  45. introVideoUrl: "http://121.36.251.245:9000/minlong/tenant_1/general_uploads/880a117c8fcc4196b0d8c0750608d373.mp4",
  46. // 保留介绍视频
  47. isRecording: false,
  48. recordingTimer: null,
  49. showStopRecordingButton: false,
  50. mediaRecorder: null,
  51. recordedChunks: [],
  52. recorder: null,
  53. lastUploadedVideoUrl: "",
  54. showStartRecordingButton: false,
  55. showRetryButton: false,
  56. // 控制重试按钮显示
  57. lastVideoToRetry: null,
  58. // 存储上次失败的视频URL,用于重试
  59. recordingStartTime: null,
  60. // 录制开始时间
  61. recordingTimerCount: 0,
  62. // 录制计时器计数
  63. recordingTimeDisplay: "00:00",
  64. // 格式化的录制时间显示
  65. // 添加上传队列相关数据
  66. uploadQueue: [],
  67. // 存储待上传的视频
  68. isUploading: false,
  69. // 标记是否正在上传
  70. uploadProgress: {},
  71. // 存储每个视频的上传进度
  72. uploadStatus: {},
  73. // 存储每个视频的上传状态
  74. showUploadStatus: false,
  75. // 是否显示上传状态指示器
  76. uploadStatusText: "",
  77. // 上传状态文本
  78. mediaRecorderTimeout: null,
  79. // 用于存储MediaRecorder的超时机制
  80. maxRecordingTime: 300,
  81. // 最大录制时间(秒)- 从60秒改为300秒(5分钟)
  82. remainingTime: 300,
  83. // 剩余录制时间(秒)- 从60秒改为300秒
  84. countdownValue: 10,
  85. // 倒计时数值
  86. showCountdown: false,
  87. // 是否显示倒计时蒙层
  88. countdownTimer: null,
  89. showGif: false,
  90. // 控制是否显示GIF
  91. gifUrl: "",
  92. // GIF图片的URL
  93. globalSocketTask: null,
  94. // 添加全局 WebSocket 连接对象
  95. lowScoreVideoUrl: "https://data.qicai321.com/minlong/latentsync/0530e7f5-1957-422d-8f34-ba4a92608081_result.mp4",
  96. // 低分提示视频URL
  97. showRerecordButton: false,
  98. // 控制重新录制按钮显示
  99. isPlayingLowScoreVideo: false,
  100. // 标记是否正在播放低分提示视频
  101. lowScoreVideoSubtitles: [
  102. {
  103. startTime: 0,
  104. endTime: 10,
  105. // 假设视频长度为10秒,可根据实际情况调整
  106. text: "我未听清楚您在说什么,请您再说一遍!"
  107. }
  108. ],
  109. // 用于存储低分提示视频的字幕
  110. retryCount: 0,
  111. // 添加重试次数计数器
  112. maxRetryAttempts: 2,
  113. // 最大重试次数限制
  114. needPlayLowScoreVideo: false,
  115. // 是否需要播放低分视频
  116. finalRecordingDuration: 0,
  117. // 最终录制时长
  118. historyTime: 0,
  119. // 添加历史时间记录
  120. followUpQuestions: [],
  121. // 存储追问问题数据
  122. currentParentQuestionId: null,
  123. // 当前父问题ID
  124. hasPlayedFollowUp: {},
  125. // 记录已播放的追问,格式: {questionId: true}
  126. isFollowUpQuestion: false,
  127. // 标记当前是否正在播放追问问题
  128. currentFollowUpQuestion: null,
  129. // 添加当前追问问题的完整信息
  130. lastQuestionWasFollowUp: false,
  131. lastFollowUpQuestionId: null,
  132. lastUpdateTime: Date.now(),
  133. // 添加最后更新时间戳
  134. subtitleMap: {},
  135. // 用于存储字幕和翻译的映射
  136. progressPercent: 0,
  137. // 录制进度百分比
  138. progressColor: "#05dc8b",
  139. // 进度条颜色
  140. progressBgColor: "rgba(0, 0, 0,0.3)"
  141. // 进度条背景色
  142. };
  143. },
  144. mounted() {
  145. this.fetchQuestions();
  146. this.fetchFollowUpQuestions();
  147. this.checkAudioPermission();
  148. this.initCamera();
  149. this.checkIOSCameraRecordPermission();
  150. this.checkAndFixRenderingIssues();
  151. setTimeout(() => {
  152. if (this.cameraStream && !this.useMiniProgramCameraComponent) {
  153. this.testAudioInput();
  154. }
  155. }, 3e3);
  156. this.historyTime = 0;
  157. common_vendor.index.setKeepScreenOn({
  158. keepScreenOn: true
  159. });
  160. },
  161. beforeDestroy() {
  162. this.stopUserCamera();
  163. this.clearCountdown();
  164. },
  165. methods: {
  166. // 初始化相机
  167. async initCamera() {
  168. const systemInfo = common_vendor.index.getSystemInfoSync();
  169. const isMiniProgram = systemInfo.uniPlatform === "mp-weixin" || systemInfo.uniPlatform === "mp-alipay" || systemInfo.uniPlatform === "mp-baidu";
  170. if (isMiniProgram) {
  171. this.useMiniProgramCameraComponent = true;
  172. this.cameraContext = common_vendor.index.createCameraContext();
  173. common_vendor.index.getSetting({
  174. success: (res) => {
  175. if (!res.authSetting["scope.record"]) {
  176. common_vendor.index.authorize({
  177. scope: "scope.record",
  178. success: () => {
  179. console.log("录音权限已获取");
  180. },
  181. fail: (err) => {
  182. console.error("录音权限获取失败:", err);
  183. this.showPermissionDialog("录音");
  184. }
  185. });
  186. }
  187. if (!res.authSetting["scope.camera"]) {
  188. common_vendor.index.authorize({
  189. scope: "scope.camera",
  190. success: () => {
  191. console.log("相机权限已获取");
  192. },
  193. fail: (err) => {
  194. console.error("相机权限获取失败:", err);
  195. this.showPermissionDialog("相机");
  196. }
  197. });
  198. }
  199. const systemInfo2 = common_vendor.index.getSystemInfoSync();
  200. if (systemInfo2.platform === "ios") {
  201. if (!res.authSetting["scope.camera"] || !res.authSetting["scope.record"]) {
  202. console.log("iOS需要同时获取相机和录音权限");
  203. }
  204. }
  205. }
  206. });
  207. } else {
  208. try {
  209. const constraints = {
  210. audio: {
  211. echoCancellation: true,
  212. noiseSuppression: true,
  213. autoGainControl: true
  214. },
  215. video: {
  216. width: { ideal: 640, max: 1280 },
  217. // 控制视频宽度
  218. height: { ideal: 480, max: 720 },
  219. // 控制视频高度
  220. frameRate: { ideal: 15, max: 24 },
  221. // 控制帧率
  222. facingMode: "user"
  223. }
  224. };
  225. const stream = await navigator.mediaDevices.getUserMedia(constraints);
  226. this.cameraStream = stream;
  227. const audioTracks = stream.getAudioTracks();
  228. console.log("音频轨道数量:", audioTracks.length);
  229. if (audioTracks.length > 0) {
  230. console.log("音频轨道已获取:", audioTracks[0].label);
  231. audioTracks[0].enabled = true;
  232. } else {
  233. console.warn("未检测到音频轨道,尝试单独获取音频");
  234. this.tryGetAudioOnly();
  235. }
  236. const videoElement = this.$refs.userCameraVideo;
  237. if (videoElement) {
  238. videoElement.srcObject = stream;
  239. videoElement.muted = true;
  240. }
  241. } catch (error) {
  242. console.error("获取摄像头失败:", error);
  243. this.cameraError = error.message || "无法访问摄像头";
  244. common_vendor.index.showToast({
  245. title: "无法访问摄像头,请检查权限设置",
  246. icon: "none"
  247. });
  248. }
  249. }
  250. },
  251. // 停止用户摄像头
  252. stopUserCamera() {
  253. if (this.cameraStream) {
  254. this.cameraStream.getTracks().forEach((track) => {
  255. track.stop();
  256. });
  257. this.cameraStream = null;
  258. }
  259. },
  260. async fetchData() {
  261. this.loading = true;
  262. this.assistantResponse = "";
  263. this.audioTranscript = "";
  264. this.processedResponses = [];
  265. try {
  266. const requestTask = common_vendor.index.request({
  267. url: "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
  268. method: "POST",
  269. header: {
  270. "Content-Type": "application/json",
  271. "Authorization": "Bearer sk-9e1ec73a7d97493b8613c63f06b6110c"
  272. },
  273. data: {
  274. "model": "qwen-omni-turbo",
  275. "messages": [
  276. {
  277. "role": "user",
  278. "content": [
  279. {
  280. "type": "input_audio",
  281. "input_audio": {
  282. "data": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250211/tixcef/cherry.wav",
  283. "format": "wav"
  284. }
  285. },
  286. {
  287. "type": "text",
  288. "text": "这段音频在说什么"
  289. }
  290. ]
  291. }
  292. ],
  293. "stream": true,
  294. "stream_options": {
  295. "include_usage": true
  296. },
  297. "modalities": ["text", "audio"],
  298. "audio": { "voice": "Cherry", "format": "wav" }
  299. },
  300. success: (res) => {
  301. console.log("请求成功,响应数据:", res.data);
  302. if (typeof res.data === "string" && res.data.includes("data: {")) {
  303. const chunks = res.data.split("data: ").filter((chunk) => chunk.trim() !== "");
  304. chunks.forEach((chunk) => {
  305. this.handleStreamResponse(chunk);
  306. });
  307. } else {
  308. this.handleStreamResponse(res.data);
  309. }
  310. this.playDigitalHumanVideo();
  311. },
  312. fail: (err) => {
  313. console.error("请求失败:", err);
  314. },
  315. complete: () => {
  316. this.loading = false;
  317. }
  318. });
  319. } catch (error) {
  320. console.error("获取数据失败:", error);
  321. this.loading = false;
  322. }
  323. },
  324. handleStreamResponse(data) {
  325. if (typeof data === "string") {
  326. if (data === "[DONE]")
  327. return;
  328. try {
  329. const cleanData = data.trim();
  330. if (cleanData.startsWith("{") && cleanData.endsWith("}")) {
  331. const jsonData = JSON.parse(cleanData);
  332. this.processStreamChunk(jsonData);
  333. }
  334. } catch (e) {
  335. console.error("解析JSON失败:", e, "原始数据:", data);
  336. }
  337. } else {
  338. this.processStreamChunk(data);
  339. }
  340. },
  341. processStreamChunk(chunk) {
  342. if (chunk.choices && chunk.choices.length > 0) {
  343. const choice = chunk.choices[0];
  344. if (choice.delta && choice.delta.content) {
  345. this.assistantResponse += choice.delta.content;
  346. }
  347. if (choice.delta && choice.delta.audio && choice.delta.audio.transcript) {
  348. this.audioTranscript += choice.delta.audio.transcript;
  349. }
  350. if (choice.delta) {
  351. const result = {};
  352. if (choice.delta.role) {
  353. result.role = choice.delta.role;
  354. }
  355. if (choice.delta.audio && choice.delta.audio.transcript) {
  356. result.transcript = choice.delta.audio.transcript;
  357. }
  358. if (Object.keys(result).length > 0) {
  359. this.processedResponses.push(result);
  360. }
  361. }
  362. }
  363. },
  364. processResponseData() {
  365. this.processedResponses = this.responses.map((item) => {
  366. const result = {};
  367. if (item.delta && item.delta.role) {
  368. result.role = item.delta.role;
  369. }
  370. if (item.delta && item.delta.audio && item.delta.audio.transcript) {
  371. result.transcript = item.delta.audio.transcript;
  372. }
  373. return result;
  374. }).filter((item) => Object.keys(item).length > 0);
  375. },
  376. // 播放数字人视频
  377. playDigitalHumanVideo() {
  378. if (this.videoList.length === 0) {
  379. this.fetchQuestions();
  380. return;
  381. }
  382. this.videoUrl = this.videoList[this.currentVideoIndex];
  383. this.videoPlaying = true;
  384. this.$nextTick(() => {
  385. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  386. if (videoContext) {
  387. videoContext.play();
  388. setTimeout(() => {
  389. if (this.videoPlaying && this.$refs.videoPlayer) {
  390. console.log("视频应该正在播放");
  391. } else {
  392. console.log("视频可能未成功播放,尝试替代方案");
  393. this.tryAlternativeVideoPath();
  394. }
  395. }, 1e3);
  396. } else {
  397. console.error("无法创建视频上下文");
  398. this.tryAlternativeVideoPath();
  399. }
  400. });
  401. },
  402. // 修改 tryAlternativeVideoPath 方法
  403. tryAlternativeVideoPath() {
  404. console.log("尝试使用替代路径");
  405. const alternativePaths = [
  406. "./static/demo.mp4",
  407. "../static/demo.mp4",
  408. "static/demo.mp4",
  409. "/static/demo.mp4",
  410. // 添加绝对路径
  411. `${window.location.origin}/static/demo.mp4`
  412. ];
  413. const currentPathIndex = alternativePaths.indexOf(this.videoUrl);
  414. const nextPathIndex = (currentPathIndex + 1) % alternativePaths.length;
  415. this.videoUrl = alternativePaths[nextPathIndex];
  416. console.log("尝试新路径:", this.videoUrl);
  417. this.$nextTick(() => {
  418. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  419. if (videoContext) {
  420. videoContext.stop();
  421. videoContext.play();
  422. setTimeout(() => {
  423. if (nextPathIndex === alternativePaths.length - 1 && !this.videoPlaying) {
  424. console.log("所有路径均失败,尝试使用uni.getVideoInfo检查视频");
  425. this.checkVideoWithAPI();
  426. }
  427. }, 1e3);
  428. }
  429. });
  430. },
  431. // 添加新方法:使用uni API检查视频
  432. checkVideoWithAPI() {
  433. common_vendor.index.getVideoInfo({
  434. src: "/static/demo.mp4",
  435. success: (res) => {
  436. console.log("视频信息获取成功:", res);
  437. this.videoUrl = "/static/demo.mp4";
  438. this.$nextTick(() => {
  439. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  440. if (videoContext) {
  441. videoContext.play();
  442. }
  443. });
  444. },
  445. fail: (err) => {
  446. console.error("视频信息获取失败:", err);
  447. this.fallbackToLocalVideo();
  448. }
  449. });
  450. },
  451. // 添加新方法:回退到本地视频
  452. fallbackToLocalVideo() {
  453. console.log("尝试使用本地视频资源");
  454. const platform = common_vendor.index.getSystemInfoSync().platform;
  455. if (platform === "android" || platform === "ios") {
  456. this.videoUrl = platform === "android" ? "android.resource://package_name/raw/demo" : "file:///assets/demo.mp4";
  457. this.$nextTick(() => {
  458. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  459. if (videoContext) {
  460. videoContext.play();
  461. }
  462. });
  463. } else {
  464. this.videoPlaying = false;
  465. common_vendor.index.showToast({
  466. title: "视频加载失败,显示静态图片",
  467. icon: "none"
  468. });
  469. }
  470. },
  471. // 修改 handleVideoError 方法
  472. handleVideoError(e) {
  473. console.error("视频加载错误:", e);
  474. if (e && e.detail) {
  475. console.error("详细错误信息:", e.detail);
  476. }
  477. common_vendor.index.getFileInfo({
  478. filePath: this.videoUrl.startsWith("/") ? this.videoUrl.substring(1) : this.videoUrl,
  479. success: (res) => {
  480. console.log("文件存在,大小:", res.size);
  481. this.tryDifferentFormat();
  482. },
  483. fail: (err) => {
  484. console.error("文件不存在或无法访问:", err);
  485. this.tryAlternativeVideoPath();
  486. }
  487. });
  488. common_vendor.index.showToast({
  489. title: "视频加载失败,请检查文件是否存在",
  490. icon: "none",
  491. duration: 2e3
  492. });
  493. },
  494. // 添加新方法:尝试不同格式
  495. tryDifferentFormat() {
  496. console.log("尝试不同的视频格式");
  497. const formats = [
  498. { ext: "mp4", mime: "video/mp4" },
  499. { ext: "webm", mime: "video/webm" },
  500. { ext: "ogg", mime: "video/ogg" },
  501. { ext: "mov", mime: "video/quicktime" }
  502. ];
  503. const currentPath = this.videoUrl;
  504. const basePath = currentPath.substring(0, currentPath.lastIndexOf(".")) || "/static/demo";
  505. let nextFormat = formats.find((f) => !currentPath.endsWith(f.ext));
  506. if (nextFormat) {
  507. this.videoUrl = `${basePath}.${nextFormat.ext}`;
  508. console.log("尝试新格式:", this.videoUrl);
  509. this.$nextTick(() => {
  510. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  511. if (videoContext) {
  512. videoContext.stop();
  513. videoContext.play();
  514. }
  515. });
  516. } else {
  517. this.useBuiltInResource();
  518. }
  519. },
  520. // 添加新方法:使用内置资源
  521. useBuiltInResource() {
  522. console.log("尝试使用内置资源");
  523. const platform = common_vendor.index.getSystemInfoSync().platform;
  524. if (platform === "windows") {
  525. process.env.UNI_INPUT_DIR || "";
  526. this.videoUrl = `./static/demo.mp4`;
  527. console.log("Windows平台尝试路径:", this.videoUrl);
  528. } else if (platform === "android" || platform === "ios") {
  529. this.useNativeVideo();
  530. } else {
  531. const baseUrl = window.location.origin;
  532. this.videoUrl = `${baseUrl}/static/demo.mp4`;
  533. console.log("Web平台尝试URL:", this.videoUrl);
  534. }
  535. this.$nextTick(() => {
  536. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  537. if (videoContext) {
  538. videoContext.play();
  539. }
  540. });
  541. },
  542. // 添加新方法:使用原生视频能力
  543. useNativeVideo() {
  544. console.log("尝试使用原生视频能力");
  545. common_vendor.index.chooseVideo({
  546. sourceType: ["album"],
  547. success: (res) => {
  548. this.videoUrl = res.tempFilePath;
  549. this.$nextTick(() => {
  550. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  551. if (videoContext) {
  552. videoContext.play();
  553. }
  554. });
  555. },
  556. fail: () => {
  557. this.videoPlaying = false;
  558. common_vendor.index.showToast({
  559. title: "无法加载视频,显示静态图片",
  560. icon: "none"
  561. });
  562. }
  563. });
  564. },
  565. // 处理视频结束事件
  566. handleVideoEnded() {
  567. console.log("视频播放结束事件触发");
  568. const videoElement = this.$refs.videoPlayer;
  569. if (videoElement) {
  570. const currentTime = videoElement.currentTime || 0;
  571. const duration = videoElement.duration || 0;
  572. if (duration > 0 && duration - currentTime > 0.5) {
  573. console.log("检测到可能的误触发结束事件,继续播放", currentTime, duration);
  574. setTimeout(() => {
  575. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  576. if (videoContext) {
  577. if (duration - currentTime > 2) {
  578. videoContext.seek(this.historyTime || 0);
  579. } else {
  580. videoContext.play();
  581. }
  582. }
  583. }, 100);
  584. return;
  585. }
  586. console.log("视频确认结束,当前时间:", currentTime, "总时长:", duration);
  587. }
  588. this.videoPlaying = false;
  589. if (this.isPlayingLowScoreVideo) {
  590. console.log("低分提示视频播放完成");
  591. if (this.retryCount < this.maxRetryAttempts) {
  592. console.log(`显示重新录制按钮 (重试次数: ${this.retryCount + 1}/${this.maxRetryAttempts})`);
  593. this.showRerecordButton = true;
  594. } else {
  595. console.log("已达到最大重试次数,继续下一题");
  596. this.retryCount = 0;
  597. this.proceedToNextQuestion();
  598. }
  599. this.isPlayingLowScoreVideo = false;
  600. this.currentSubtitle = "";
  601. return;
  602. }
  603. if (this.isFollowUpQuestion) {
  604. console.log("追问问题视频播放完成");
  605. this.isFollowUpQuestion = false;
  606. this.showStartRecordingButton = true;
  607. this.startCountdown();
  608. return;
  609. }
  610. if (this.currentVideoIndex >= 1) {
  611. this.showStartRecordingButton = true;
  612. this.startCountdown();
  613. } else {
  614. this.showAnswerButton = true;
  615. }
  616. },
  617. // 添加新方法:开始倒计时
  618. startCountdown() {
  619. this.showCountdown = true;
  620. this.countdownValue = 10;
  621. this.countdownTimer = setInterval(() => {
  622. this.countdownValue--;
  623. if (this.countdownValue <= 0) {
  624. this.clearCountdown();
  625. this.showStartRecordingButton = false;
  626. this.startRecordingAnswer();
  627. }
  628. }, 1e3);
  629. },
  630. // 添加新方法:清除倒计时
  631. clearCountdown() {
  632. if (this.countdownTimer) {
  633. clearInterval(this.countdownTimer);
  634. this.countdownTimer = null;
  635. }
  636. this.showCountdown = false;
  637. },
  638. // 修改 handleStartRecordingClick 方法,使其可以终止倒计时
  639. handleStartRecordingClick() {
  640. this.showStartRecordingButton = false;
  641. this.clearCountdown();
  642. this.startRecordingAnswer();
  643. },
  644. // 修改 stopRecordingAnswer 方法,添加录制时长检查
  645. stopRecordingAnswer() {
  646. this.clearCountdown();
  647. const recordingDuration = this.getRecordingDuration();
  648. const minimumDuration = 3;
  649. const lowScoreDuration = 7;
  650. if (recordingDuration < minimumDuration) {
  651. common_vendor.index.showToast({
  652. title: "录制时间过短,请至少录制3秒",
  653. icon: "none",
  654. duration: 2e3
  655. });
  656. return;
  657. }
  658. this.completeRecordingStop();
  659. if (recordingDuration < lowScoreDuration) {
  660. console.log(`录制时间 ${recordingDuration} 秒,少于 ${lowScoreDuration} 秒,将播放低分提示视频`);
  661. this.needPlayLowScoreVideo = true;
  662. } else {
  663. this.needPlayLowScoreVideo = false;
  664. }
  665. },
  666. // 添加新方法:开始录制用户回答
  667. startRecordingAnswer() {
  668. console.log("开始录制用户回答");
  669. this.isRecording = true;
  670. this.recordingStartTime = Date.now();
  671. this.recordingTimerCount = 0;
  672. this.remainingTime = this.maxRecordingTime;
  673. this.recordingTimer = setInterval(() => {
  674. this.recordingTimerCount++;
  675. this.remainingTime = Math.max(0, this.maxRecordingTime - this.recordingTimerCount);
  676. this.recordingTimeDisplay = this.formatTime(this.recordingTimerCount);
  677. this.progressPercent = this.recordingTimerCount / this.maxRecordingTime * 100;
  678. if (this.recordingTimerCount >= this.maxRecordingTime) {
  679. console.log("已达到最大录制时间(5分钟),自动停止录制");
  680. this.stopRecordingAnswer();
  681. }
  682. }, 1e3);
  683. const systemInfo = common_vendor.index.getSystemInfoSync();
  684. const isMiniProgram = systemInfo.uniPlatform && systemInfo.uniPlatform.startsWith("mp-");
  685. if (isMiniProgram) {
  686. this.startMiniProgramRecording();
  687. } else {
  688. this.startBrowserRecording();
  689. }
  690. this.showStopRecordingButton = true;
  691. },
  692. // 添加一个新方法:重置相机组件
  693. resetCamera() {
  694. console.log("重置相机组件");
  695. this.useMiniProgramCameraComponent = false;
  696. if (this.cameraContext) {
  697. this.cameraContext = null;
  698. }
  699. setTimeout(() => {
  700. this.useMiniProgramCameraComponent = true;
  701. setTimeout(() => {
  702. this.cameraContext = common_vendor.index.createCameraContext();
  703. console.log("相机组件已重置");
  704. }, 500);
  705. }, 500);
  706. },
  707. // 修改 startMiniProgramRecording 方法
  708. startMiniProgramRecording() {
  709. console.log("开始小程序录制方法");
  710. const systemInfo = common_vendor.index.getSystemInfoSync();
  711. const isIOS = systemInfo.platform === "ios";
  712. if (isIOS) {
  713. this.resetCamera();
  714. setTimeout(() => {
  715. this.actualStartRecording(isIOS);
  716. }, 1e3);
  717. } else {
  718. this.actualStartRecording(isIOS);
  719. }
  720. },
  721. // 添加新方法:实际开始录制
  722. actualStartRecording(isIOS) {
  723. if (!this.cameraContext) {
  724. this.cameraContext = common_vendor.index.createCameraContext();
  725. console.log("创建新的相机上下文");
  726. }
  727. common_vendor.index.getSetting({
  728. success: (res) => {
  729. const hasRecordAuth = res.authSetting["scope.record"];
  730. const hasCameraAuth = res.authSetting["scope.camera"];
  731. if (!hasRecordAuth || !hasCameraAuth) {
  732. console.warn("缺少必要权限,请求权限");
  733. this.requestMiniProgramPermissions();
  734. return;
  735. }
  736. if (isIOS) {
  737. console.log("iOS: 检查相机状态");
  738. const options = {
  739. timeout: 3e5,
  740. // 300秒超时 (5分钟)
  741. quality: "low",
  742. // 降低质量
  743. compressed: true,
  744. success: () => {
  745. console.log("iOS录制开始成功");
  746. },
  747. fail: (err) => {
  748. console.error("iOS录制失败:", err);
  749. this.useAlternativeRecordingMethod();
  750. }
  751. };
  752. try {
  753. console.log("尝试开始录制");
  754. this.recorder = this.cameraContext.startRecord(options);
  755. } catch (e) {
  756. console.error("开始录制异常:", e);
  757. this.useAlternativeRecordingMethod();
  758. }
  759. } else {
  760. const options = {
  761. timeout: 3e5,
  762. // 300秒超时 (5分钟)
  763. quality: "medium",
  764. compressed: true,
  765. success: () => {
  766. console.log("Android录制开始成功");
  767. },
  768. fail: (err) => {
  769. console.error("Android录制失败:", err);
  770. common_vendor.index.showToast({
  771. title: "录制失败,请检查相机权限",
  772. icon: "none"
  773. });
  774. this.proceedToNextQuestion();
  775. }
  776. };
  777. this.recorder = this.cameraContext.startRecord(options);
  778. }
  779. }
  780. });
  781. },
  782. // 添加新方法:使用替代录制方法
  783. useAlternativeRecordingMethod() {
  784. console.log("使用替代录制方法");
  785. common_vendor.index.showActionSheet({
  786. itemList: ["使用相册中的视频", "跳过此问题"],
  787. success: (res) => {
  788. if (res.tapIndex === 0) {
  789. common_vendor.index.chooseVideo({
  790. sourceType: ["album"],
  791. maxDuration: 300,
  792. // 从60秒改为300秒
  793. camera: "front",
  794. success: (res2) => {
  795. console.log("选择视频成功:", res2.tempFilePath);
  796. this.isRecording = false;
  797. this.showStopRecordingButton = false;
  798. this.uploadRecordedVideo(res2.tempFilePath);
  799. },
  800. fail: () => {
  801. console.log("用户取消选择视频");
  802. this.proceedToNextQuestion();
  803. }
  804. });
  805. } else {
  806. console.log("用户选择跳过问题");
  807. this.proceedToNextQuestion();
  808. }
  809. },
  810. fail: () => {
  811. console.log("操作取消");
  812. this.proceedToNextQuestion();
  813. }
  814. });
  815. },
  816. // 添加新方法:请求小程序权限
  817. requestMiniProgramPermissions() {
  818. common_vendor.index.authorize({
  819. scope: "scope.record",
  820. success: () => {
  821. console.log("录音权限已获取");
  822. common_vendor.index.authorize({
  823. scope: "scope.camera",
  824. success: () => {
  825. console.log("相机权限已获取");
  826. this.startMiniProgramRecording();
  827. },
  828. fail: (err) => {
  829. console.error("相机权限获取失败:", err);
  830. this.showPermissionDialog("相机");
  831. }
  832. });
  833. },
  834. fail: (err) => {
  835. console.error("录音权限获取失败:", err);
  836. this.showPermissionDialog("录音");
  837. }
  838. });
  839. },
  840. // 修改浏览器环境下的录制方法
  841. startBrowserRecording() {
  842. if (!this.cameraStream) {
  843. console.error("没有可用的摄像头流");
  844. common_vendor.index.showToast({
  845. title: "录制失败,摄像头未就绪",
  846. icon: "none"
  847. });
  848. this.proceedToNextQuestion();
  849. return;
  850. }
  851. try {
  852. const hasAudio = this.cameraStream.getAudioTracks().length > 0;
  853. if (!hasAudio) {
  854. console.warn("警告:媒体流中没有音频轨道,尝试重新获取带音频的媒体流");
  855. navigator.mediaDevices.getUserMedia({
  856. audio: {
  857. echoCancellation: true,
  858. noiseSuppression: true,
  859. autoGainControl: true
  860. },
  861. video: true
  862. }).then((newStream) => {
  863. const audioTracks = newStream.getAudioTracks();
  864. if (audioTracks.length > 0) {
  865. console.log("成功获取音频轨道:", audioTracks[0].label);
  866. const videoTrack = this.cameraStream.getVideoTracks()[0];
  867. const audioTrack = newStream.getAudioTracks()[0];
  868. const combinedStream = new MediaStream();
  869. if (videoTrack)
  870. combinedStream.addTrack(videoTrack);
  871. if (audioTrack)
  872. combinedStream.addTrack(audioTrack);
  873. this.cameraStream = combinedStream;
  874. const videoElement = this.$refs.userCameraVideo;
  875. if (videoElement) {
  876. videoElement.srcObject = combinedStream;
  877. videoElement.muted = true;
  878. }
  879. this.setupMediaRecorder(combinedStream);
  880. } else {
  881. console.warn("仍然无法获取音频轨道");
  882. this.setupMediaRecorder(this.cameraStream);
  883. }
  884. }).catch((err) => {
  885. console.error("获取音频失败:", err);
  886. this.setupMediaRecorder(this.cameraStream);
  887. });
  888. } else {
  889. console.log("检测到音频轨道,直接使用");
  890. this.setupMediaRecorder(this.cameraStream);
  891. }
  892. } catch (error) {
  893. console.error("浏览器录制失败:", error);
  894. common_vendor.index.showToast({
  895. title: "录制失败,浏览器可能不支持此功能",
  896. icon: "none"
  897. });
  898. this.proceedToNextQuestion();
  899. }
  900. },
  901. // 修改 setupMediaRecorder 方法
  902. setupMediaRecorder(stream) {
  903. const videoTracks = stream.getVideoTracks();
  904. const audioTracks = stream.getAudioTracks();
  905. console.log("设置MediaRecorder - 视频轨道:", videoTracks.length, "音频轨道:", audioTracks.length);
  906. let mimeType = "";
  907. const supportedTypes = [
  908. "video/webm;codecs=vp9,opus",
  909. "video/webm;codecs=vp8,opus",
  910. "video/webm;codecs=h264,opus",
  911. "video/mp4;codecs=h264,aac",
  912. "video/webm",
  913. "video/mp4"
  914. ];
  915. for (const type of supportedTypes) {
  916. if (MediaRecorder.isTypeSupported(type)) {
  917. mimeType = type;
  918. console.log("使用支持的MIME类型:", mimeType);
  919. break;
  920. }
  921. }
  922. const options = {
  923. mimeType: mimeType || "",
  924. audioBitsPerSecond: 64e3,
  925. // 降低音频比特率
  926. videoBitsPerSecond: 1e6
  927. // 降低视频比特率到1Mbps
  928. };
  929. try {
  930. this.mediaRecorder = new MediaRecorder(stream, options);
  931. console.log("MediaRecorder创建成功,使用选项:", options);
  932. } catch (e) {
  933. console.warn("使用指定选项创建MediaRecorder失败,尝试使用默认选项");
  934. this.mediaRecorder = new MediaRecorder(stream);
  935. }
  936. this.recordedChunks = [];
  937. this.mediaRecorder.ondataavailable = (event) => {
  938. if (event.data && event.data.size > 0) {
  939. this.recordedChunks.push(event.data);
  940. console.log(`收到数据块: ${event.data.size} 字节`);
  941. }
  942. };
  943. this.mediaRecorder.onstop = async () => {
  944. console.log("MediaRecorder停止,数据块数量:", this.recordedChunks.length);
  945. if (this.recordedChunks.length === 0) {
  946. console.error("没有录制到数据");
  947. common_vendor.index.showToast({
  948. title: "录制失败,未捕获到数据",
  949. icon: "none"
  950. });
  951. this.proceedToNextQuestion();
  952. return;
  953. }
  954. const mimeType2 = this.mediaRecorder.mimeType || "video/webm";
  955. const blob = new Blob(this.recordedChunks, { type: mimeType2 });
  956. console.log("创建Blob,原始大小:", blob.size, "类型:", mimeType2);
  957. common_vendor.index.showLoading({
  958. title: "正在处理视频...",
  959. mask: true
  960. });
  961. try {
  962. const compressedBlob = await this.compressVideo(blob);
  963. const fileName = `answer_${this.currentVideoIndex}_${Date.now()}.webm`;
  964. const file = new File([compressedBlob], fileName, { type: mimeType2 });
  965. common_vendor.index.hideLoading();
  966. this.uploadRecordedVideo(file);
  967. } catch (error) {
  968. console.error("视频处理失败:", error);
  969. common_vendor.index.hideLoading();
  970. const fileName = `answer_${this.currentVideoIndex}_${Date.now()}.webm`;
  971. const file = new File([blob], fileName, { type: mimeType2 });
  972. this.uploadRecordedVideo(file);
  973. }
  974. };
  975. this.mediaRecorder.onerror = (event) => {
  976. console.error("MediaRecorder错误:", event.error);
  977. };
  978. try {
  979. this.mediaRecorder.start(1e3);
  980. console.log("MediaRecorder开始录制");
  981. this.mediaRecorderTimeout = setTimeout(() => {
  982. if (this.mediaRecorder && this.mediaRecorder.state === "recording") {
  983. console.log("MediaRecorder备份超时机制触发,停止录制");
  984. this.mediaRecorder.stop();
  985. }
  986. }, 3e5);
  987. } catch (e) {
  988. console.error("开始录制失败:", e);
  989. }
  990. },
  991. // 添加新方法:停止录制用户回答
  992. stopRecordingAnswer() {
  993. console.log("停止录制用户回答");
  994. if (this.countdownTimer) {
  995. clearInterval(this.countdownTimer);
  996. this.countdownTimer = null;
  997. this.showCountdown = false;
  998. }
  999. const recordingDuration = this.getRecordingDuration();
  1000. const minimumDuration = 3;
  1001. const lowScoreDuration = 7;
  1002. if (recordingDuration < minimumDuration) {
  1003. common_vendor.index.showToast({
  1004. title: "录制时间过短,请至少录制3秒",
  1005. icon: "none",
  1006. duration: 2e3
  1007. });
  1008. return;
  1009. }
  1010. this.completeRecordingStop();
  1011. if (recordingDuration < lowScoreDuration) {
  1012. console.log(`录制时间 ${recordingDuration} 秒,少于 ${lowScoreDuration} 秒,将播放低分提示视频`);
  1013. this.needPlayLowScoreVideo = true;
  1014. } else {
  1015. this.needPlayLowScoreVideo = false;
  1016. }
  1017. },
  1018. // 添加新方法:获取录制时长
  1019. getRecordingDuration() {
  1020. if (this.recordingStartTime) {
  1021. return (Date.now() - this.recordingStartTime) / 1e3;
  1022. }
  1023. if (this.mediaRecorder && this.$refs.userCameraVideo) {
  1024. return this.$refs.userCameraVideo.currentTime || 0;
  1025. }
  1026. if (this.recordingTimerCount) {
  1027. return this.recordingTimerCount;
  1028. }
  1029. return 0;
  1030. },
  1031. // 添加新方法:重置录制
  1032. resetRecording() {
  1033. if (this.recordingTimer) {
  1034. clearTimeout(this.recordingTimer);
  1035. }
  1036. this.recordingStartTime = Date.now();
  1037. this.recordingTimerCount = 0;
  1038. if (this.mediaRecorder && this.mediaRecorder.state !== "inactive") {
  1039. this.mediaRecorder.stop();
  1040. this.recordedChunks = [];
  1041. setTimeout(() => {
  1042. this.startBrowserRecording();
  1043. }, 500);
  1044. } else if (this.cameraContext) {
  1045. this.cameraContext.stopRecord({
  1046. success: () => {
  1047. console.log("相机录制已停止");
  1048. },
  1049. fail: (err) => {
  1050. console.error("停止相机录制失败:", err);
  1051. }
  1052. });
  1053. }
  1054. common_vendor.index.showToast({
  1055. title: "请重新开始回答",
  1056. icon: "none",
  1057. duration: 2e3
  1058. });
  1059. },
  1060. // 修改 completeRecordingStop 方法,确保正确处理追问问题ID
  1061. completeRecordingStop() {
  1062. console.log("完成录制停止");
  1063. if (this.recordingTimer) {
  1064. clearInterval(this.recordingTimer);
  1065. this.recordingTimer = null;
  1066. }
  1067. this.finalRecordingDuration = this.recordingTimerCount;
  1068. this.showStopRecordingButton = false;
  1069. this.isRecording = false;
  1070. const systemInfo = common_vendor.index.getSystemInfoSync();
  1071. const isMiniProgram = systemInfo.uniPlatform && systemInfo.uniPlatform.startsWith("mp-");
  1072. if (isMiniProgram) {
  1073. this.stopMiniProgramRecording();
  1074. } else {
  1075. this.stopBrowserRecording();
  1076. }
  1077. if (this.isFollowUpQuestion && this.currentFollowUpQuestion) {
  1078. console.log("当前是追问问题,记录追问问题ID:", this.currentFollowUpQuestion.id);
  1079. this.lastQuestionWasFollowUp = true;
  1080. this.lastFollowUpQuestionId = this.currentFollowUpQuestion.id;
  1081. } else {
  1082. this.lastQuestionWasFollowUp = false;
  1083. this.lastFollowUpQuestionId = null;
  1084. }
  1085. },
  1086. // 修改 stopMiniProgramRecording 方法,确保正确传递追问问题ID
  1087. stopMiniProgramRecording() {
  1088. console.log("停止小程序录制");
  1089. if (!this.cameraContext) {
  1090. console.error("相机上下文不存在");
  1091. this.proceedToNextQuestion();
  1092. return;
  1093. }
  1094. this.cameraContext.stopRecord({
  1095. success: (res) => {
  1096. console.log("小程序录制停止成功:", res);
  1097. const videoPath = res.tempVideoPath;
  1098. if (videoPath) {
  1099. this.uploadRecordedVideo(videoPath);
  1100. } else {
  1101. console.error("未获取到录制视频路径");
  1102. this.proceedToNextQuestion();
  1103. }
  1104. },
  1105. fail: (err) => {
  1106. console.error("小程序录制停止失败:", err);
  1107. this.proceedToNextQuestion();
  1108. }
  1109. });
  1110. },
  1111. // 添加新方法:停止浏览器录制
  1112. stopBrowserRecording() {
  1113. if (this.mediaRecorder && this.mediaRecorder.state !== "inactive") {
  1114. this.mediaRecorder.stop();
  1115. console.log("浏览器录制停止成功");
  1116. } else {
  1117. console.error("MediaRecorder不存在或已经停止");
  1118. this.proceedToNextQuestion();
  1119. }
  1120. },
  1121. // 修改 uploadRecordedVideo 方法,添加记录父问题ID的逻辑
  1122. uploadRecordedVideo(fileOrPath) {
  1123. console.log("准备上传视频:", typeof fileOrPath === "string" ? fileOrPath : fileOrPath.name);
  1124. console.log("当前问题ID:", this.currentParentQuestionId);
  1125. console.log("当前问题类型:", this.isFollowUpQuestion);
  1126. console.log("当前追问问题:", this.currentFollowUpQuestion);
  1127. let questionId;
  1128. let isFollowUpQuestionUpload = false;
  1129. let questionText = "";
  1130. let questionForm = 0;
  1131. if (this.currentFollowUpQuestion && (this.currentFollowUpQuestion.question_form === 5 || this.isFollowUpQuestion)) {
  1132. questionId = this.currentFollowUpQuestion.id;
  1133. isFollowUpQuestionUpload = true;
  1134. questionText = this.currentFollowUpQuestion.question || "";
  1135. questionForm = 5;
  1136. console.log("正在上传追问问题的回答:", {
  1137. questionId,
  1138. questionText,
  1139. questionForm,
  1140. isFollowUp: true
  1141. });
  1142. } else {
  1143. const currentQuestion = this.getCurrentQuestionByIndex(this.currentVideoIndex);
  1144. if (currentQuestion && currentQuestion.id) {
  1145. questionId = currentQuestion.id;
  1146. questionText = currentQuestion.question || "";
  1147. console.log("正在上传常规问题的回答:", {
  1148. questionId,
  1149. questionText,
  1150. questionForm: 0
  1151. });
  1152. } else {
  1153. questionId = this.getDefaultQuestionId(this.currentVideoIndex);
  1154. console.log("使用默认问题ID:", questionId);
  1155. }
  1156. }
  1157. const uploadTask = {
  1158. id: Date.now().toString(),
  1159. file: fileOrPath,
  1160. questionId,
  1161. isFollowUp: isFollowUpQuestionUpload,
  1162. questionText,
  1163. questionForm,
  1164. attempts: 0,
  1165. maxAttempts: 3,
  1166. parentQuestionId: this.currentParentQuestionId
  1167. // 添加父问题ID
  1168. };
  1169. if (!isFollowUpQuestionUpload) {
  1170. this.currentParentQuestionId = questionId;
  1171. }
  1172. this.uploadQueue.push(uploadTask);
  1173. this.uploadProgress[uploadTask.id] = 0;
  1174. this.uploadStatus[uploadTask.id] = "pending";
  1175. common_vendor.index.showToast({
  1176. title: "已完成回答",
  1177. icon: "none",
  1178. duration: 1500
  1179. });
  1180. this.updateUploadStatusText();
  1181. if (!this.isUploading) {
  1182. this.processUploadQueue();
  1183. }
  1184. this.handlePostUploadActions(uploadTask);
  1185. },
  1186. // 添加新方法:处理上传后的逻辑
  1187. handlePostUploadActions(task) {
  1188. if (this.needPlayLowScoreVideo && this.retryCount < 1) {
  1189. this.playLowScoreVideo();
  1190. this.needPlayLowScoreVideo = false;
  1191. } else {
  1192. if (task.isFollowUp) {
  1193. console.log("追问问题回答完成,进入下一个问题");
  1194. this.retryCount = 0;
  1195. this.isFollowUpQuestion = false;
  1196. this.currentFollowUpQuestion = null;
  1197. this.proceedToNextQuestion();
  1198. } else {
  1199. this.currentParentQuestionId = task.questionId;
  1200. console.log("检查常规问题的追问,父问题ID:", this.currentParentQuestionId);
  1201. this.checkAndPlayFollowUpQuestion(this.currentParentQuestionId);
  1202. }
  1203. }
  1204. },
  1205. // 修改 processUploadQueue 方法
  1206. processUploadQueue() {
  1207. if (this.uploadQueue.length === 0) {
  1208. this.isUploading = false;
  1209. this.showUploadStatus = false;
  1210. return;
  1211. }
  1212. this.isUploading = true;
  1213. this.showUploadStatus = true;
  1214. const task = this.uploadQueue[0];
  1215. this.uploadStatus[task.id] = "uploading";
  1216. this.updateUploadStatusText();
  1217. task.attempts++;
  1218. if (typeof task.file === "string") {
  1219. this.uploadFileWithUni(task);
  1220. } else {
  1221. this.uploadFileWithXHR(task);
  1222. }
  1223. },
  1224. // 添加新方法:使用XMLHttpRequest上传文件
  1225. uploadFileWithXHR(task) {
  1226. const userInfo = common_vendor.index.getStorageSync("userInfo");
  1227. const openid = userInfo ? JSON.parse(userInfo).openid || "" : "";
  1228. const tenant_id = JSON.parse(common_vendor.index.getStorageSync("userInfo")).tenant_id || "1";
  1229. const formData = new FormData();
  1230. formData.append("file", task.file);
  1231. formData.append("openid", openid);
  1232. formData.append("tenant_id", tenant_id);
  1233. formData.append("application_id", common_vendor.index.getStorageSync("appId"));
  1234. formData.append("question_id", task.questionId);
  1235. formData.append("video_duration", 0);
  1236. formData.append("has_audio", "true");
  1237. const xhr = new XMLHttpRequest();
  1238. xhr.open("POST", `${common_config.apiBaseUrl}/api/upload/`, true);
  1239. xhr.timeout = 12e4;
  1240. xhr.upload.onprogress = (event) => {
  1241. if (event.lengthComputable) {
  1242. const percentComplete = Math.round(event.loaded / event.total * 100);
  1243. this.uploadProgress[task.id] = percentComplete;
  1244. this.updateUploadStatusText();
  1245. }
  1246. };
  1247. xhr.onload = () => {
  1248. if (xhr.status === 200) {
  1249. try {
  1250. const res = JSON.parse(xhr.responseText);
  1251. console.log("上传响应:", res);
  1252. if (res.code === 2e3) {
  1253. const videoUrl = res.data.url || res.data.photoUrl || "";
  1254. if (videoUrl) {
  1255. this.uploadStatus[task.id] = "success";
  1256. this.updateUploadStatusText();
  1257. this.submitVideoToInterview(videoUrl, task);
  1258. } else {
  1259. this.handleUploadFailure(task, "视频URL获取失败");
  1260. }
  1261. } else {
  1262. this.handleUploadFailure(task, res.msg || "上传失败");
  1263. }
  1264. } catch (e) {
  1265. this.handleUploadFailure(task, "解析响应失败");
  1266. }
  1267. } else {
  1268. this.handleUploadFailure(task, "HTTP状态: " + xhr.status);
  1269. }
  1270. };
  1271. xhr.onerror = () => {
  1272. this.handleUploadFailure(task, "网络错误");
  1273. };
  1274. xhr.ontimeout = () => {
  1275. this.handleUploadFailure(task, "上传超时");
  1276. };
  1277. xhr.send(formData);
  1278. },
  1279. // 添加新方法:使用uni.uploadFile上传文件
  1280. uploadFileWithUni(task) {
  1281. const userInfo = common_vendor.index.getStorageSync("userInfo");
  1282. const openid = userInfo ? JSON.parse(userInfo).openid || "" : "";
  1283. const tenant_id = JSON.parse(common_vendor.index.getStorageSync("userInfo")).tenant_id || "1";
  1284. const uploadTask = common_vendor.index.uploadFile({
  1285. url: `${common_config.apiBaseUrl}/api/upload/`,
  1286. filePath: task.file,
  1287. name: "file",
  1288. formData: {
  1289. openid,
  1290. tenant_id,
  1291. application_id: common_vendor.index.getStorageSync("appId"),
  1292. question_id: task.questionId,
  1293. video_duration: 0,
  1294. has_audio: "true"
  1295. },
  1296. success: (uploadRes) => {
  1297. try {
  1298. const res = JSON.parse(uploadRes.data);
  1299. console.log("上传响应:", res);
  1300. if (res.code === 2e3) {
  1301. const videoUrl = res.data.permanent_link || res.data.url || "";
  1302. if (videoUrl) {
  1303. this.uploadStatus[task.id] = "success";
  1304. this.updateUploadStatusText();
  1305. this.submitVideoToInterview(videoUrl, task);
  1306. } else {
  1307. this.handleUploadFailure(task, "视频URL获取失败");
  1308. }
  1309. } else {
  1310. this.handleUploadFailure(task, res.msg || "上传失败");
  1311. }
  1312. } catch (e) {
  1313. this.handleUploadFailure(task, "解析响应失败");
  1314. }
  1315. },
  1316. fail: (err) => {
  1317. this.handleUploadFailure(task, err.errMsg || "上传失败");
  1318. }
  1319. });
  1320. uploadTask.onProgressUpdate((res) => {
  1321. this.uploadProgress[task.id] = res.progress;
  1322. this.updateUploadStatusText();
  1323. });
  1324. },
  1325. // 添加新方法:处理上传失败
  1326. handleUploadFailure(task, errorMsg) {
  1327. console.error("上传失败:", errorMsg);
  1328. this.uploadStatus[task.id] = "failed";
  1329. this.updateUploadStatusText();
  1330. if (task.attempts < task.maxAttempts) {
  1331. console.log(`将在5秒后重试上传,当前尝试次数: ${task.attempts}/${task.maxAttempts}`);
  1332. setTimeout(() => {
  1333. this.uploadProgress[task.id] = 0;
  1334. if (typeof task.file !== "string") {
  1335. this.uploadFileWithXHR(task);
  1336. } else {
  1337. this.uploadFileWithUni(task);
  1338. }
  1339. }, 5e3);
  1340. } else {
  1341. console.log("超过最大重试次数,放弃上传");
  1342. common_vendor.index.showToast({
  1343. title: "视频上传失败,请稍后重试",
  1344. icon: "none",
  1345. duration: 2e3
  1346. });
  1347. this.uploadQueue.shift();
  1348. this.processUploadQueue();
  1349. }
  1350. },
  1351. // 修改 submitVideoToInterview 方法
  1352. submitVideoToInterview(videoUrl, task) {
  1353. const requestData = {
  1354. application_id: common_vendor.index.getStorageSync("appId"),
  1355. question_id: task.questionId,
  1356. video_url: videoUrl,
  1357. tenant_id: JSON.parse(common_vendor.index.getStorageSync("userInfo")).tenant_id || "1",
  1358. is_follow_up: task.isFollowUp ? 1 : 0,
  1359. question_form: task.questionForm,
  1360. question_text: task.questionText
  1361. };
  1362. common_vendor.index.request({
  1363. url: `${common_config.apiBaseUrl}/api/job/upload_video`,
  1364. method: "POST",
  1365. data: requestData,
  1366. header: {
  1367. "content-type": "application/x-www-form-urlencoded"
  1368. },
  1369. success: (res) => {
  1370. if (res.data.code === 200 || res.data.code === 2e3) {
  1371. this.uploadQueue.shift();
  1372. this.processUploadQueue();
  1373. } else {
  1374. this.handleUploadError(task, "提交失败: " + (res.data.msg || "未知错误"));
  1375. }
  1376. },
  1377. fail: (err) => {
  1378. this.handleUploadError(task, "网络错误: " + err.errMsg);
  1379. }
  1380. });
  1381. },
  1382. // 添加新方法:处理提交失败
  1383. handleSubmitFailure(task, errorMsg) {
  1384. console.error("提交失败:", errorMsg);
  1385. this.uploadStatus[task.id] = "failed";
  1386. this.updateUploadStatusText();
  1387. if (task.attempts < task.maxAttempts) {
  1388. console.log(`将在5秒后重试提交,当前尝试次数: ${task.attempts}/${task.maxAttempts}`);
  1389. setTimeout(() => {
  1390. this.submitVideoToInterview(task.videoUrl, task);
  1391. }, 5e3);
  1392. } else {
  1393. console.log("超过最大重试次数,放弃提交");
  1394. common_vendor.index.showToast({
  1395. title: "视频提交失败,请稍后重试",
  1396. icon: "none",
  1397. duration: 2e3
  1398. });
  1399. this.uploadQueue.shift();
  1400. this.processUploadQueue();
  1401. }
  1402. },
  1403. // 添加新方法:更新上传状态文本
  1404. updateUploadStatusText() {
  1405. if (this.uploadQueue.length === 0) {
  1406. this.uploadStatusText = "";
  1407. return;
  1408. }
  1409. const currentTask = this.uploadQueue[0];
  1410. const progress = this.uploadProgress[currentTask.id] || 0;
  1411. const status = this.uploadStatus[currentTask.id] || "pending";
  1412. let statusText = "";
  1413. switch (status) {
  1414. case "pending":
  1415. statusText = "等待上传";
  1416. break;
  1417. case "uploading":
  1418. statusText = `上传中 ${progress}%`;
  1419. break;
  1420. case "success":
  1421. statusText = "上传成功,提交中...";
  1422. break;
  1423. case "failed":
  1424. statusText = `上传失败,${currentTask.attempts < currentTask.maxAttempts ? "即将重试" : "已放弃"}`;
  1425. break;
  1426. }
  1427. const questionTypeText = currentTask.isFollowUp ? "追问" : "问题";
  1428. const questionShortText = currentTask.questionText ? currentTask.questionText.length > 10 ? currentTask.questionText.substring(0, 10) + "..." : currentTask.questionText : `${questionTypeText}${currentTask.questionId}`;
  1429. this.uploadStatusText = `${questionTypeText}「${questionShortText}」:${statusText}`;
  1430. if (this.uploadQueue.length > 1) {
  1431. this.uploadStatusText += ` (${this.uploadQueue.length}个视频待处理)`;
  1432. }
  1433. },
  1434. // 修改 proceedToNextQuestion 方法,确保在切换视频时重置历史时间
  1435. proceedToNextQuestion() {
  1436. console.log("继续下一个问题");
  1437. this.currentVideoIndex++;
  1438. this.historyTime = 0;
  1439. if (this.currentVideoIndex < this.videoList.length) {
  1440. this.videoUrl = this.videoList[this.currentVideoIndex];
  1441. this.videoPlaying = true;
  1442. this.$nextTick(() => {
  1443. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  1444. if (videoContext) {
  1445. videoContext.play();
  1446. }
  1447. });
  1448. } else {
  1449. console.log("所有视频已播放完毕");
  1450. this.stopUserCamera();
  1451. this.clearCountdown();
  1452. setTimeout(() => {
  1453. common_vendor.index.navigateTo({
  1454. url: "/pages/camera/camera",
  1455. success: () => {
  1456. console.log("成功跳转到camera页面");
  1457. },
  1458. fail: (err) => {
  1459. console.error("跳转到camera页面失败:", err);
  1460. common_vendor.index.redirectTo({
  1461. url: "/pages/camera/camera",
  1462. fail: (redirectErr) => {
  1463. console.error("重定向到camera页面也失败:", redirectErr);
  1464. common_vendor.index.switchTab({
  1465. url: "/pages/camera/camera",
  1466. fail: (switchErr) => {
  1467. console.error("所有跳转方式都失败:", switchErr);
  1468. common_vendor.index.navigateBack({
  1469. delta: 1
  1470. });
  1471. }
  1472. });
  1473. }
  1474. });
  1475. }
  1476. });
  1477. }, 2e3);
  1478. }
  1479. },
  1480. // 修改 handleAnswerButtonClick 方法,确保在切换视频时重置历史时间
  1481. handleAnswerButtonClick() {
  1482. console.log("点击开始回答按钮");
  1483. this.showAnswerButton = false;
  1484. this.currentVideoIndex++;
  1485. this.historyTime = 0;
  1486. if (this.currentVideoIndex < this.videoList.length) {
  1487. this.videoUrl = this.videoList[this.currentVideoIndex];
  1488. this.videoPlaying = true;
  1489. this.$nextTick(() => {
  1490. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  1491. if (videoContext) {
  1492. videoContext.play();
  1493. }
  1494. });
  1495. }
  1496. },
  1497. // 处理相机错误
  1498. handleCameraError(e) {
  1499. console.error("相机错误:", e);
  1500. const systemInfo = common_vendor.index.getSystemInfoSync();
  1501. const isIOS = systemInfo.platform === "ios";
  1502. if (isIOS) {
  1503. console.log("iOS相机错误,尝试重新初始化");
  1504. common_vendor.index.showToast({
  1505. title: "相机初始化中...",
  1506. icon: "loading",
  1507. duration: 2e3
  1508. });
  1509. this.resetCamera();
  1510. if (this.isRecording) {
  1511. this.isRecording = false;
  1512. this.showStopRecordingButton = false;
  1513. setTimeout(() => {
  1514. this.useAlternativeRecordingMethod();
  1515. }, 1e3);
  1516. }
  1517. } else {
  1518. common_vendor.index.showToast({
  1519. title: "相机初始化失败,请检查权限设置",
  1520. icon: "none"
  1521. });
  1522. this.tryFallbackOptions();
  1523. }
  1524. },
  1525. // 添加新方法:尝试备用选项
  1526. tryFallbackOptions() {
  1527. const systemInfo = common_vendor.index.getSystemInfoSync();
  1528. if (systemInfo.uniPlatform === "mp-weixin" || systemInfo.uniPlatform === "mp-alipay") {
  1529. this.useMiniProgramCamera();
  1530. } else {
  1531. this.showStaticCameraPlaceholder();
  1532. }
  1533. },
  1534. // 添加新方法:使用小程序相机API
  1535. useMiniProgramCamera() {
  1536. console.log("尝试使用小程序相机组件");
  1537. this.useMiniProgramCameraComponent = true;
  1538. },
  1539. // 添加新方法:显示静态图像
  1540. showStaticCameraPlaceholder() {
  1541. console.log("显示静态摄像头占位图");
  1542. const img = document.createElement("img");
  1543. img.src = "/static/images/camera-placeholder.png";
  1544. img.className = "static-camera-image";
  1545. img.style.width = "100%";
  1546. img.style.height = "100%";
  1547. img.style.objectFit = "cover";
  1548. const container = this.$refs.userCameraVideo.parentNode;
  1549. container.appendChild(img);
  1550. },
  1551. // 修改 handleTimeUpdate 方法
  1552. handleTimeUpdate(e) {
  1553. const currentTime = e.detail.currentTime || e.target.currentTime;
  1554. if (this.isRecording && this.recordingTimerCount) {
  1555. this.recordingTimeDisplay = this.formatTime(this.recordingTimerCount);
  1556. }
  1557. if (this.isPlayingLowScoreVideo) {
  1558. if (this.lowScoreVideoSubtitles && this.lowScoreVideoSubtitles.length > 0) {
  1559. const subtitle = this.lowScoreVideoSubtitles[0];
  1560. this.currentSubtitle = subtitle.text;
  1561. }
  1562. return;
  1563. }
  1564. let currentSubtitles = null;
  1565. if (this.isFollowUpQuestion && this.currentFollowUpQuestion) {
  1566. const subtitleKey = `followUpSubtitles_${this.currentFollowUpQuestion.id}`;
  1567. currentSubtitles = this[subtitleKey] || [{
  1568. startTime: 0,
  1569. endTime: 30,
  1570. text: this.currentFollowUpQuestion.digital_human_video_subtitle || this.currentFollowUpQuestion.question
  1571. }];
  1572. } else {
  1573. if (this.currentVideoIndex === 0) {
  1574. currentSubtitles = this.subtitles;
  1575. } else {
  1576. const subtitleArrayName = `question${this.currentVideoIndex}Subtitles`;
  1577. currentSubtitles = this[subtitleArrayName];
  1578. }
  1579. }
  1580. if (currentSubtitles && currentSubtitles.length > 0) {
  1581. const subtitle = currentSubtitles.find(
  1582. (sub) => currentTime >= sub.startTime && currentTime <= sub.endTime
  1583. ) || currentSubtitles[0];
  1584. if (subtitle) {
  1585. this.currentSubtitle = subtitle.text;
  1586. }
  1587. }
  1588. this.historyTime = currentTime;
  1589. this.lastUpdateTime = Date.now();
  1590. },
  1591. // Add a new method to handle the "Start Recording" button click
  1592. handleStartRecordingClick() {
  1593. this.showStartRecordingButton = false;
  1594. this.clearCountdown();
  1595. this.startRecordingAnswer();
  1596. },
  1597. // 修改 checkAudioPermission 方法,确保在录制前获取音频权限
  1598. checkAudioPermission() {
  1599. const systemInfo = common_vendor.index.getSystemInfoSync();
  1600. const isMiniProgram = systemInfo.uniPlatform && systemInfo.uniPlatform.startsWith("mp-");
  1601. if (isMiniProgram) {
  1602. common_vendor.index.getSetting({
  1603. success: (res) => {
  1604. if (!res.authSetting["scope.record"]) {
  1605. common_vendor.index.authorize({
  1606. scope: "scope.record",
  1607. success: () => {
  1608. console.log("录音权限已获取");
  1609. },
  1610. fail: (err) => {
  1611. console.error("录音权限获取失败:", err);
  1612. this.showPermissionDialog("录音");
  1613. }
  1614. });
  1615. }
  1616. if (!res.authSetting["scope.camera"]) {
  1617. common_vendor.index.authorize({
  1618. scope: "scope.camera",
  1619. success: () => {
  1620. console.log("相机权限已获取");
  1621. },
  1622. fail: (err) => {
  1623. console.error("相机权限获取失败:", err);
  1624. this.showPermissionDialog("相机");
  1625. }
  1626. });
  1627. }
  1628. }
  1629. });
  1630. }
  1631. },
  1632. // 添加新方法:测试音频输入
  1633. testAudioInput() {
  1634. if (!this.cameraStream) {
  1635. console.warn("没有可用的媒体流,无法测试音频");
  1636. return;
  1637. }
  1638. const audioTracks = this.cameraStream.getAudioTracks();
  1639. if (audioTracks.length === 0) {
  1640. console.warn("没有检测到音频轨道,尝试重新获取");
  1641. this.tryGetAudioOnly();
  1642. return;
  1643. }
  1644. console.log("音频轨道信息:", audioTracks[0].getSettings());
  1645. try {
  1646. const AudioContext = window.AudioContext || window.webkitAudioContext;
  1647. if (!AudioContext) {
  1648. console.warn("浏览器不支持AudioContext");
  1649. return;
  1650. }
  1651. const audioContext = new AudioContext();
  1652. const analyser = audioContext.createAnalyser();
  1653. const microphone = audioContext.createMediaStreamSource(this.cameraStream);
  1654. microphone.connect(analyser);
  1655. analyser.fftSize = 256;
  1656. const bufferLength = analyser.frequencyBinCount;
  1657. const dataArray = new Uint8Array(bufferLength);
  1658. let silenceCounter = 0;
  1659. const checkAudio = () => {
  1660. if (this.isRecording)
  1661. return;
  1662. analyser.getByteFrequencyData(dataArray);
  1663. let sum = 0;
  1664. for (let i = 0; i < bufferLength; i++) {
  1665. sum += dataArray[i];
  1666. }
  1667. const average = sum / bufferLength;
  1668. if (average > 10) {
  1669. console.log("检测到音频输入,音量:", average);
  1670. silenceCounter = 0;
  1671. } else {
  1672. silenceCounter++;
  1673. if (silenceCounter > 10) {
  1674. console.warn("持续检测不到音频输入,可能麦克风未正常工作");
  1675. silenceCounter = 0;
  1676. }
  1677. }
  1678. requestAnimationFrame(checkAudio);
  1679. };
  1680. checkAudio();
  1681. } catch (e) {
  1682. console.error("音频测试失败:", e);
  1683. }
  1684. },
  1685. // 添加新方法:尝试单独获取音频
  1686. tryGetAudioOnly() {
  1687. navigator.mediaDevices.getUserMedia({ audio: true }).then((audioStream) => {
  1688. if (this.cameraStream) {
  1689. const videoTrack = this.cameraStream.getVideoTracks()[0];
  1690. const audioTrack = audioStream.getAudioTracks()[0];
  1691. const combinedStream = new MediaStream();
  1692. if (videoTrack)
  1693. combinedStream.addTrack(videoTrack);
  1694. if (audioTrack)
  1695. combinedStream.addTrack(audioTrack);
  1696. this.cameraStream = combinedStream;
  1697. const videoElement = this.$refs.userCameraVideo;
  1698. if (videoElement) {
  1699. videoElement.srcObject = combinedStream;
  1700. videoElement.muted = true;
  1701. }
  1702. console.log("成功合并音频和视频轨道");
  1703. } else {
  1704. console.warn("没有视频流可合并");
  1705. }
  1706. }).catch((err) => {
  1707. console.error("单独获取音频失败:", err);
  1708. });
  1709. },
  1710. // 添加新方法:显示权限对话框
  1711. showPermissionDialog(permissionType) {
  1712. common_vendor.index.showModal({
  1713. title: "需要权限",
  1714. content: `请允许使用${permissionType}权限,否则可能影响面试功能`,
  1715. confirmText: "去设置",
  1716. success: (res) => {
  1717. if (res.confirm) {
  1718. common_vendor.index.openSetting({
  1719. success: (settingRes) => {
  1720. console.log("设置页面打开成功", settingRes);
  1721. }
  1722. });
  1723. }
  1724. }
  1725. });
  1726. },
  1727. // 添加重试上传方法
  1728. retryVideoUpload() {
  1729. if (this.lastVideoToRetry) {
  1730. this.showRetryButton = false;
  1731. common_vendor.index.showLoading({
  1732. title: "正在重新提交...",
  1733. mask: true
  1734. });
  1735. this.submitVideoToInterview(this.lastVideoToRetry);
  1736. } else {
  1737. common_vendor.index.showToast({
  1738. title: "没有可重试的视频",
  1739. icon: "none"
  1740. });
  1741. }
  1742. },
  1743. // 添加一个新方法用于压缩视频
  1744. async compressVideo(videoBlob) {
  1745. if (videoBlob.size < 5 * 1024 * 1024) {
  1746. return videoBlob;
  1747. }
  1748. console.log("开始压缩视频,原始大小:", videoBlob.size);
  1749. const videoElement = document.createElement("video");
  1750. videoElement.muted = true;
  1751. videoElement.autoplay = false;
  1752. const canvas = document.createElement("canvas");
  1753. const ctx = canvas.getContext("2d");
  1754. videoElement.src = URL.createObjectURL(videoBlob);
  1755. return new Promise((resolve) => {
  1756. videoElement.onloadedmetadata = () => {
  1757. const width = Math.floor(videoElement.videoWidth / 2);
  1758. const height = Math.floor(videoElement.videoHeight / 2);
  1759. canvas.width = width;
  1760. canvas.height = height;
  1761. const stream = canvas.captureStream(15);
  1762. if (videoElement.captureStream) {
  1763. const originalStream = videoElement.captureStream();
  1764. const audioTracks = originalStream.getAudioTracks();
  1765. if (audioTracks.length > 0) {
  1766. stream.addTrack(audioTracks[0]);
  1767. }
  1768. }
  1769. const options = {
  1770. mimeType: "video/webm;codecs=vp8,opus",
  1771. audioBitsPerSecond: 64e3,
  1772. videoBitsPerSecond: 8e5
  1773. // 800kbps
  1774. };
  1775. const mediaRecorder = new MediaRecorder(stream, options);
  1776. const chunks = [];
  1777. mediaRecorder.ondataavailable = (e) => {
  1778. if (e.data.size > 0) {
  1779. chunks.push(e.data);
  1780. }
  1781. };
  1782. mediaRecorder.onstop = () => {
  1783. const compressedBlob = new Blob(chunks, { type: "video/webm" });
  1784. console.log("视频压缩完成,压缩后大小:", compressedBlob.size);
  1785. resolve(compressedBlob);
  1786. };
  1787. videoElement.onplay = () => {
  1788. mediaRecorder.start(10);
  1789. const drawFrame = () => {
  1790. if (videoElement.paused || videoElement.ended) {
  1791. mediaRecorder.stop();
  1792. return;
  1793. }
  1794. ctx.drawImage(videoElement, 0, 0, width, height);
  1795. requestAnimationFrame(drawFrame);
  1796. };
  1797. drawFrame();
  1798. };
  1799. videoElement.play();
  1800. };
  1801. });
  1802. },
  1803. // 修改 checkIOSCameraRecordPermission 方法
  1804. checkIOSCameraRecordPermission() {
  1805. const systemInfo = common_vendor.index.getSystemInfoSync();
  1806. if (systemInfo.platform !== "ios")
  1807. return;
  1808. common_vendor.index.getSetting({
  1809. success: (res) => {
  1810. if (!res.authSetting["scope.camera"]) {
  1811. common_vendor.index.authorize({
  1812. scope: "scope.camera",
  1813. success: () => {
  1814. console.log("iOS相机权限已获取");
  1815. },
  1816. fail: (err) => {
  1817. console.error("iOS相机权限获取失败:", err);
  1818. this.showPermissionDialog("相机");
  1819. }
  1820. });
  1821. }
  1822. if (!res.authSetting["scope.record"]) {
  1823. common_vendor.index.authorize({
  1824. scope: "scope.record",
  1825. success: () => {
  1826. console.log("iOS录音权限已获取");
  1827. },
  1828. fail: (err) => {
  1829. console.error("iOS录音权限获取失败:", err);
  1830. this.showPermissionDialog("录音");
  1831. }
  1832. });
  1833. }
  1834. }
  1835. });
  1836. },
  1837. // 添加新方法:检查并修复渲染问题
  1838. checkAndFixRenderingIssues() {
  1839. try {
  1840. if (typeof u !== "undefined" && u) {
  1841. if (!u.currentQuestion) {
  1842. console.log("修复: 创建缺失的currentQuestion对象");
  1843. u.currentQuestion = {};
  1844. }
  1845. if (u.currentQuestion && typeof u.currentQuestion.isImportant === "undefined") {
  1846. console.log("修复: 设置缺失的isImportant属性");
  1847. u.currentQuestion.isImportant = false;
  1848. }
  1849. }
  1850. } catch (e) {
  1851. console.log("防御性检查异常:", e);
  1852. }
  1853. },
  1854. // 添加格式化时间的辅助方法
  1855. formatTime(seconds) {
  1856. if (!seconds && seconds !== 0)
  1857. return "03:30";
  1858. const minutes = Math.floor(seconds / 60);
  1859. const remainingSeconds = seconds % 60;
  1860. return `${minutes.toString().padStart(2, "0")}:${remainingSeconds.toString().padStart(2, "0")}`;
  1861. },
  1862. // 添加获取问题数据的方法
  1863. fetchQuestions() {
  1864. this.loading = true;
  1865. const tenant_id = JSON.parse(common_vendor.index.getStorageSync("userInfo")).tenant_id || "1";
  1866. let position_id = 1;
  1867. try {
  1868. const selectedJob = JSON.parse(common_vendor.index.getStorageSync("selectedJob") || "{}");
  1869. if (selectedJob && selectedJob.id) {
  1870. position_id = selectedJob.id;
  1871. console.log("使用选择的职位ID获取问题:", position_id);
  1872. } else {
  1873. console.warn("未找到选择的职位信息,使用默认职位ID:", position_id);
  1874. }
  1875. } catch (e) {
  1876. console.error("解析职位信息失败:", e);
  1877. }
  1878. const timestamp = Date.now();
  1879. const requestUrl = `${common_config.apiBaseUrl}/api/wechat/open_questions/?position_id=${position_id}&tenant_id=${tenant_id}&question_form=0&_t=${timestamp}`;
  1880. console.log("完整的请求URL:", requestUrl);
  1881. common_vendor.index.request({
  1882. url: requestUrl,
  1883. method: "GET",
  1884. success: (res) => {
  1885. if (res.data && res.data.code === 2e3 && res.data.data && res.data.data.items) {
  1886. console.log("获取问题数据成功:", res.data.data.items);
  1887. this.questions = res.data.data.items;
  1888. this.processQuestionData();
  1889. this.playIntroVideo();
  1890. } else {
  1891. console.error("获取问题数据失败:", res.data);
  1892. common_vendor.index.showToast({
  1893. title: "获取问题数据失败",
  1894. icon: "none"
  1895. });
  1896. }
  1897. },
  1898. fail: (err) => {
  1899. console.error("请求问题数据失败:", err);
  1900. common_vendor.index.showToast({
  1901. title: "网络错误,请检查网络连接",
  1902. icon: "none"
  1903. });
  1904. },
  1905. complete: () => {
  1906. this.loading = false;
  1907. }
  1908. });
  1909. },
  1910. // 处理问题数据,提取视频URL和字幕
  1911. processQuestionData() {
  1912. this.videoList = [];
  1913. this.videoList.push(this.introVideoUrl);
  1914. this.subtitles = [
  1915. {
  1916. startTime: 0,
  1917. endTime: 5,
  1918. text: "你好,我是本次面试的面试官,欢迎参加本公司的线上面试!"
  1919. },
  1920. {
  1921. startTime: 5,
  1922. endTime: 13,
  1923. text: "面试预计需要15分钟,请你提前安排在网络良好、光线亮度合适、且相对安静的环境参加这次面试"
  1924. },
  1925. {
  1926. startTime: 13,
  1927. endTime: 20,
  1928. text: "以免影响本次面试的结果。如果你在面试过程中遇到问题,请与我们的招聘人员联系。"
  1929. }
  1930. ];
  1931. const sortedQuestions = [...this.questions].sort((a, b) => a.sequence_number - b.sequence_number);
  1932. const questionsToUse = sortedQuestions.slice(0, 5);
  1933. questionsToUse.forEach((question, index) => {
  1934. if (question.digital_human_video_url) {
  1935. this.videoList.push(question.digital_human_video_url);
  1936. const subtitleArray = [{
  1937. startTime: 0,
  1938. endTime: 30,
  1939. // 延长字幕显示时间到30秒
  1940. text: question.digital_human_video_subtitle || question.question
  1941. }];
  1942. const videoIndex = this.videoList.length - 1;
  1943. this[`question${videoIndex}Subtitles`] = subtitleArray;
  1944. this.subtitleMap[question.digital_human_video_url] = subtitleArray;
  1945. }
  1946. });
  1947. if (this.videoList.length <= 1)
  1948. ;
  1949. else {
  1950. console.log("处理后的视频列表:", this.videoList);
  1951. console.log("处理后的字幕:", this.subtitles);
  1952. }
  1953. },
  1954. // 使用默认视频和字幕(作为备用)
  1955. useDefaultVideosAndSubtitles() {
  1956. console.log("使用默认视频和字幕");
  1957. this.subtitles = [
  1958. {
  1959. startTime: 0,
  1960. endTime: 5,
  1961. text: "你好,我是本次面试的面试官,欢迎参加本公司的线上面试!"
  1962. },
  1963. {
  1964. startTime: 5,
  1965. endTime: 13,
  1966. text: "面试预计需要15分钟,请你提前安排在网络良好、光线亮度合适、且相对安静的环境参加这次面试"
  1967. },
  1968. {
  1969. startTime: 13,
  1970. endTime: 20,
  1971. text: "以免影响本次面试的结果。如果你在面试过程中遇到问题,请与我们的招聘人员联系。"
  1972. }
  1973. ];
  1974. this.question1Subtitles = [{
  1975. startTime: 0,
  1976. endTime: 10,
  1977. text: "请结合您的基本信息与过往履历进行简单的自我介绍,并讲一讲您有哪些优势胜任本岗位:"
  1978. }];
  1979. this.question2Subtitles = [{
  1980. startTime: 0,
  1981. endTime: 4,
  1982. text: "在工作中,你如何确保个人防护装备的正确使用?"
  1983. }];
  1984. this.question3Subtitles = [{
  1985. startTime: 0,
  1986. endTime: 4,
  1987. text: "描述一次你与团队合作改善生产流程的经历。"
  1988. }];
  1989. this.question4Subtitles = [{
  1990. startTime: 0,
  1991. endTime: 6,
  1992. text: "你在团队合作中曾遇到过哪些挑战?如何解决团队内部的分歧?"
  1993. }];
  1994. this.question5Subtitles = [{
  1995. startTime: 0,
  1996. endTime: 5,
  1997. text: "您已完成本次面试全部题目,请问您对于这个岗位还有什么想要了解的吗?"
  1998. }];
  1999. },
  2000. // 播放介绍视频
  2001. playIntroVideo() {
  2002. this.videoUrl = this.videoList[0];
  2003. this.videoPlaying = true;
  2004. this.$nextTick(() => {
  2005. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  2006. if (videoContext) {
  2007. videoContext.play();
  2008. }
  2009. });
  2010. },
  2011. // 添加新方法:获取默认问题ID
  2012. getDefaultQuestionId(videoIndex) {
  2013. switch (videoIndex) {
  2014. case 1:
  2015. return 10;
  2016. case 2:
  2017. return 11;
  2018. case 3:
  2019. return 12;
  2020. case 4:
  2021. return 13;
  2022. default:
  2023. return 10;
  2024. }
  2025. },
  2026. // 添加新方法:根据索引获取当前问题
  2027. getCurrentQuestionByIndex(videoIndex) {
  2028. const questionIndex = videoIndex - 1;
  2029. const sortedQuestions = [...this.questions].sort((a, b) => a.sequence_number - b.sequence_number);
  2030. if (questionIndex >= 0 && questionIndex < sortedQuestions.length) {
  2031. return sortedQuestions[questionIndex];
  2032. }
  2033. return null;
  2034. },
  2035. onShow() {
  2036. console.log("identity-verify页面onShow");
  2037. console.log("当前本地存储中的职位信息:", common_vendor.index.getStorageSync("selectedJob"));
  2038. this.fetchQuestions();
  2039. this.fetchFollowUpQuestions();
  2040. },
  2041. // 添加新方法:重置录制状态,准备重新回答
  2042. resetForRerecording() {
  2043. console.log("重置录制状态,准备重新回答");
  2044. this.isRecording = false;
  2045. this.showStopRecordingButton = false;
  2046. this.showStartRecordingButton = true;
  2047. this.clearCountdown();
  2048. if (this.recordingTimer) {
  2049. clearInterval(this.recordingTimer);
  2050. this.recordingTimer = null;
  2051. }
  2052. this.recordingTimerCount = 0;
  2053. this.recordingTimeDisplay = "00:00 ";
  2054. this.remainingTime = this.maxRecordingTime;
  2055. if (this.mediaRecorder && this.mediaRecorder.state !== "inactive") {
  2056. this.mediaRecorder.stop();
  2057. this.recordedChunks = [];
  2058. }
  2059. if (this.cameraContext) {
  2060. this.cameraContext.stopRecord({
  2061. success: () => {
  2062. console.log("相机录制已停止");
  2063. },
  2064. fail: (err) => {
  2065. console.error("停止相机录制失败:", err);
  2066. }
  2067. });
  2068. }
  2069. },
  2070. // 修改 playLowScoreVideo 方法,优化字幕显示
  2071. playLowScoreVideo() {
  2072. console.log("播放低分提示视频");
  2073. this.isPlayingLowScoreVideo = true;
  2074. this.showStartRecordingButton = false;
  2075. this.showStopRecordingButton = false;
  2076. this.showRerecordButton = false;
  2077. this.videoUrl = this.lowScoreVideoUrl;
  2078. this.videoPlaying = true;
  2079. this.currentSubtitle = "";
  2080. this.$nextTick(() => {
  2081. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  2082. if (videoContext) {
  2083. videoContext.play();
  2084. setTimeout(() => {
  2085. this.currentSubtitle = "我未听清楚您在说什么,请您再说一遍!";
  2086. this.lowScoreVideoSubtitles = [
  2087. {
  2088. startTime: 0,
  2089. endTime: 30,
  2090. // 假设视频长度为10秒,可根据实际情况调整
  2091. text: "我未听清楚您在说什么,请您再说一遍!",
  2092. translation: "I didn't quite catch what you said, could you please repeat it?"
  2093. }
  2094. ];
  2095. }, 500);
  2096. }
  2097. });
  2098. },
  2099. // 添加新方法:处理重新录制按钮点击
  2100. handleRerecordButtonClick() {
  2101. console.log("点击重新录制按钮");
  2102. this.retryCount++;
  2103. console.log(`当前重试次数: ${this.retryCount}/${this.maxRetryAttempts}`);
  2104. this.showRerecordButton = false;
  2105. this.handleStartRecordingClick();
  2106. },
  2107. // 添加 onUnload 生命周期钩子,移除 WebSocket 关闭
  2108. onUnload() {
  2109. console.log("页面卸载");
  2110. },
  2111. // 修改 onHide 生命周期钩子,移除 WebSocket 关闭
  2112. onHide() {
  2113. console.log("页面隐藏");
  2114. },
  2115. // 添加新方法:阻止视频控制
  2116. preventVideoControl(e) {
  2117. e.preventDefault();
  2118. e.stopPropagation();
  2119. console.log("阻止视频控制操作");
  2120. return false;
  2121. },
  2122. // 添加获取追问问题的方法
  2123. fetchFollowUpQuestions() {
  2124. const tenant_id = JSON.parse(common_vendor.index.getStorageSync("userInfo")).tenant_id || "1";
  2125. let position_id = 1;
  2126. try {
  2127. const selectedJob = JSON.parse(common_vendor.index.getStorageSync("selectedJob") || "{}");
  2128. if (selectedJob && selectedJob.id) {
  2129. position_id = selectedJob.id;
  2130. console.log("使用选择的职位ID获取追问问题:", position_id);
  2131. } else {
  2132. console.warn("未找到选择的职位信息,使用默认职位ID:", position_id);
  2133. }
  2134. } catch (e) {
  2135. console.error("解析职位信息失败:", e);
  2136. }
  2137. const timestamp = Date.now();
  2138. const requestUrl = `${common_config.apiBaseUrl}/api/wechat/open_questions/?position_id=${position_id}&tenant_id=${tenant_id}&question_form=5&_t=${timestamp}`;
  2139. console.log("获取追问问题的请求URL:", requestUrl);
  2140. common_vendor.index.request({
  2141. url: requestUrl,
  2142. method: "GET",
  2143. success: (res) => {
  2144. if (res.data && res.data.code === 2e3 && res.data.data && res.data.data.items) {
  2145. console.log("获取追问问题数据成功:", res.data.data.items);
  2146. this.followUpQuestions = res.data.data.items.map((item) => ({
  2147. ...item,
  2148. question_form: 5
  2149. // 确保每个追问问题都有正确的question_form值
  2150. }));
  2151. this.processFollowUpQuestions();
  2152. } else {
  2153. console.error("获取追问问题数据失败:", res.data);
  2154. this.followUpQuestions = [];
  2155. }
  2156. },
  2157. fail: (err) => {
  2158. console.error("请求追问问题数据失败:", err);
  2159. this.followUpQuestions = [];
  2160. }
  2161. });
  2162. },
  2163. // 改进处理追问问题数据的方法
  2164. processFollowUpQuestions() {
  2165. if (!this.followUpQuestions || this.followUpQuestions.length === 0) {
  2166. console.log("没有追问问题数据");
  2167. this.followUpQuestions = [];
  2168. return;
  2169. }
  2170. console.log("处理追问问题数据,总数:", this.followUpQuestions.length);
  2171. this.followUpQuestions = this.followUpQuestions.filter((q) => q.parent_question_id);
  2172. const parentQuestionIds = /* @__PURE__ */ new Set();
  2173. this.followUpQuestions.forEach((question) => {
  2174. if (question.parent_question_id) {
  2175. parentQuestionIds.add(question.parent_question_id);
  2176. }
  2177. });
  2178. console.log("有追问的父问题ID:", Array.from(parentQuestionIds));
  2179. this.hasPlayedFollowUp = {};
  2180. },
  2181. // 添加新方法:检查并播放追问问题
  2182. checkAndPlayFollowUpQuestion(parentQuestionId) {
  2183. console.log("检查是否有追问问题,父问题ID:", parentQuestionId);
  2184. if (!parentQuestionId) {
  2185. console.warn("没有父问题ID,无法检查追问问题");
  2186. this.proceedToNextQuestion();
  2187. return;
  2188. }
  2189. if (this.hasPlayedFollowUp[parentQuestionId]) {
  2190. console.log("已经播放过此问题的追问,直接进入下一个问题");
  2191. this.retryCount = 0;
  2192. this.proceedToNextQuestion();
  2193. return;
  2194. }
  2195. const followUpQuestion = this.followUpQuestions.find(
  2196. (q) => q.parent_question_id === parentQuestionId && q.digital_human_video_url && q.question_form === 5
  2197. );
  2198. if (followUpQuestion) {
  2199. console.log("找到追问问题:", followUpQuestion);
  2200. this.hasPlayedFollowUp[parentQuestionId] = true;
  2201. this.isFollowUpQuestion = true;
  2202. this.currentParentQuestionId = parentQuestionId;
  2203. this.currentFollowUpQuestion = followUpQuestion;
  2204. this.playFollowUpQuestionVideo(followUpQuestion);
  2205. } else {
  2206. console.log("没有找到对应的追问问题,继续下一个问题");
  2207. this.retryCount = 0;
  2208. this.proceedToNextQuestion();
  2209. }
  2210. },
  2211. // 添加新方法:播放追问问题视频
  2212. playFollowUpQuestionVideo(followUpQuestion) {
  2213. console.log("播放追问问题视频:", followUpQuestion.digital_human_video_url);
  2214. this.videoUrl = followUpQuestion.digital_human_video_url;
  2215. this.videoPlaying = true;
  2216. const followUpSubtitles = [{
  2217. startTime: 0,
  2218. endTime: 60,
  2219. // 延长显示时间到60秒
  2220. text: followUpQuestion.digital_human_video_subtitle || followUpQuestion.question
  2221. }];
  2222. const subtitleKey = `followUpSubtitles_${followUpQuestion.id}`;
  2223. this[subtitleKey] = followUpSubtitles;
  2224. this.$nextTick(() => {
  2225. const videoContext = common_vendor.index.createVideoContext("myVideo", this);
  2226. if (videoContext) {
  2227. videoContext.play();
  2228. this.currentSubtitle = followUpSubtitles[0].text;
  2229. }
  2230. });
  2231. }
  2232. },
  2233. computed: {
  2234. // 计算进度比例
  2235. progressRatio() {
  2236. return this.recordingTimerCount / this.maxRecordingTime;
  2237. },
  2238. // 右半圆旋转角度
  2239. half1Turn() {
  2240. if (this.progressRatio <= 0.5) {
  2241. return this.progressRatio * 2 * 180;
  2242. } else {
  2243. return 180;
  2244. }
  2245. },
  2246. // 左半圆旋转角度
  2247. half2Turn() {
  2248. if (this.progressRatio <= 0.5) {
  2249. return 0;
  2250. } else {
  2251. return (this.progressRatio - 0.5) * 2 * 180;
  2252. }
  2253. },
  2254. // 修改进度百分比的计算方式
  2255. progressPercent() {
  2256. return Math.min(Math.round(this.recordingTimerCount / this.maxRecordingTime * 100), 100);
  2257. }
  2258. }
  2259. };
  2260. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  2261. return common_vendor.e({
  2262. a: $data.videoUrl,
  2263. b: common_vendor.o((...args) => $options.handleVideoError && $options.handleVideoError(...args)),
  2264. c: common_vendor.o((...args) => $options.handleVideoEnded && $options.handleVideoEnded(...args)),
  2265. d: common_vendor.o((...args) => $options.handleTimeUpdate && $options.handleTimeUpdate(...args)),
  2266. e: common_vendor.o((...args) => $options.preventVideoControl && $options.preventVideoControl(...args)),
  2267. f: common_vendor.o((...args) => $options.preventVideoControl && $options.preventVideoControl(...args)),
  2268. g: $data.showAnswerButton
  2269. }, $data.showAnswerButton ? {
  2270. h: common_vendor.o((...args) => $options.handleAnswerButtonClick && $options.handleAnswerButtonClick(...args))
  2271. } : {}, {
  2272. i: $data.currentSubtitle
  2273. }, $data.currentSubtitle ? {
  2274. j: common_vendor.t($data.currentSubtitle)
  2275. } : {}, {
  2276. k: $data.useMiniProgramCameraComponent
  2277. }, $data.useMiniProgramCameraComponent ? {
  2278. l: common_vendor.o((...args) => $options.handleCameraError && $options.handleCameraError(...args))
  2279. } : {}, {
  2280. m: $data.loading
  2281. }, $data.loading ? {} : {}, {
  2282. n: $data.showDebugInfo
  2283. }, $data.showDebugInfo ? common_vendor.e({
  2284. o: $data.assistantResponse
  2285. }, $data.assistantResponse ? {
  2286. p: common_vendor.t($data.assistantResponse)
  2287. } : {}, {
  2288. q: $data.audioTranscript
  2289. }, $data.audioTranscript ? {
  2290. r: common_vendor.t($data.audioTranscript)
  2291. } : {}, {
  2292. s: common_vendor.f($data.processedResponses, (item, index, i0) => {
  2293. return common_vendor.e({
  2294. a: item.role
  2295. }, item.role ? {
  2296. b: common_vendor.t(item.role)
  2297. } : {}, {
  2298. c: item.transcript
  2299. }, item.transcript ? {
  2300. d: common_vendor.t(item.transcript)
  2301. } : {}, {
  2302. e: index
  2303. });
  2304. })
  2305. }) : {}, {
  2306. t: $data.showStopRecordingButton
  2307. }, $data.showStopRecordingButton ? {
  2308. v: common_vendor.o((...args) => $options.stopRecordingAnswer && $options.stopRecordingAnswer(...args))
  2309. } : {}, {
  2310. w: $data.isRecording
  2311. }, $data.isRecording ? {
  2312. x: common_vendor.t($data.recordingTimeDisplay),
  2313. y: `conic-gradient(${$data.progressColor} ${$options.progressPercent}%, ${$data.progressBgColor} 0%)`
  2314. } : {}, {
  2315. z: $data.showStartRecordingButton
  2316. }, $data.showStartRecordingButton ? {
  2317. A: common_vendor.o((...args) => $options.handleStartRecordingClick && $options.handleStartRecordingClick(...args))
  2318. } : {}, {
  2319. B: $data.showRetryButton
  2320. }, $data.showRetryButton ? {
  2321. C: common_vendor.o((...args) => $options.retryVideoUpload && $options.retryVideoUpload(...args))
  2322. } : {}, {
  2323. D: $data.showCountdown
  2324. }, $data.showCountdown ? {
  2325. E: common_vendor.t($data.countdownValue)
  2326. } : {}, {
  2327. F: $data.showRerecordButton
  2328. }, $data.showRerecordButton ? {
  2329. G: common_vendor.o((...args) => $options.handleRerecordButtonClick && $options.handleRerecordButtonClick(...args))
  2330. } : {});
  2331. }
  2332. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-464e78c6"]]);
  2333. wx.createPage(MiniProgramPage);