1 |
- import{d as S,ah as k,ag as R,b0 as q,r as L,R as M,Z as B,$ as x,m as I,b7 as T,c as i,L as H,q as c,B as j,f as J,bi as O}from"./index.5f7ffb46.js";import{s as u}from"./video.module.177dd31a.js";import{P as z}from"./plyr.min.cb0f7b0b.js";/* empty css */import{u as y,b as U}from"./index.da1fa078.js";var Q=S({name:"pre-register",setup(){const m=k(),C=R(),A=q(),D=sessionStorage.getItem("active-open-id"),d=y(1e3,{controls:!0});d.pause();const e=L({coverImg:"",introductionVideo:"",introductionVideoTime:0,videoBrowsePoint:0,saveId:m.query.saveId,orchestraId:m.query.id,openId:m.query.openId||D,loading:!1,player:null,playerSpeed:1,intervalFnRef:null,videoDetails:[],pointVideo:{},pointVideoTime:0,videoSelectId:null,isPageHide:!1}),r=y(1e3,{controls:!0});r.pause();const g=o=>{const a=[];o.sort((s,n)=>s[0]-n[0]);let t=o[0];for(let s=1;s<o.length;s++){const n=o[s];t[1]>=n[0]?t[1]=Math.max(n[1],t[1]):(a.push(t),t=n)}return a.push(t),N(a)},N=o=>{const a=[],t=e.pointVideo.startNode,s=e.pointVideo.endNode;return o.forEach(n=>{n[0]>=t&&n[1]<=s&&a.push(n),n[0]>=t&&n[1]<=s&&n[1]>=s&&a.push([n[0],s]),n[0]<t&&n[1]>t&&n[1]<s&&a.push(t,n[1])}),a},V=o=>{const a=g(o);console.log(a,"afterIntervals");let t=0;return a.forEach(s=>{t+=s[1]-s[0]}),t},v=o=>{e.videoDetails.forEach(a=>{a.startNode<=o&&o<=a.endNode&&(e.videoSelectId=a.id)})},P=()=>{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};J().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 z("#register-video",a),e.player.on("ready",s=>{console.log("ready",s)}),e.player.on("loadedmetadata",()=>{console.log("loadedmetadata"),e.loading=!1,e.player.currentTime=e.videoBrowsePoint,v(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"),r.isActive.value&&r.pause()}),e.player.on("seeked",()=>{console.log("seeked"),r.isActive.value&&r.pause()}),e.player.on("waiting",()=>{r.isActive.value&&r.pause()}),e.player.on("timeupdate",()=>{console.log("timeupdate",e.player.currentTime),v(e.player.currentTime),!r.isActive.value&&e.player.currentTime>0&&e.player.playing&&r.resume()}),e.player.on("ended",()=>{e.player.pause()}),e.player.on("play",()=>{console.log("play"),r.resume()}),e.player.on("pause",()=>{console.log("pause",r.isActive.value),r.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()}),console.log(document.getElementsByClassName("plyr")),document.getElementsByClassName("plyr")[0].appendChild(s)}),e.player.on("exitfullscreen",()=>{console.log("exitfullscreen");const s=document.getElementById("fullscreen-back");s&&s.remove()}),v(0)},f=M([]);let l=[];const p=y(1e3,{controls:!0});B(()=>r.isActive.value,o=>{h(o)});const h=o=>{if(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&&f.value.push(l),l=[],p.counter.value=0}};B(A,o=>{console.log("watch",o),o=="hidden"&&e.player.pause()});const E=async(o=10)=>{try{const a=f.value.length>0?g(f.value):[],t=a.length>0?V(a):0,s=Math.floor(t/Math.floor(e.pointVideoTime)*100);await I.post("/api-student/open/studentBrowseRecord/updateStat",{data:{id:e.saveId,pageBrowseTime:o,videoBrowseData:JSON.stringify(a),videoBrowseDataTime:t||0,videoBrowsePercentage:s||0,videoBrowseTime:r==null?void 0:r.counter.value,videoBrowsePoint:Math.floor(e.player.currentTime||0)}})}catch{}},b=async()=>{var o,a;try{e.player.pause(),(o=e.intervalFnRef)==null||o.pause(),p.pause(),r.pause(),d.pause(),h(r.isActive.value),await E(),window.location.href=window.location.origin+window.location.pathname+"/project/preRegister.html?"+O.stringify({orchestraId:e.orchestraId,openId:e.openId})}catch(t){console.log(t,"e"),(a=e.intervalFnRef)==null||a.resume(),d.resume(),p.resume()}};x(async()=>{try{const{data:o}=await I.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,f.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)}),P(),e.intervalFnRef=U(async()=>{d.counter.value=0,d.resume(),await E(),r.counter.value=0},1e4)}catch{}}),T(()=>{var o;(o=e.intervalFnRef)==null||o.pause(),p.pause(),d.pause()}),e.openId||C.replace({path:"/pre-register-video",query:{id:e.orchestraId}});const w=()=>{console.log(e.isPageHide,"showInfo"),e.isPageHide&&window.location.reload()};window.addEventListener("pageshow",w);const F=()=>{console.log(e.isPageHide,"showInfo"),e.isPageHide=!0};return window.addEventListener("pagehide",F),T(()=>{window.removeEventListener("pageshow",w),window.removeEventListener("pagehide",F)}),()=>i("div",{class:u["pre-register-video"]},[i("div",{class:u.videoContainer},[i("div",{class:u["video-content"]},[i("video",{id:"register-video",class:u.video,src:e.introductionVideo,playsinline:!0,poster:e.coverImg,preload:"auto"},null),e.loading&&i("div",{class:u.loadingVideo},[i(H,{size:36,color:"#FF8057",vertical:!0,style:{height:"100%",justifyContent:"center"}},{default:()=>[c("\u52A0\u8F7D\u4E2D...")]})])])]),i("div",{class:u.videoCount},[i("div",{class:u.videoCountContent},[e.videoDetails.map(o=>i("span",{class:[o.id===e.videoSelectId?u.active:""],onClick:()=>{e.player.currentTime=o.startNode,e.player.play(),e.videoBrowsePoint=o.startNode,v(e.player.currentTime)}},[o.desc]))])]),i("div",{class:u.messageContainer},[i("div",{class:u.messageContent},[i("p",null,[c("\u6CE8\u610F\u4E8B\u9879")]),i("p",{class:u.c1},[c("1\u3001 \u8BF7\u5BB6\u957F\u4EEC\u8BA4\u771F\u89C2\u770B\u5BB6\u957F\u4F1A\u89C6\u9891\uFF0C\u4E86\u89E3\u4E50\u56E2\u4E8B\u9879\uFF1B")]),i("p",{class:u.c1},[c("2\u3001\u62A5\u540D\u622A\u6B62\u65F6\u95F4\u4E3A\u540E\u592921\uFF1A00\u524D\uFF0C\u56E0\u7F16\u5236\u6709\u9650\uFF0C\u4EE5\u62A5\u540D\u5148\u540E\u987A\u5E8F\u4E3A\u539F\u5219\u786E\u5B9A\u5E2D\u4F4D\uFF1B")]),i("p",{class:u.c1},[c("3\u3001\u5165\u56E2\u9700\u51C6\u5907\u81EA\u7528\u4E50\u5668\u548C\u4E50\u56E2AI\u5B66\u7EC3\u5DE5\u5177\uFF0C\u5BB6\u957F\u81EA\u613F\u9009\u62E9\u51C6\u5907\u65B9\u5F0F\uFF1B")]),i("p",{class:u.c1},[c("4\u3001\u4E50\u56E2\u62A5\u540D\u9700\u70B9\u51FB\u4E50\u56E2\u62A5\u540D\u6216\u626B\u7801\uFF0C\u5B8C\u6210\u63D0\u4EA4\u89C6\u4E3A\u62A5\u540D\u6210\u529F\u3002")])]),i(j,{class:u.submitBtn,onClick:b},null)])])}});export{Q as default};
|