1 |
- import{d as b,ah as A,ag as k,aY as F,r as q,R as L,Z as I,$ as M,m as N,b3 as B,c as i,L as x,q as H,B as O,f as U,be as _}from"./index.31cf5bff.js";import{s as l}from"./video.module.2569ebf7.js";import{P as $}from"./plyr.min.22fd58dd.js";/* empty css */import{u as y,b as j}from"./index.a40a62d5.js";var K=b({name:"pre-register",setup(){const f=A(),E=k(),R=F(),V=sessionStorage.getItem("active-open-id"),c=y(1e3,{controls:!0});c.pause();const e=q({coverImg:"",introductionVideo:"",introductionVideoTime:0,videoBrowsePoint:0,saveId:f.query.saveId,orchestraId:f.query.id,openId:f.query.openId||V,loading:!1,player:null,playerSpeed:1,intervalFnRef:null,videoDetails:[],pointVideo:{},pointVideoTime:0,videoSelectId:null,isPageHide:!1,parentConferencesNotes:"",orchestraRegisterType:"",status:""}),n=y(1e3,{controls:!0});n.pause();const g=o=>{const a=[];o.sort((s,r)=>s[0]-r[0]);let t=o[0];for(let s=1;s<o.length;s++){const r=o[s];t[1]>=r[0]?t[1]=Math.max(r[1],t[1]):(a.push(t),t=r)}return a.push(t),C(a)},C=o=>{const a=[],t=e.pointVideo.startNode,s=e.pointVideo.endNode;return o.forEach(r=>{r[1]>=r[0]&&(r[0]>=t&&r[0]<=s&&r[1]<=s&&a.push(r),r[0]>=t&&r[0]<=s&&r[1]>s&&a.push([r[0],s]),r[0]<t&&r[1]>t&&r[1]<=s&&a.push([t,r[1]]),r[0]<t&&r[1]>t&&r[1]>s&&a.push([t,s]))}),a},P=o=>{const a=g(o);let t=0;return a.forEach(s=>{t+=s[1]-s[0]}),t},u=o=>{e.videoDetails.forEach(a=>{a.startNode<=o&&o<=a.endNode&&(e.videoSelectId=a.id)})},S=()=>{const a={controls:["play-large","play","progress","captions","current-time","duration","settings","fullscreen"],settings:["speed"],speed:{selected:1,options:[.5,1,1.5,2]},i18n:{speed:"\u901F\u5EA6",normal:"\u9ED8\u8BA4"},autoplay:!1,invertTime:!1};U().iPhone&&(a.fullscreen={enabled:!0,fallback:"force",iosNative:!0});const t=[];e.videoDetails.forEach(s=>{t.push({time:s.startNode,label:s.desc})}),a.markers={enabled:!0,points:t},e.player=new $("#register-video",a),e.player.on("ready",s=>{}),e.player.on("loadedmetadata",()=>{console.log("loadedmetadata"),e.loading=!1,e.player.currentTime=e.videoBrowsePoint,u(e.player.currentTime)}),e.player.on("ratechange",()=>{e.playerSpeed=e.playerSpeed<e.player.speed?e.player.speed:e.playerSpeed}),e.player.on("seeking",()=>{console.log("seeking"),n.isActive.value&&n.pause()}),e.player.on("seeked",()=>{console.log("seeked"),n.isActive.value&&n.pause()}),e.player.on("waiting",()=>{n.isActive.value&&n.pause()}),e.player.on("timeupdate",()=>{console.log(n.isActive.value,"timeupdate"),u(e.player.currentTime),!n.isActive.value&&e.player.currentTime>0&&e.player.playing&&n.resume()}),e.player.on("ended",()=>{e.player.pause(),console.log(n.isActive.value,"ended")}),e.player.on("play",()=>{console.log("play"),n.resume()}),e.player.on("pause",()=>{console.log("pause",n.isActive.value),n.pause()}),e.player.on("enterfullscreen",()=>{console.log("fullscreen");const s=document.createElement("i");s.id="fullscreen-back",s.className="van-icon van-icon-arrow-left video-back",s.addEventListener("click",()=>{e.player.fullscreen.exit()}),document.getElementsByClassName("plyr")[0].appendChild(s)}),e.player.on("exitfullscreen",()=>{console.log("exitfullscreen");const s=document.getElementById("fullscreen-back");s&&s.remove()}),u(0)},v=L([]);let d=[];const p=y(1e3,{controls:!0});I(()=>n.isActive.value,o=>{m(o)});const m=o=>{if(console.log(o,"videoIntervalRef.isActive.value in"),o?d[0]=Math.floor(e.player.currentTime):d[1]=Math.floor(e.player.currentTime),d.length>=2){const a=d[1]-d[0]-p.counter.value*e.playerSpeed>2;d[1]>=d[0]&&!a&&v.value.push(d),d=[],p.counter.value=0}};I(R,o=>{console.log("watch",o),o=="hidden"&&e.player.pause()});const h=async(o=10)=>{try{const a=v.value.length>0?g(v.value):[],t=a.length>0?P(a):0,s=Math.floor(t/Math.floor(e.pointVideoTime)*100);await N.post("/api-student/open/studentBrowseRecord/updateStat",{data:{id:e.saveId,pageBrowseTime:o,videoBrowseData:JSON.stringify(a),videoBrowseDataTime:t||0,videoBrowsePercentage:s||0,videoBrowseTime:n==null?void 0:n.counter.value,videoBrowsePoint:Math.floor(e.player.currentTime||0)}})}catch{}},D=async()=>{var o,a;try{e.player.pause(),(o=e.intervalFnRef)==null||o.pause(),p.pause(),n.pause(),c.pause(),m(n.isActive.value),await h(),console.log(e.orchestraRegisterType),e.orchestraRegisterType==="PARENT_CONFERENCES"?window.location.href=window.location.origin+window.location.pathname+`/#/preApply?id=${e.orchestraId}`:e.orchestraRegisterType==="GROUP_BUY"?window.location.href=window.location.origin+window.location.pathname+`/#/preGoodsApply?id=${e.orchestraId}`:window.location.href=window.location.origin+window.location.pathname+"/project/preRegister.html?"+_.stringify({orchestraId:e.orchestraId,openId:e.openId})}catch(t){console.log(t,"e"),(a=e.intervalFnRef)==null||a.resume(),c.resume(),p.resume()}};M(async()=>{try{const{data:o}=await N.get("/api-student/open/studentBrowseRecord/query",{params:{openId:e.openId,orchestraId:e.orchestraId}});e.videoBrowsePoint=o.videoBrowsePoint||0,e.player&&(e.player.currentTime=o.videoBrowsePoint||0),e.introductionVideo=o.introductionVideo,e.introductionVideoTime=o.introductionVideoTime,e.coverImg=o.coverImg,v.value=o.videoBrowseData?JSON.parse(o.videoBrowseData):[],e.parentConferencesNotes=o.parentConferencesNotes,e.orchestraRegisterType=o.orchestraRegisterType,(o.videoDetails||[]).forEach(t=>{e.videoDetails.push({startNode:t.startNode,endNode:t.endNode,desc:t.desc,id:t.id}),t.pointFlag&&(e.pointVideo=t,e.pointVideoTime=t.endNode-t.startNode)}),S(),e.intervalFnRef=j(async()=>{c.counter.value=0,c.resume(),await h(),n.counter.value=0},1e4)}catch{}}),B(()=>{var o,a;(o=e.player)==null||o.fullscreen.exit(),(a=e.intervalFnRef)==null||a.pause(),p.pause(),c.pause()}),e.openId||E.replace({path:"/pre-register-video",query:{id:e.orchestraId}});const w=()=>{e.isPageHide&&window.location.reload()};window.addEventListener("pageshow",w);const T=()=>{e.isPageHide=!0};return window.addEventListener("pagehide",T),B(()=>{window.removeEventListener("pageshow",w),window.removeEventListener("pagehide",T)}),()=>i("div",{class:l["pre-register-video"]},[i("div",{class:l.videoContainer},[i("div",{class:l["video-content"]},[i("video",{id:"register-video",class:l.video,src:e.introductionVideo,playsinline:!0,poster:e.coverImg,preload:"auto"},null),e.loading&&i("div",{class:l.loadingVideo},[i(x,{size:36,color:"#FF8057",vertical:!0,style:{height:"100%",justifyContent:"center"}},{default:()=>[H("\u52A0\u8F7D\u4E2D...")]})])])]),i("div",{class:l.videoCount},[i("div",{class:l.videoTitle},null),i("div",{class:l.videoCountContent},[e.videoDetails.map(o=>i("span",{class:[o.id===e.videoSelectId?l.active:""],onClick:()=>{e.player.currentTime=o.startNode,e.player.play(),e.videoBrowsePoint=o.startNode,u(e.player.currentTime)}},[o.desc]))])]),i("div",{class:l.messageContainer},[i("div",{class:l.messageContent},[i("div",{innerHTML:e.parentConferencesNotes},null),i(O,{class:l.submitBtn,onClick:D},null)])])])}});export{K as default};
|