2026-03-06 18:05:51 +08:00
|
|
|
"use strict";const e=require("../../common/vendor.js"),o=require("../../config/api.js"),i=require("../../utils/payment.js"),t={components:{PaymentModal:()=>"../../components/PaymentModal.js"},data:()=>({API_BASE:o.API_BASE,loadOptions:null,lastUserId:null,loading:!1,videos:[],selectedVideoId:"",selectedVideoName:"",selectedVideoUrl:"",selectedPhotoUrl:"",selectedVoiceId:"",selectedDialect:"",selectedLanguageHint:"",selectedLanguageHintLabel:"",languageHintOptions:["中文(zh)","英文(en)","法语(fr)","德语(de)","日语(ja)","韩语(ko)","俄语(ru)"],dialectOptions:["广东话","东北话","甘肃话","贵州话","河南话","湖北话","江西话","闽南话","宁夏话","山西话","陕西话","山东话","上海话","四川话","天津话","云南话"],isConnecting:!1,connectingText:"正在接通...",videoCache:{},downloadingVideos:{},localVideoUrl:"",cacheProgress:{},preCachingInProgress:!1,videoPreloadStatus:{},callStarted:!1,callStatus:"视频通话中",callDuration:"00:00",callStartTime:null,durationTimer:null,messages:[],recognizingText:"",scrollTop:0,isRecording:!1,isProcessing:!1,isSpeaking:!1,processingText:"正在聆听...",recorderManager:null,audioFilePath:"",recordingStartTime:null,autoListen:!1,autoLoopTimer:null,longPressTimer:null,isTouching:!1,stopFallbackTimer:null,stopFallbackRetries:0,stopFallbackActive:!1,vadEnabled:!0,vadVoiceThreshold:.004,vadSilenceMs:600,vadMaxDurationMs:15e3,vadSpeaking:!1,vadSilenceStart:null,vadMaxTimer:null,vadLastSoundTime:null,vadLastFrameTime:null,vadWatchTimer:null,audioContext:null,audioCacheKey:"",currentAudioSrc:"",pendingAudioUrl:"",audioTriedFallback:!1,audioSessionId:0,audioPlayedInSession:!1,audioPlayStartAt:0,audioTriedRedownload:!1,audioTriedRecreateContext:!1,audioPlayInvokedInSession:!1,audioPlayTargetSessionId:0,audioDiagnosedInSession:!1,videoContext:null,audioContextActivated:!1,videoInitialPlayed:!1,processingTimeout:null,showSettingsDialog:!1,dialogMemoryIdentity:"",dialogMemoryInfo:"",dialogMemoryCatchphrase:"",systemPrompt:"",paymentModalData:{show:!1,serviceType:"",serviceName:"",serviceDesc:"",price:0,orderNo:"",paymentTips:"点击确认支付后将开始视频通话"},_paymentResolve:null,_paymentReject:null,_paymentOnSuccess:null,_paymentOnFailed:null}),async onLoad(o){console.log("[VideoCallNew] 页面加载",o),this.loadOptions=o;const i=e.index.getStorageSync("userId");this.lastUserId=i,await this.loadVideoCache(),o&&o.videoId?(this.selectedVideoId=o.videoId,this.selectedVideoName=decodeURIComponent(o.videoName||"复活视频"),this.selectedVideoUrl=decodeURIComponent(o.videoUrl||""),this.selectedVoiceId=o.voiceId||"",this.selectedDialect="",console.log("[VideoCallNew] 从URL参数加载视频信息"),console.log("[VideoCallNew] 视频ID:",this.selectedVideoId),console.log("[VideoCallNew] 视频名称:",this.selectedVideoName),console.log("[VideoCallNew] 视频URL:",this.selectedVideoUrl),console.log("[VideoCallNew] 音色ID:",this.selectedVoiceId),await this.checkAndLoadLocalVideo(this.selectedVideoId,this.selectedVideoUrl),this.initRecorder(),this.initAudioContext(),this.initVideoContext(),this.startAutoLoop(),setTimeout((()=>{this.startVideoCallDirect()}),300)):(this.loadVideos(),this.initRecorder(),this.initAudioContext(),this.initVideoContext(),this.startAutoLoop())},onShow(){console.log("[VideoCallNew] 页面显示");const o=e.index.getStorageSync("userId");o!==this.lastUserId&&(console.log("[VideoCallNew] 检测到用户切换"),console.log("[VideoCallNew] 上次用户ID:",this.lastUserId,"当前用户ID:",o),this.lastUserId=o),this.callStarted||this.loadOptions&&this.loadOptions.videoId||(console.log("[VideoCallNew] 页面重新显示,刷新视频列表"),this.loadVideos())},onUnload(){this.cleanup()},methods:{isVideoUsableForCall(e){if(!e)return!1;const o=e.edited_video_url||e.videoUrl||e.local_video_path||e.video_url||e.localVideoPath,i=e.voice_id||e.voiceId;return!!o&&!!i},async loadVideos(){this.loading=!0;const o=e.index.getStorageSync("userId")||"",i=e.index.getStorageSync("token")||"";await this.loadVideoCache(),e.index.req
|