| 1 |
- import{d as R,ah as q,ag as L,aY as M,r as x,R as H,Z as A,$ as j,m as D,b3 as T,c as s,L as J,q as l,B as O,f as z}from"./index.ba0ad69d.js";import{s as i}from"./video.module.c48c72d5.js";import{P as U}from"./plyr.min.22fd58dd.js";/* empty css */import{q as Y}from"./index.339fc024.js";import{u as F,b as Z}from"./index.553baa13.js";var X=R({name:"pre-register",setup(){const y=q(),N=L(),V=M(),P=sessionStorage.getItem("active-open-id"),p=F(1e3,{controls:!0});p.pause();const e=x({coverImg:"",introductionVideo:"",introductionVideoTime:0,videoBrowsePoint:0,saveId:y.query.saveId,orchestraId:y.query.id,openId:y.query.openId||P,loading:!1,player:null,playerSpeed:1,intervalFnRef:null,videoDetails:[],pointVideo:{},pointVideoTime:0,videoSelectId:null,isPageHide:!1}),n=F(1e3,{controls:!0});n.pause();const B=o=>{const u=[];o.sort((r,f)=>r[0]-f[0]);let t=o[0];for(let r=1;r<o.length;r++){const f=o[r];t[1]>=f[0]?t[1]=Math.max(f[1],t[1]):(u.push(t),t=f)}u.push(t);const a=[],v=e.pointVideo.startNode,g=e.pointVideo.endNode;return u.forEach(r=>{r[0]>=v&&r[1]<=g&&a.push(r),r[0]>=v&&r[1]>=v&&r[1]>=g&&a.push([r[0],g]),r[0]<v&&r[1]>v&&r[1]<g&&a.push(v,r[1])}),a},b=o=>{const u=B(o);console.log(u,"afterIntervals");let t=0;return u.forEach(a=>{t+=a[1]-a[0]}),t},E=o=>{e.videoDetails.forEach(u=>{u.startNode<=o&&o<=u.endNode&&(e.videoSelectId=u.id)})},S=()=>{const u={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};z().iPhone&&(u.fullscreen={enabled:!0,fallback:"force",iosNative:!0});const t=[];e.videoDetails.forEach(a=>{t.push({time:a.startNode,label:a.desc})}),u.markers={enabled:!0,points:t},e.player=new U("#register-video",u),e.player.on("loadedmetadata",()=>{console.log("loadedmetadata"),e.loading=!1,e.player.currentTime=e.videoBrowsePoint,E(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",()=>{E(e.player.currentTime),!n.isActive.value&&e.player.currentTime>0&&e.player.playing&&n.resume()}),e.player.on("ended",()=>{e.player.pause()}),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 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()}),console.log(document.getElementsByClassName("plyr")),document.getElementsByClassName("plyr")[0].appendChild(a)}),e.player.on("exitfullscreen",()=>{console.log("exitfullscreen");const a=document.getElementById("fullscreen-back");a&&a.remove()})},c=H([]);let d=[];const m=F(1e3,{controls:!0});A(()=>n.isActive.value,o=>{h(o)});const h=o=>{if(o?d[0]=Math.floor(e.player.currentTime):d[1]=Math.floor(e.player.currentTime),d.length>=2){const u=d[1]-d[0]-m.counter.value*e.playerSpeed>2;d[1]>=d[0]&&!u&&c.value.push(d),d=[],m.counter.value=0}};A(V,o=>{console.log("watch",o),o=="hidden"&&e.player.pause()});const w=async(o=10)=>{try{const u=c.value.length>0?B(c.value):[];console.log(c.value,u,"video");const t=c.value.length>0?b(c.value):0,a=Math.floor(t/Math.floor(e.pointVideoTime)*100);await D.post("/api-student/open/studentBrowseRecord/updateStat",{data:{id:e.saveId,pageBrowseTime:o,videoBrowseData:JSON.stringify(u),videoBrowseDataTime:t||0,videoBrowsePercentage:a||0,videoBrowseTime:n==null?void 0:n.counter.value,videoBrowsePoint:Math.floor(e.player.currentTime||0)}})}catch{}},k=async()=>{var o,u;try{e.player.pause(),(o=e.intervalFnRef)==null||o.pause(),m.pause(),n.pause(),p.pause(),h(n.isActive.value),await w(),window.location.href=window.location.origin+window.location.pathname+"/project/preRegister.html?"+Y.stringify({orchestraId:e.orchestraId,openId:e.openId})}catch(t){console.log(t,"e"),(u=e.intervalFnRef)==null||u.resume(),p.resume(),m.resume()}};j(async()=>{try{const{data:o}=await D.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,c.value=o.videoBrowseData?JSON.parse(o.videoBrowseData):[],(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=Z(async()=>{p.counter.value=0,p.resume(),await w(),n.counter.value=0},1e4)}catch{}}),T(()=>{var o;(o=e.intervalFnRef)==null||o.pause(),m.pause(),p.pause()}),e.openId||N.replace({path:"/pre-register-video",query:{id:e.orchestraId}});const C=()=>{console.log(e.isPageHide,"showInfo"),e.isPageHide&&window.location.reload()};window.addEventListener("pageshow",C);const I=()=>{console.log(e.isPageHide,"showInfo"),e.isPageHide=!0};return window.addEventListener("pagehide",I),T(()=>{window.removeEventListener("pageshow",C),window.removeEventListener("pagehide",I)}),()=>s("div",{class:i["pre-register-video"]},[s("div",{class:i.videoContainer},[s("div",{class:i["video-content"]},[s("video",{id:"register-video",class:i.video,src:e.introductionVideo,playsinline:!0,poster:e.coverImg,preload:"auto"},null),e.loading&&s("div",{class:i.loadingVideo},[s(J,{size:36,color:"#FF8057",vertical:!0,style:{height:"100%",justifyContent:"center"}},{default:()=>[l("\u52A0\u8F7D\u4E2D...")]})])])]),s("div",{class:i.videoCount},[s("div",{class:i.videoCountContent},[e.videoDetails.map(o=>s("span",{class:[o.id===e.videoSelectId?i.active:""],onClick:()=>{e.player.currentTime=o.startNode}},[o.desc]))])]),s("div",{class:i.messageContainer},[s("div",{class:i.messageContent},[s("p",null,[l("\u5BB6\u957F\u60A8\u597D\uFF01")]),s("p",{class:i.c1},[l("\u8BF7\u5BB6\u957F\u4EEC\u5408\u7406\u5B89\u6392\u65F6\u95F4\uFF0C"),s("span",null,[l("\u8BA4\u771F\u89C2\u770B")]),l("\u5BB6\u957F\u4F1A\u5185\u5BB9\u3002\u5728"),s("span",null,[l("\u8BE6\u7EC6\u4E86\u89E3")]),l("\u6240\u6709\u8981\u6C42\u540E\uFF0C\u6709\u610F\u5411\u8BA9\u5B69\u5B50\u52A0\u5165\u4E50\u56E2\u7684\u5BB6\u957F\uFF0C\u8BF7\u5728"),s("span",null,[l("\u660E\u665A20:00\u524D")]),l("\uFF0C\u4E3A\u5B69\u5B50\u5B8C\u6210"),s("span",null,[l("\u4E50\u56E2\u62A5\u540D")]),l("\u3002")]),s("p",{class:i.c1},[l("\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")]),s("p",{class:i.bottom},[l("\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")])]),s(O,{class:i.submitBtn,onClick:k},null)])])}});export{X as default};
|