"use strict";var e=Object.defineProperty,i=Object.defineProperties,t=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,r=(i,t,s)=>t in i?e(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s,a=(e,i)=>{for(var t in i||(i={}))n.call(i,t)&&r(e,t,i[t]);if(s)for(var t of s(i))o.call(i,t)&&r(e,t,i[t]);return e},l=(e,s)=>i(e,t(s)),h=require("../common/vendor.js"),u=require("../utils/common.js"),d=require("../api/course.js");require("../api/user.js"),require("../common/request.js");const p={data:()=>({baseUrl:h.index.getStorageSync("requestPath"),rewardType:[{name:"红包奖励",value:1},{name:"积分奖励",value:2}],currentReward:1,player:null,loading:!0,progress:0,code:null,statusBarHeight:h.index.getSystemInfoSync().statusBarHeight,scrollTop:0,height:"0px",isLogin:!0,videoUrl:"",videoId:"",playTime:0,duration:0,playDuration:0,playDurationSeek:0,tipsTime:0,tipsOpen:!1,config:{},courseInfo:{},quesList:[],lineList:[],errQues:[],remain:0,errTitle:"",errDesc:"",showPlay:!0,showControls:!1,playStatus:"",isFullscreen:!1,isAddKf:0,lineIndex:0,isExpand:!0,textHeight:0,qwUserId:"",qrcode:"",corpId:"",qrcodeMsg:"",urlOption:{},bufferRate:0,uuId:"",isEnded:!1,linkType:0,ip:null,checked:!0,isFinish:0,interval:null,intervalIntegral:null,options:{sources:[{src:""}],poster:"",live:!1,controls:!0,autoplay:!1,licenseUrl:"https://license.vod2.myqcloud.com/license/v2/1323137866_1/v_cube.license",LicenseKey:"bcc5bd9a14b798b48c52ff005a21d926",controlBar:{volumePanel:!1,playbackRateMenuButton:!1,QualitySwitcherMenuButton:!1},plugins:{ContextMenu:{statistic:!1}}},errorCount:0,answerPopup:!1,sortLink:"",isExpire:!0,menuButtonLeft:281,menuButtonH:45,timer:null,flag:!1}),filters:{numberToChinese(e){if(e){return["一","二","三","四","五","六","七","八","九"][e-1]}return""}},computed:{isAnswer:()=>(e,i)=>{if(1==e.type)return e.answer==i;if(2==e.type){return e.answer.split(",").some((e=>e==i))}return!1}},onLoad(e){this.code=e.code,this.urlOption=e.course?JSON.parse(e.course):{},this.videoId=this.urlOption.videoId,this.qwUserId=this.urlOption.qwUserId||"",this.corpId=this.urlOption.corpId||"",this.linkType=this.urlOption.linkType||0,this.sortLink=this.urlOption.link||"",this.getMenuButton()},onShow(){this.tipsOpen=!1,this.isExpand=!0,this.uuId=u.generateRandomString(16),this.videoId&&this.getH5CourseByVideo(),this.sortLink?this.getLink():h.index.showToast({title:"sortLink is not found",icon:"none"})},mounted(){this.getIP(),this.getHeight()},onHide(){this.player&&this.player.pause()},onUnload(){null!=this.interval&&(clearInterval(this.interval),this.interval=null),this.clearIntegral()},beforeDestroy(){this.player=h.index.createVideoContext("video-content-box"),this.player&&(this.player.stop(),this.player=null),null!=this.interval&&(clearInterval(this.interval),this.interval=null),this.clearIntegral()},methods:{getMenuButton(){const e=h.index.getMenuButtonBoundingClientRect();this.menuButtonLeft=e.left,this.menuButtonH=e.height},onTimeUpdate(e){let i=Math.round(e.detail.currentTime);this.playDurationSeek>0?(this.playTime=this.playDurationSeek,this.throttle((()=>this.changeTime(this)),1e3,!1)):(1!=this.linkType&&(i-this.playTime>3||i-this.playTime<-3)&&1!=this.isFinish&&(h.index.showToast({title:"不能快进哦",icon:"none"}),i=this.playTime,this.player.seek(this.playTime)),this.playTime=i)},changeTime(e,i){e.playDurationSeek=0},videoErrorCallback(e){this.clearIntegral(),this.errorCount++,this.errorCount>3||(console.log(e),this.getErrMsg(e.target.errMsg),this.getH5CourseVideoDetails("error"))},getPlay(){this.errorCount=0,this.judgeDuration()},getPause(){this.clearIntegral()},getEnded(){this.clearIntegral(),this.isEnded=!0,this.getFinishCourseVideo()},getIP(){h.index.request({url:"https://ipinfo.io/json",method:"GET",success:e=>{this.ip=e.data.ip}})},getHeight(){this.$nextTick((()=>{h.index.createSelectorQuery().in(this).select("#title-content").boundingClientRect((e=>{this.height=`calc(100vh - ${e.height}px - 420rpx - ${this.statusBarHeight}px - 164rpx - 88rpx)`})).exec()}))},getDescHeight(){this.$nextTick((()=>{h.index.createSelectorQuery().in(this).select("#descbox-desc").boundingClientRect((e=>{this.textHeight=e.height})).exec()}))},numberToLetter(e){let i=e+65;return String.fromCharCode(i)},updateTime(){var e=this;null!=this.interval&&clearInterval(this.interval),this.interval=setInterval((function(){e.getFinishCourseVideo(),e.getInternetTraffic()}),6e4)},judgeDuration(){var e=this;null!=this.intervalIntegral&&(clearInterval(this.intervalIntegral),this.intervalIntegral=null),this.intervalIntegral=setInterval((function(){e.getIntegralByH5Video()}),6e5)},clearIntegral(){null!=this.intervalIntegral&&(clearInterval(this.intervalIntegral),this.intervalIntegral=null)},handleExpand(){this.isExpand=!this.isExpand},getH5CourseByVideo(){this.loading=!0,d.getH5CourseByVideoId({videoId:this.videoId}).then((e=>{this.loading=!1,200==e.code&&(this.courseInfo=e.data,h.index.setNavigationBarTitle({title:this.courseInfo&&this.courseInfo.title?this.courseInfo.title:""})),this.getHeight(),this.getDescHeight()}),(e=>{this.loading=!1})).catch((()=>{this.loading=!1}))},getH5CourseVideoDetails(e){d.getH5CourseVideoDetails(this.urlOption).then((i=>{if(200==i.code){this.config=i.config||{},this.isFinish=i.isFinish||0,this.duration=i.course&&i.course.duration?i.course.duration:0,this.playDuration=i.playDuration||0,this.playDurationSeek=i.playDuration||0,this.tipsTime=i.tipsTime||0;let t=[];i.course&&i.course.lineOne&&t.push(i.course.lineOne),i.course&&i.course.lineTwo&&t.push(i.course.lineTwo),i.course&&i.course.lineThree&&t.push(i.course.lineThree),this.lineList=t,this.player&&"error"!=e?(this.playTime=this.playTime>this.playDuration?this.playTime:this.playDuration>=this.duration?0:this.playDuration,this.player.seek(this.playTime),this.player.play()):(this.lineIndex=this.config.defaultLine,this.videoUrl=t[this.lineIndex],this.poster=i.course&&i.course.imgUrl?i.course.imgUrl:"",this.playTime=this.playDuration>=this.duration?0:this.playDuration,setTimeout((()=>{this.player=h.index.createVideoContext("video-content-box"),this.player.seek(this.playTime),this.player.play()}),500)),this.updateTime(),this.quesList=i.questions&&i.questions.length>0?i.questions:[],this.quesList=this.quesList.map((e=>l(a({},e),{questionOption:JSON.parse(e.question),answer:""})))}this.getHeight(),this.getDescHeight()}),(e=>{}))},handleAnswer(e,i,t){let s=this.playTime;if(this.isEnded?s=this.duration:s{e?1==this.isAddKf?this.courseAnswer():this.videoId&&this.qwUserId?this.getIsAddKf():h.index.showToast({title:"请添加客服",icon:"none"}):this.goLogin()}),(e=>{}))},courseAnswer(){let e=this.playTime;if(this.isEnded?e=this.duration:e!e.answer)))return void h.index.showToast({title:"请确认是否答完所有题目",icon:"none"});const i=this.quesList.map((e=>{const i=e,{questionOption:t}=i;return((e,i)=>{var t={};for(var r in e)n.call(e,r)&&i.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&s)for(var r of s(e))i.indexOf(r)<0&&o.call(e,r)&&(t[r]=e[r]);return t})(i,["questionOption"])})),t=l(a({},this.urlOption),{questions:i,videoId:this.videoId,duration:this.playTime});this.errTitle="",this.errDesc="",this.errQues=[],d.courseAnswer(t).then((e=>{200==e.code?e.incorrectQuestions?(e.incorrectQuestions.length>0&&(this.errQues=e.incorrectQuestions),this.remain=e.remain||0,e.remain>0&&(this.errTitle="很遗憾答错了",this.errDesc=`还有${e.remain}次机会,继续加油`,this.$refs.answerPopup.open("center"))):(this.errTitle="恭喜你,回答正确",this.errDesc="请选择奖励",this.$refs.answerPopup.open("center")):"该课题到达答错次数限制"==e.msg?(this.errTitle="答题次数超过限制",this.errDesc="以后的课程要认真学习哦",this.$refs.answerPopup.open("center")):h.index.showToast({title:e.msg,icon:"none"})}),(e=>{}))},rewardChange(e){this.currentReward=e.detail.value},closeAnswerPopup(){if(this.$refs.answerPopup.close(),"恭喜你,回答正确"==this.errTitle){const e=l(a({},this.urlOption),{rewardType:Number(this.currentReward),source:2});d.sendReward(e).then((e=>{h.index.showToast({title:e.msg,icon:"none"})}))}},openPop(){this.$refs.popup.open("bottom")},close(){this.$refs.popup.close()},handleLine(e){var i=this;this.lineIndex!=e||this.videoUrl!=this.lineList[e]?(this.lineIndex=e,this.videoUrl=this.lineList[e],this.tipsOpen=!1,this.playDurationSeek=this.playTime||0,this.player=h.index.createVideoContext("video-content-box"),setTimeout((function(){i.player.seek(i.playDurationSeek),i.player.play()}),500),this.close()):this.close()},openTipsPop(){this.$refs.tipsPopup.open(),this.tipsOpen=!0,this.pause()},closeTipsPop(){this.$refs.tipsPopup.close()},getIsAddKf(){this.qrcode="",this.qrcodeMsg="",this.isAddKf=0,d.getIsAddKf(this.urlOption).then((e=>{200==e.code?(this.isAddKf=1,this.getH5CourseVideoDetails()):400==e.code?(this.isAddKf=0,this.qrcode=e.qrcode,this.qrcodeMsg=e.msg,this.$refs.kfPopup.open()):504==e.code?this.goLogin():(this.isAddKf=0,h.index.showToast({title:e.msg,icon:"none"}))}),(e=>{}))},closeKFPop(){this.$refs.kfPopup.close()},getFinishCourseVideo(){if(!this.playTime)return;const e=a({duration:this.playTime},this.urlOption);d.getFinishCourseVideo(e)},getIntegralByH5Video(){const e=a({duration:this.playTime},this.urlOption);d.getIntegralByH5Video(e).then((e=>{200==e.code&&h.index.showToast({title:"积分+10",icon:"none"})}))},progressChange(e){this.bufferRate=Math.ceil(e.detail.buffered)},getInternetTraffic(){const e=Math.ceil(this.playTime/this.duration*100);if((0==this.bufferRate||this.bufferRate{console.log("当前的环境商",e),e||reject(),h.index.login({provider:e,success:async i=>{console.log(i),h.index.getUserInfo({provider:e,success:e=>{h.index.showToast({title:"处理中...",icon:"loading"}),d.loginByMp({code:i.code,encryptedData:e.encryptedData,iv:e.iv}).then((e=>{h.index.hideLoading(),200==e.code?(h.index.setStorageSync("AppTokenmini_RTCourse",e.token),h.index.setStorageSync("userInfo",JSON.stringify(e.user)),this.isLogin=!0,this.getIsAddKf()):h.index.showToast({title:e.msg,icon:"none"})})).catch((e=>{h.index.hideLoading(),h.index.showToast({icon:"none",title:"登录失败,请重新登录"})}))}})}})})).catch((e=>{}))},getLink(){d.getRealLink({sortLink:this.sortLink}).then((e=>{200==e.code?(this.isExpire=!1,this.isLogin&&1==this.isAddKf&&this.getH5CourseVideoDetails(),this.videoId&&1!=this.isAddKf&&this.$isLoginCourse().then((e=>{this.isLogin=e,e?this.getIsAddKf():this.goLogin()}),(e=>{}))):(this.isExpire=!0,h.index.showToast({title:"课程已过期或链接无效",icon:"none"}))})).catch((e=>{this.isExpire=!0,h.index.showToast({title:"发生错误,请稍后再试",icon:"none"})}))},throttle(e,i=500,t=!0){t?this.flag||(this.flag=!0,"function"==typeof e&&e(),this.timer=setTimeout((()=>{this.flag=!1}),i)):this.flag||(this.flag=!0,this.timer=setTimeout((()=>{this.flag=!1,"function"==typeof e&&e()}),i))}}};if(!Array){h.resolveComponent("uni-popup")()}Math;var c=h._export_sfc(p,[["render",function(e,i,t,s,n,o){return h.e({a:h.t(n.courseInfo.title),b:n.menuButtonLeft+"px",c:n.menuButtonH+"px",d:n.menuButtonH+"px",e:`calc(88rpx + ${n.statusBarHeight}px)`,f:n.statusBarHeight+"px",g:!n.isLogin||1!=n.isAddKf},n.isLogin&&1==n.isAddKf?{}:{h:n.courseInfo.imgUrl},{i:h.o(((...e)=>o.onTimeUpdate&&o.onTimeUpdate(...e))),j:h.o(((...e)=>o.progressChange&&o.progressChange(...e))),k:h.o(((...e)=>o.videoErrorCallback&&o.videoErrorCallback(...e))),l:h.o(((...e)=>o.getPlay&&o.getPlay(...e))),m:h.o(((...e)=>o.getPause&&o.getPause(...e))),n:h.o(((...e)=>o.getEnded&&o.getEnded(...e))),o:n.courseInfo.title,p:e.poster,q:[],r:n.videoUrl,s:n.isLogin&&1==n.isAddKf},n.isLogin&&1==n.isAddKf?{t:h.t(n.courseInfo.title)}:{v:h.t(n.courseInfo.courseName)},{w:!n.isLogin||1!=n.isAddKf},n.isLogin&&1==n.isAddKf?{}:h.e({x:h.t(n.courseInfo.title),y:n.textHeight>21},n.textHeight>21?{z:h.t(n.isExpand?"收起简介":"展开简介"),A:h.o(((...e)=>o.handleExpand&&o.handleExpand(...e))),B:n.baseUrl+"/images/course_arrow_up_icon.png",C:n.isExpand,D:n.baseUrl+"/images/course_arrow_down_icon.png",E:!n.isExpand}:{}),{F:h.t(n.courseInfo.description),G:n.isLogin&&1==n.isAddKf&&n.textHeight>21},n.isLogin&&1==n.isAddKf&&n.textHeight>21?{H:h.t(n.isExpand?"收起简介":"展开简介"),I:h.o(((...e)=>o.handleExpand&&o.handleExpand(...e))),J:n.baseUrl+"/images/course_arrow_up_icon.png",K:n.isExpand,L:n.baseUrl+"/images/course_arrow_down_icon.png",M:!n.isExpand,N:h.n(n.isExpand?"expand":"expand expand-ab")}:{},{O:n.isExpand?"auto":"42rpx",P:n.isLogin&&1==n.isAddKf},n.isLogin&&1==n.isAddKf?{Q:h.f(n.quesList,((e,i,t)=>({a:h.t(i+1),b:h.t(1==e.type?"单选":2==e.type?"多选":""),c:1==e.type||2==e.type,d:h.t(e.title),e:h.f(e.questionOption,((i,t,s)=>({a:h.t(o.numberToLetter(t)),b:h.t(i.name),c:h.n(o.isAnswer(e,i.name)?"ques-option ques-option-active":"ques-option"),d:t,e:h.o((t=>o.handleAnswer(e,i)),t)}))),f:i})))}:{},{R:n.height,S:n.scrollTop,T:n.isLogin&&1==n.isAddKf},n.isLogin&&1==n.isAddKf?{U:n.baseUrl+"/images/changePlayer-icon.png",V:h.t(n.lineIndex+1|e.numberToChinese),W:h.o(((...e)=>o.openPop&&o.openPop(...e)))}:{},{X:n.baseUrl+"/images/tc_close_icon.png",Y:h.o(((...e)=>o.close&&o.close(...e))),Z:h.f(n.lineList,((i,t,s)=>({a:h.t(t+1|e.numberToChinese),b:h.n(n.lineIndex==t?"line-item line-active":"line-item"),c:t,d:h.o((e=>o.handleLine(t)),t)}))),aa:h.sr("popup","0bb59292-0"),ab:h.p({type:"bottom"}),ac:n.baseUrl+"/images/red_envelope_img.png",ad:n.baseUrl+"/images/course_close_white_icon.png",ae:h.o(((...e)=>o.closeTipsPop&&o.closeTipsPop(...e))),af:n.baseUrl+"/images/tips_title_img.png",ag:h.o(((...e)=>o.closeTipsPop&&o.closeTipsPop(...e))),ah:h.sr("tipsPopup","0bb59292-1"),ai:h.p({type:"center","is-mask-click":!1}),aj:"恭喜你,回答正确"==n.errTitle},"恭喜你,回答正确"==n.errTitle?{ak:n.baseUrl+"/images/course_answer_img.png"}:{al:n.baseUrl+"/images/course_answer_incorrectly_img.png"},{am:h.t(n.errTitle),an:n.errDesc,ao:"恭喜你,回答正确"==n.errTitle},"恭喜你,回答正确"==n.errTitle?{ap:h.f(n.rewardType,((e,i,t)=>({a:e.value+"",b:e.value==n.currentReward,c:h.t(e.name),d:e.value==n.currentReward?"#FF5C03":"",e:e.value}))),aq:h.o(((...e)=>o.rewardChange&&o.rewardChange(...e)))}:{},{ar:n.errQues&&n.errQues.length>0},n.errQues&&n.errQues.length>0?{as:h.f(n.errQues,((e,i,t)=>({a:h.t(e.title),b:i})))}:{},{at:"恭喜你,回答正确"==n.errTitle},"恭喜你,回答正确"==n.errTitle?{av:h.o(((...e)=>o.closeAnswerPopup&&o.closeAnswerPopup(...e)))}:{aw:h.t(n.remain>0?"重新答题":"确认"),ax:h.o(((...e)=>o.closeAnswerPopup&&o.closeAnswerPopup(...e))),ay:n.errQues&&n.errQues.length>0?"40rpx":"54rpx"},{az:h.n("恭喜你,回答正确"==n.errTitle?"answerPopup-box bg":"answerPopup-box"),aA:h.sr("answerPopup","0bb59292-2"),aB:h.p({type:"center",show:n.answerPopup}),aC:n.qrcode,aD:n.qrcodeMsg,aE:n.qrcodeMsg,aF:n.baseUrl+"/images/course_close_white_icon.png",aG:h.o(((...e)=>o.closeKFPop&&o.closeKFPop(...e))),aH:h.sr("kfPopup","0bb59292-3"),aI:h.p({type:"center","mask-click":!1}),aJ:n.videoId},n.videoId?{aK:n.isLogin&&1==n.isAddKf,aL:n.baseUrl+"/images/red_envelope_btnimg.png",aM:h.t(n.isLogin&&1==n.isAddKf?"提交答案领取奖励":"立即学习"),aN:h.n(n.isLogin&&1==n.isAddKf?"footer-btn footer-btn-border":"footer-btn"),aO:h.o(((...e)=>o.submit&&o.submit(...e)))}:{})}],["__scopeId","data-v-0bb59292"]]);wx.createPage(c);