1 |
- import{d as k,ah as A,ag as F,aY as M,r as q,R as L,Z as I,$ as x,m as N,b3 as B,c as n,L as H,q as O,B as U,f as _,be as $}from"./index.332c7f08.js";import{s as d}from"./video.module.2569ebf7.js";import{P as j}from"./plyr.min.22fd58dd.js";/* empty css */import{d as V}from"./deep-clone.c5af4e6b.js";import{u as g,b as G}from"./index.08e660c8.js";var W=k({name:"pre-register",setup(){const f=A(),C=F(),D=M(),E=sessionStorage.getItem("active-open-id"),c=g(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||E,loading:!1,player:null,playerSpeed:1,intervalFnRef:null,videoDetails:[],pointVideo:{},pointVideoTime:0,videoSelectId:null,isPageHide:!1,parentConferencesNotes:"",orchestraRegisterType:"",status:"",registerDisplay:!0}),i=g(1e3,{controls:!0});i.pause();const m=o=>{const r=[];o.sort((a,s)=>a[0]-s[0]);let t=o[0];for(let a=1;a<o.length;a++){const s=o[a];t[1]>=s[0]?t[1]=Math.max(s[1],t[1]):(r.push(t),t=s)}return r.push(t),P(r)},P=o=>{const r=[],t=e.pointVideo.startNode,a=e.pointVideo.endNode;return o.forEach(s=>{s[1]>=s[0]&&(s[0]>=t&&s[0]<=a&&s[1]<=a&&r.push(s),s[0]>=t&&s[0]<=a&&s[1]>a&&r.push([s[0],a]),s[0]<t&&s[1]>t&&s[1]<=a&&r.push([t,s[1]]),s[0]<t&&s[1]>t&&s[1]>a&&r.push([t,a]))}),r},R=o=>{const r=m(o);let t=0;return r.forEach(a=>{t+=a[1]-a[0]}),t},u=o=>{e.videoDetails.forEach(r=>{r.startNode<=o&&o<=r.endNode&&(e.videoSelectId=r.id)})},S=()=>{const r={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};_().iPhone&&(r.fullscreen={enabled:!0,fallback:"force",iosNative:!0});const t=[];e.videoDetails.forEach(a=>{t.push({time:a.startNode,label:a.desc})}),r.markers={enabled:!0,points:t},e.player=new j("#register-video",r),e.player.on("ready",a=>{}),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"),i.isActive.value&&i.pause()}),e.player.on("seeked",()=>{console.log("seeked"),i.isActive.value&&i.pause()}),e.player.on("waiting",()=>{i.isActive.value&&i.pause()}),e.player.on("timeupdate",()=>{u(e.player.currentTime),!i.isActive.value&&e.player.currentTime>0&&e.player.playing&&i.resume()}),e.player.on("ended",()=>{e.player.pause(),console.log(i.isActive.value,"ended")}),e.player.on("play",()=>{console.log("play"),i.resume()}),e.player.on("pause",()=>{console.log("pause",i.isActive.value),i.pause()}),e.player.on("enterfullscreen",()=>{console.log("fullscreen");const a=document.createElement("i");a.id="fullscreen-back",a.className="van-icon van-icon-arrow-left video-back",a.addEventListener("click",()=>{e.player.fullscreen.exit()}),document.getElementsByClassName("plyr")[0].appendChild(a)}),e.player.on("exitfullscreen",()=>{console.log("exitfullscreen");const a=document.getElementById("fullscreen-back");a&&a.remove()}),u(0)},v=L([]);let l=[];const p=g(1e3,{controls:!0});I(()=>i.isActive.value,o=>{y(o)});const y=(o,r=!1)=>{const t=V(l);if(r?l.length>0&&(l[1]=Math.floor(e.player.currentTime)):o?l[0]=Math.floor(e.player.currentTime):l[1]=Math.floor(e.player.currentTime),l.length>=2){const a=l[1]-l[0]-p.counter.value*e.playerSpeed>2;l[1]>=l[0]&&!a&&v.value.push(l),r?l=V(t):(l=[],p.counter.value=0)}};I(D,o=>{console.log("watch",o),o=="hidden"&&e.player.pause()});const h=async(o=10)=>{try{const r=v.value.length>0?m(v.value):[],t=r.length>0?R(r):0,a=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(r),videoBrowseDataTime:t||0,videoBrowsePercentage:a||0,videoBrowseTime:i==null?void 0:i.counter.value,videoBrowsePoint:Math.floor(e.player.currentTime||0)}})}catch{}},b=async()=>{var o,r;try{e.player.pause(),(o=e.intervalFnRef)==null||o.pause(),p.pause(),i.pause(),c.pause(),y(i.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"),(r=e.intervalFnRef)==null||r.resume(),c.resume(),p.resume()}};x(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,e.registerDisplay=o.registerDisplay,(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=G(async()=>{c.counter.value=0,c.resume(),y(!1,!0),await h(),i.counter.value=0},1e4)}catch{}}),B(()=>{var o,r;(o=e.player)==null||o.fullscreen.exit(),(r=e.intervalFnRef)==null||r.pause(),p.pause(),c.pause()}),e.openId||C.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)}),()=>n("div",{class:d["pre-register-video"]},[n("div",{class:d.videoContainer},[n("div",{class:d["video-content"]},[n("video",{id:"register-video",class:d.video,src:e.introductionVideo,playsinline:!0,poster:e.coverImg,preload:"auto"},null),e.loading&&n("div",{class:d.loadingVideo},[n(H,{size:36,color:"#FF8057",vertical:!0,style:{height:"100%",justifyContent:"center"}},{default:()=>[O("\u52A0\u8F7D\u4E2D...")]})])])]),n("div",{class:d.videoCount},[n("div",{class:d.videoTitle},null),n("div",{class:d.videoCountContent},[e.videoDetails.map(o=>n("span",{class:[o.id===e.videoSelectId?d.active:""],onClick:()=>{e.player.currentTime=o.startNode,e.player.play(),e.videoBrowsePoint=o.startNode,u(e.player.currentTime)}},[o.desc]))])]),n("div",{class:d.messageContainer},[n("div",{class:d.messageContent},[n("div",{innerHTML:e.parentConferencesNotes},null),e.registerDisplay&&n(U,{class:d.submitBtn,onClick:b},null)])])])}});export{W as default};
|