| 1 |
- import{s as r}from"./video.module.98bd01e8.js";import{d as b,ah as S,ag as k,aY as R,r as q,R as N,Z as w,$ as L,m as h,b3 as C,c as a,L as M,q as n,B as x,f as H}from"./index.ed35620e.js";import{P as j}from"./plyr.min.22fd58dd.js";/* empty css */import{q as J}from"./index.339fc024.js";import{u as g,b as O}from"./index.1d322bf0.js";var G=b({name:"pre-register",setup(){const v=S(),I=k(),A=R(),T=sessionStorage.getItem("active-open-id"),c=g(1e3,{controls:!0});c.pause();const e=q({coverImg:"",introductionVideo:"",introductionVideoTime:0,videoBrowsePoint:0,saveId:v.query.saveId,orchestraId:v.query.id,openId:v.query.openId||T,loading:!1,player:null,playerSpeed:1,intervalFnRef:null,isPageHide:!1}),t=g(1e3,{controls:!0});t.pause();const F=o=>{const s=[];o.sort((i,m)=>i[0]-m[0]);let u=o[0];for(let i=1;i<o.length;i++){const m=o[i];u[1]>=m[0]?u[1]=Math.max(m[1],u[1]):(s.push(u),u=m)}return s.push(u),s},P=o=>{const s=F(o);let u=0;return s.forEach(i=>{u+=i[1]-i[0]}),u},D=()=>{const s={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};H().iPhone&&(s.fullscreen={enabled:!0,fallback:"force",iosNative:!0}),e.player=new j("#register-video",s),e.player.on("loadedmetadata",()=>{console.log("loadedmetadata"),e.loading=!1,e.player.currentTime=e.videoBrowsePoint}),e.player.on("ratechange",()=>{e.playerSpeed=e.playerSpeed<e.player.speed?e.player.speed:e.playerSpeed}),e.player.on("seeking",()=>{console.log("seeking"),t.isActive.value&&t.pause()}),e.player.on("seeked",()=>{console.log("seeked"),t.isActive.value&&t.pause()}),e.player.on("waiting",()=>{console.log("waiting pause"),t.isActive.value&&t.pause()}),e.player.on("timeupdate",()=>{!t.isActive.value&&e.player.currentTime>0&&e.player.playing&&t.resume()}),e.player.on("ended",()=>{e.player.pause()}),e.player.on("play",()=>{console.log("play"),t.resume()}),e.player.on("pause",()=>{console.log("pause",t.isActive.value),t.pause()}),e.player.on("enterfullscreen",()=>{console.log("fullscreen");const u=document.createElement("i");u.id="fullscreen-back",u.className="van-icon van-icon-arrow-left video-back",u.addEventListener("click",()=>{e.player.fullscreen.exit()}),console.log(document.getElementsByClassName("plyr")),document.getElementsByClassName("plyr")[0].appendChild(u)}),e.player.on("exitfullscreen",()=>{console.log("exitfullscreen");const u=document.getElementById("fullscreen-back");u&&u.remove()})},d=N([]);let l=[];const p=g(1e3,{controls:!0});w(()=>t.isActive.value,o=>{y(o)});const y=o=>{if(o?l[0]=Math.floor(e.player.currentTime):l[1]=Math.floor(e.player.currentTime),l.length>=2){const s=l[1]-l[0]-p.counter.value*e.playerSpeed>2;l[1]>=l[0]&&!s&&d.value.push(l),l=[],p.counter.value=0}};w(A,o=>{console.log("watch",o),o=="hidden"&&e.player.pause()});const B=async(o=10)=>{try{const s=d.value.length>0?F(d.value):[],u=d.value.length>0?P(d.value):0,i=Math.floor(u/Math.floor(e.introductionVideoTime)*100);await h.post("/api-student/open/studentBrowseRecord/updateStat",{data:{id:e.saveId,pageBrowseTime:o,videoBrowseData:JSON.stringify(s),videoBrowseDataTime:u||0,videoBrowsePercentage:i||0,videoBrowseTime:t==null?void 0:t.counter.value,videoBrowsePoint:Math.floor(e.player.currentTime||0)}})}catch{}},V=async()=>{var o,s;try{e.player.pause(),(o=e.intervalFnRef)==null||o.pause(),p.pause(),t.pause(),c.pause(),y(t.isActive.value),await B(),window.location.href=window.location.origin+window.location.pathname+"/project/preRegister.html?"+J.stringify({orchestraId:e.orchestraId,openId:e.openId})}catch(u){console.log(u,"e"),(s=e.intervalFnRef)==null||s.resume(),c.resume(),p.resume()}};L(async()=>{try{const{data:o}=await h.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,d.value=o.videoBrowseData?JSON.parse(o.videoBrowseData):[],D(),e.intervalFnRef=O(async()=>{c.counter.value=0,c.resume(),await B(),t.counter.value=0},1e4)}catch{}}),C(()=>{var o;(o=e.intervalFnRef)==null||o.pause(),p.pause(),c.pause()}),e.openId||I.replace({path:"/pre-register-video",query:{id:e.orchestraId}});const f=()=>{console.log(e.isPageHide,"showInfo"),e.isPageHide&&window.location.reload()};window.addEventListener("pageshow",f);const E=()=>{console.log(e.isPageHide,"showInfo"),e.isPageHide=!0};return window.addEventListener("pagehide",E),C(()=>{window.removeEventListener("pageshow",f),window.removeEventListener("pagehide",E)}),()=>a("div",{class:r["pre-register-video"]},[a("div",{class:r.videoContainer},[a("div",{class:r["video-content"]},[a("video",{id:"register-video",class:r.video,src:e.introductionVideo,playsinline:!0,poster:e.coverImg,preload:"auto"},null),e.loading&&a("div",{class:r.loadingVideo},[a(M,{size:36,color:"#FF8057",vertical:!0,style:{height:"100%",justifyContent:"center"}},{default:()=>[n("\u52A0\u8F7D\u4E2D...")]})])])]),a("div",{class:r.messageContainer},[a("div",{class:r.messageContent},[a("p",null,[n("\u5BB6\u957F\u60A8\u597D\uFF01")]),a("p",{class:r.c1},[n("\u8BF7\u5BB6\u957F\u4EEC\u5408\u7406\u5B89\u6392\u65F6\u95F4\uFF0C"),a("span",null,[n("\u8BA4\u771F\u89C2\u770B")]),n("\u5BB6\u957F\u4F1A\u5185\u5BB9\u3002\u5728"),a("span",null,[n("\u8BE6\u7EC6\u4E86\u89E3")]),n("\u6240\u6709\u8981\u6C42\u540E\uFF0C\u6709\u610F\u5411\u8BA9\u5B69\u5B50\u52A0\u5165\u4E50\u56E2\u7684\u5BB6\u957F\uFF0C\u8BF7\u5728"),a("span",null,[n("\u660E\u665A20:00\u524D")]),n("\uFF0C\u4E3A\u5B69\u5B50\u5B8C\u6210"),a("span",null,[n("\u4E50\u56E2\u62A5\u540D")]),n("\u3002")]),a("p",{class:r.c1},[n("\u4E0B\u5468\uFF0C\u4E13\u4E1A\u8001\u5E08\u5C06\u9488\u5BF9\u610F\u5411\u5165\u56E2\u5B66\u5458\u8FDB\u884C\u8EAB\u4F53\u6761\u4EF6\u786E\u8BA4\u3002\u8C22\u8C22\u5404\u4F4D\u7684\u652F\u6301\uFF01")]),a("p",{class:r.bottom},[n("\u6CE8\uFF1A\u4E50\u56E2\u4E8E\u4E0B\u5B66\u671F\u6B63\u5F0F\u5F00\u59CB\u8BAD\u7EC3\uFF0C\u8BAD\u7EC3\u65F6\u95F4\u4E0B\u5B66\u671F\u5F00\u5B66\u524D\u53E6\u884C\u901A\u77E5\uFF0C\u8BAD\u7EC3\u65F6\u95F4\u4F1A\u4E0E\u5B66\u6821\u5176\u4ED6\u793E\u56E2\u9519\u5F00\uFF0C\u5BB6\u957F\u65E0\u9700\u62C5\u5FC3\u65F6\u95F4\u51B2\u7A81\u95EE\u9898\u3002")])]),a(x,{class:r.submitBtn,onClick:V},null)])])}});export{G as default};
|