1 |
- import{d as b,ah as x,ag as A,b0 as M,r as L,R as q,Z as C,$ as H,m as B,b7 as N,c as s,L as j,q as O,B as _,bd as U}from"./index.f2940478.js";import{s as d}from"./video.module.60ee571d.js";import{T as g}from"./tcplayer.v4.8.0.min.d79f74d0.js";/* empty css */import{d as D}from"./deep-clone.c5af4e6b.js";import{u as m,b as $}from"./index.5c31d467.js";var Q=b({name:"pre-register",setup(){const f=x(),F=A(),E=M(),V=sessionStorage.getItem("active-open-id"),c=m(1e3,{controls:!0});c.pause();const e=L({videoID:"video"+Date.now()+Math.floor(Math.random()*100),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:"",registerDisplay:!0}),i=m(1e3,{controls:!0});i.pause();const h=t=>{const r=[];t.sort((a,n)=>a[0]-n[0]);let o=t[0];for(let a=1;a<t.length;a++){const n=t[a];o[1]>=n[0]?o[1]=Math.max(n[1],o[1]):(r.push(o),o=n)}return r.push(o),R(r)},R=t=>{const r=[],o=e.pointVideo.startNode,a=e.pointVideo.endNode;return t.forEach(n=>{n[1]>=n[0]&&(n[0]>=o&&n[0]<=a&&n[1]<=a&&r.push(n),n[0]>=o&&n[0]<=a&&n[1]>a&&r.push([n[0],a]),n[0]<o&&n[1]>o&&n[1]<=a&&r.push([o,n[1]]),n[0]<o&&n[1]>o&&n[1]>a&&r.push([o,a]))}),r},P=t=>{const r=h(t);let o=0;return r.forEach(a=>{o+=a[1]-a[0]}),o},u=t=>{e.videoDetails.forEach(r=>{r.startNode<=t&&t<=r.endNode&&(e.videoSelectId=r.id)})},S=()=>{const t=g.getComponent("Button"),r=g.getComponent("BigPlayButton");r.prototype.createEl=function(){const o=t.prototype.createEl.call(this),a='<button><svg width="41px"height="41px"viewBox="0 0 41 41"version="1.1"xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink"><g stroke="none"stroke-width="1"fill="none"fill-rule="evenodd"><g transform="translate(-167.000000, -155.000000)"><g transform="translate(0.000000, 85.000000)"><g transform="translate(158.000000, 70.000000)"><g transform="translate(9.000000, 0.000000)"><circle id="\u692D\u5706\u5F62"stroke="#FFFFFF"fill-opacity="0.1"fill="#D8D8D8"cx="20.5"cy="20.5"r="20"></circle><path d="M14.5483871,27.6859997 L14.5483871,13.4342349 C14.5480523,12.8729571 14.8729597,12.356555 15.3949624,12.0887034 C15.9169651,11.8208518 16.5522696,11.8445472 17.0503046,12.1504437 L28.6530473,19.2778563 C29.1119763,19.5602271 29.3887725,20.0426422 29.3887725,20.5601173 C29.3887725,21.0775924 29.1119763,21.5600075 28.6530473,21.8423783 L17.0503046,28.9697909 C16.5522696,29.2756874 15.9169651,29.2993828 15.3949624,29.0315312 C14.8729597,28.7636796 14.5480523,28.2472775 14.5483871,27.6859997 Z"id="\u8DEF\u5F84"fill="#FFFFFF"fill-rule="nonzero"></path></g></g></g></g></g></svg></button>';return o.appendChild(g.dom.createEl("div",{className:"vjs-button-icon",innerHTML:a})),o},e.player=g("register-video",{appID:"",controls:!0,plugins:{}}),e.player&&(e.player.src(e.introductionVideo),e.player.poster(e.coverImg||""),e.player.on("ready",o=>{console.log("ready",o)}),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",()=>{console.log("timeupdate",e.player.currentTime()),u(e.player.currentTime()),!i.isActive.value&&e.player.currentTime()>0&&e.player.playing&&i.resume()}),e.player.on("ended",()=>{e.player.pause()}),e.player.on("play",()=>{console.log("play"),i.resume()}),e.player.on("pause",()=>{console.log("pause",i.isActive.value),i.pause()}),e.player.on("fullscreenchange",()=>{if(e.player.isFullscreen()){console.log("fullscreen");const o=document.createElement("i");o.id="fullscreen-back",o.className="van-icon van-icon-arrow-left video-back",o.addEventListener("click",()=>{e.player.exitFullscreen()}),document.getElementsByClassName("video-js")[0].appendChild(o)}else{console.log("exitfullscreen");const o=document.getElementById("fullscreen-back");o&&o.remove()}})),u(0)},v=q([]);let l=[];const p=m(1e3,{controls:!0});C(()=>i.isActive.value,t=>{console.log(i.isActive.value,"videoIntervalRef"),y(t)});const y=(t,r=!1)=>{const o=D(l);if(r?l.length>0&&(l[1]=Math.floor(e.player.currentTime)):t?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=D(o):(l=[],p.counter.value=0)}};C(E,t=>{console.log("watch",t),t=="hidden"&&e.player.pause()});const w=async(t=10)=>{try{const r=v.value.length>0?h(v.value):[],o=r.length>0?P(r):0,a=Math.floor(o/Math.floor(e.pointVideoTime)*100);await B.post("/api-student/open/studentBrowseRecord/updateStat",{data:{id:e.saveId,pageBrowseTime:t,videoBrowseData:JSON.stringify(r),videoBrowseDataTime:o||0,videoBrowsePercentage:a||0,videoBrowseTime:i==null?void 0:i.counter.value,videoBrowsePoint:Math.floor(e.player.currentTime()||0)}})}catch{}},k=async()=>{var t,r;try{e.player.pause(),(t=e.intervalFnRef)==null||t.pause(),p.pause(),i.pause(),c.pause(),y(i.isActive.value),await w(),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?"+U.stringify({orchestraId:e.orchestraId,openId:e.openId})}catch(o){console.log(o,"e"),(r=e.intervalFnRef)==null||r.resume(),c.resume(),p.resume()}};H(async()=>{try{const{data:t}=await B.get("/api-student/open/studentBrowseRecord/query",{params:{openId:e.openId,orchestraId:e.orchestraId}});e.videoBrowsePoint=t.videoBrowsePoint||0,e.player&&e.player.currentTime(t.videoBrowsePoint||0),e.introductionVideo=t.introductionVideo,e.introductionVideoTime=t.introductionVideoTime,e.coverImg=t.coverImg,v.value=t.videoBrowseData?JSON.parse(t.videoBrowseData):[],e.parentConferencesNotes=t.parentConferencesNotes,e.orchestraRegisterType=t.orchestraRegisterType,e.registerDisplay=t.registerDisplay,(t.videoDetails||[]).forEach(o=>{e.videoDetails.push({startNode:o.startNode,endNode:o.endNode,desc:o.desc,id:o.id}),o.pointFlag&&(e.pointVideo=o,e.pointVideoTime=o.endNode-o.startNode)}),S(),e.intervalFnRef=$(async()=>{c.counter.value=0,c.resume(),y(!1,!0),await w(),i.counter.value=0},1e4)}catch{}}),N(()=>{var t,r;(t=e.player)==null||t.fullscreen.exit(),(r=e.intervalFnRef)==null||r.pause(),p.pause(),c.pause()}),e.openId||F.replace({path:"/pre-register-video",query:{id:e.orchestraId}});const T=()=>{e.isPageHide&&window.location.reload()};window.addEventListener("pageshow",T);const I=()=>{e.isPageHide=!0};return window.addEventListener("pagehide",I),N(()=>{window.removeEventListener("pageshow",T),window.removeEventListener("pagehide",I)}),()=>s("div",{class:d["pre-register-video"]},[s("div",{class:d.videoContainer},[s("div",{class:d["video-content"]},[s("video",{id:"register-video",class:d.video,src:e.introductionVideo,playsinline:!0,poster:e.coverImg,preload:"auto"},null),e.loading&&s("div",{class:d.loadingVideo},[s(j,{size:36,color:"#FF8057",vertical:!0,style:{height:"100%",justifyContent:"center"}},{default:()=>[O("\u52A0\u8F7D\u4E2D...")]})])])]),s("div",{class:d.videoCount},[s("div",{class:d.videoTitle},null),s("div",{class:d.videoCountContent},[e.videoDetails.map(t=>s("span",{class:[t.id===e.videoSelectId?d.active:""],onClick:()=>{e.player.currentTime(t.startNode),e.player.play(),e.videoBrowsePoint=t.startNode,u(e.player.currentTime())}},[t.desc]))])]),s("div",{class:d.messageContainer},[s("div",{class:d.messageContent},[s("div",{innerHTML:e.parentConferencesNotes},null),e.registerDisplay&&s(_,{class:d.submitBtn,onClick:k},null)])])])}});export{Q as default};
|