var courseWare={init:function(){var e=this;e.courseId=e.getPar("cid"),e.courseWareId=e.getPar("rid"),e.isapp=localStorage.appAdapt=="true"||localStorage.appAdapt==!0||(e.getPar("appAdapt")?parseInt(e.getPar("appAdapt")):"")||e.getCookie("appAdapt"),e.getCookie("appAdapt")&&$(".hed_ttpa,.inrout .home,.inrout .course,.inrout .personal").hide(),e.upLoadClicktag=0,e.staticTemplate=window.location.pathname.indexOf("courseware")>-1,e.channels=e.getchannel(),e.switchURL(),e.bindEvent(),e.renderDetails(function(r){var o=r.data||{};if(e.isapp){if(e.getCookie("appAdapt")){$(".hed_ttpa,.js_back,.inrout .home,.inrout .course,.inrout .personal").hide();return}o.userTypeExact!="STUDENT"&&$(".hed_ttpa,.js_back,.toolBtn,.enterLiveBox").hide()}window.__wxjs_environment==="miniprogram"&&$(".hed_ttpa,.js_back,.toolBtn").hide()})},switchURL:function(){var e=this;if(e.courseWareId||e.goHome(),!/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(navigator.userAgent)&&!e.staticTemplate){var r=window.location.origin+"/pages/ware.html"+window.location.search;window.location.href=r}},getchannel:function(){var e=this,r,o=localStorage.appAdapt===!0||localStorage.appAdapt==="true";if(o){var a=sessionStorage.getItem("ip")||"",i=sessionStorage.getItem("channel")||"",s=o?sessionStorage.getItem("gmtStart"):0,n=o?sessionStorage.getItem("sourceId"):0,t=o?sessionStorage.getItem("sourceJson"):"",c=o?sessionStorage.getItem("sourceType"):"";r={ip:a,channel:i,gmtStart:s,sourceId:n,sourceJson:t,sourceType:c}}else{r=sessionStorage.getItem("cluechannel")?JSON.parse(sessionStorage.getItem("cluechannel")):{};var a=sessionStorage.getItem("sourceip");r.ip=a||""}var d=e.getPar("channel")||"";return d&&(r.channel=d),r.uvcid=localStorage.uvcid||"",r.pvid=sessionStorage.getItem("pvid")||"",r},yxyblogin:function(e){var r=this;if(r.getCookie("appAdapt")){/iPhone|iPad|iPod/i.test(navigator.userAgent)?window.webkit&&window.webkit.messageHandlers.PrimaryLoginForIOS.postMessage(null):window.Android&&window.Android.login();return}else e()},bindEvent:function(){var e=this;user.getAjaxRoomInfo(),$(document).on("click",".js_back",function(){e.goCourse()}),$(".inrout").on("click",".curcoll",function(){e.channels=e.getchannel(),e.isplay(),e.request({url:"/api/course/collectCourseWare?projectid=37",data:{courseWareId:e.courseWareId,pvid:e.channels.pvid,uvcid:e.channels.uvcid,shareUserId:e.channels.shareUserId,clientType:e.channels.channel},success:function(o){var a=parseInt(o.code);switch(a){case 200:$(".curcoll").addClass("curcolls");break;case 401:e.yxyblogin(function(){user.loginLayer(function(i){parseInt(i.code)==200&&e.renderDetails()})});break;case 403:e.yxyblogin(function(){user.loginLayer(function(i){parseInt(i.code)==200&&e.renderDetails()})});break;default:layer.open({content:o.message,btn:"\u786E\u5B9A"})}}})}),$(".inrout").on("click",".curcolls",function(){e.isplay(),e.request({url:"/api/course/cancelCollectCourseWare?projectid=37",data:{courseWareId:e.courseWareId},success:function(o){var a=parseInt(o.code);switch(a){case 200:$(".curcoll").removeClass("curcolls");break;case 401:e.yxyblogin(function(){user.loginLayer(function(i){parseInt(i.code)==200&&e.renderDetails()})});break;case 403:e.yxyblogin(function(){user.loginLayer(function(i){parseInt(i.code)==200&&e.renderDetails()})});break;default:layer.open({content:o.message,btn:"\u786E\u5B9A"})}}})});var r="/design/designstatic/front/images/shareBackground.png";$(document).on("click",".curshare, .shareBox ",function(){if(e.isplay(),$(".inrout").addClass("hide"),getCookie("appAdapt")){/iPhone|iPad|iPod/i.test(navigator.userAgent)?window.webkit&&window.webkit.messageHandlers.shareActionForIOS.postMessage(window.location.href):window.Android&&window.Android.share(window.location.href);return}if(e.userInfo){var o=e.coursewareDetail;o.userInfo=e.userInfo,o.iscourse=!0,o.courseName=o.courseWareName;var a=window.imgEditor,i=this,s=window.location.href;a.shareLayer(s,r,function(n){n.success||i.unlogin()},o)}else user.loginLayer(function(n){n.success&&e.renderDetails()})}),$(".enterLiveBox").on("click",".alertmessage",function(){layer.open({content:"\u5DF2\u6DFB\u52A0\u5230\u8D2D\u7269\u8F66\u3002",btn:["\u524D\u5F80\u8D2D\u7269\u8F66","\u786E\u8BA4"],yes:function(o,a){window.location.href="/pay/#/shopping"}})}),$(".enterLiveBox").on("click",".cursign",function(){if($(this).attr("data-go")=="course")return e.goCourse(),!1;var o=$(this).attr("data-coursewareType");e.upLoadClicktag==0&&(e.upLoadClicktag=1,e.isplay(),user.isLogin(function(a){a.success?e.studentBuy(a):parseInt(a.code)==401||parseInt(a.code)==403?e.yxyblogin(function(){user.loginLayer(function(i){i.success&&e.renderDetails(function(s){e.studentBuy(s)})})}):layer.open({content:"\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\uFF01",btn:"\u786E\u5B9A"})}),setTimeout(function(){e.upLoadClicktag=0},300))}),$(".enterLiveBox").on("click",".curshop",function(){if($(this).hasClass("alertmessage"))return!1;e.isplay(),user.isLogin(function(o){o.success?o.data.userTypeExact=="STUDENT"?e.isInCart==!1&&e.joinBuyCar(function(){layer.open({content:"\u52A0\u5165\u6210\u529F",skin:"msg",time:1.5}),$(".curshop").html("\u5DF2\u52A0\u5165\u8D2D\u7269\u8F66"),$(".curshop").addClass("alertmessage"),e.isInCart=!0}):layer.open({content:"\u53EA\u6709\u5B66\u751F\u8D26\u53F7\u624D\u80FD\u52A0\u5165\u8D2D\u7269\u8F66\uFF01",btn:"\u786E\u5B9A"}):parseInt(o.code)==401||parseInt(o.code)==403?e.yxyblogin(function(){user.loginLayer(function(a){a.success&&e.renderDetails(function(i){i.data.userTypeExact=="STUDENT"?e.isInCart==!0?($(".curshop").addClass("huise"),$(".alertmessage").removeClass("huise")):e.joinBuyCar(function(){e.renderDetails(),layer.open({content:"\u52A0\u5165\u6210\u529F",skin:"msg",time:1.5})}):layer.open({content:"\u53EA\u6709\u5B66\u751F\u8D26\u53F7\u624D\u80FD\u52A0\u5165\u8D2D\u7269\u8F66\uFF01",btn:"\u786E\u5B9A"})})})}):layer.open({content:"\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\uFF01",btn:"\u786E\u5B9A"})})}),$(".inrout").on("click",".home",function(){e.goHome()}),$(".inrout").on("click",".course",function(){e.goCourse()}),$(".inrout").on("click",".personal",function(){e.goPersonal()}),$(".toolBtn").on("click",function(){$(this).hide(),$(".inrout").removeClass("hide"),$(".shadowbox").show()}),$(".closeBtn, .shadowbox").on("click",function(){$(".toolBtn").show(),$(".inrout").addClass("hide"),$(".shadowbox").hide()}),$(".curriculum").on("click",".botico",function(){$(this).remove()})},renderTitle:function(){var e=this,r="";e.request({url:"/api/school/getSubheadByHostName",success:function(o){o.data.subhead!=""&&o.data.subhead?r="-"+o.data.subhead:r=o.data.subhead||"";var a="";a=e.retit+r,$("title").html(a),e.getCookie("appAdapt")&&(/iPhone|iPad|iPod/i.test(navigator.userAgent)||window.Android&&window.Android.setTitle(a))}})},renderDetails:function(e){var r=this;r.getLoginUser(e),r.getCourseWareDetail(function(o){r.carryDetails(o),r.renderTitle(),r.getM3u8()})},carryDetails:function(e){var r=this,o=e.data;r.coursewareDetail=o,$("meta[name=keywords]").attr("content",o.introduce+","+o.mainClassifyName+","+o.courseName),$("meta[name=description]").attr("content",o.introduce);var a=window.location.href,i=o.introduce,s=o.courseWareName,n=r.courseWareId,t=o.isPay,c=o.isInCart;r.isInCart=o.isInCart;var d=o.cover,l=o.price?JSON.parse(o.price):[];if(r.pre=l,r.courseWareType=o.courseWareType,r.cid=o.courseId,r.courseOnlyBalance=o.courseOnlyBalance||0,r.videoAuditionSet=o.videoAuditionSet,r.retit=o.courseWareName,$(".hea_name").text(s),r.videoAuditionSet){var p=JSON.parse(r.videoAuditionSet);r.rtime=p.time,r.rtype=parseInt(p.type);var f=''}else var f="';$(".curfengs").html(f);var g=$(".coursemain").html(o.detail);g.find("img").length<1&&g.text()==""&&$(".coursemain").html("
"),r.courseOnlyBalance==1&&(orderList[0]={courseWareId:n,courseWareName:s,orderTitle:s,orderType:2,price:l[0],paymentSource:"6"});var u="";u+=''+o.courseWareName+"",i.length>44?u+=''+o.introduce+'
':u+=''+o.introduce+"
",u+='',l[0]?u+='\uFFE5'+(l[0]/100).toFixed(2)+"":l[0]==0&&(u+='\u514D\u8D39'),l[1]&&(u+='\u81EA\u62A5\u540D\u4E4B\u65E5\u8D77'+l[1]+"\u5929\u6709\u6548"),u+="
",$(".curwithin").html(u),o.isFavorite&&$(".curcoll").addClass("curcolls"),r.carryFooter(o,e.timeStamp)},carryFooter:function(e,r){var o=this,a=e.isInCart,i=e.price?JSON.parse(e.price):[],s="",n="",t=["1","2","3","4","5"];e.isPay==!0?t.indexOf(e.courseWareType)>-1?e.allowBackView&&e.gmtCourseEnd\u7ACB\u5373\u62A5\u540D':(s+='\u7ACB\u5373\u62A5\u540D
',a==!0?s+='\u5DF2\u52A0\u5165\u8D2D\u7269\u8F66
':s+='\u52A0\u5165\u8D2D\u7269\u8F66
',$(".enterLiveBox").css({height:"86px"})):i[0]==0?s+='\u514D\u8D39\u62A5\u540D
':s+='\u524D\u5F80\u8BFE\u7A0B
',$(".enterLiveBox").html(s)},studentBuy:function(e){var r=this,o=e.data,a=window.location.href,i=r.coursewareDetail,s=i.isPay,n=i.introduce,t=i.courseWareName,c=i.courseWareId,d=i.isInCart,l=i.cover,p=i.price?JSON.parse(i.price):[];r.pre=p;var f=new Array;f[0]={courseWareId:c,courseWareName:t,orderTitle:t,orderType:2,price:p[0]},o.userTypeExact=="STUDENT"?s==!0?r.gotoStudy():r.courseOnlyBalance==1?r.payBalance(f):p[0]==0?r.payFree(f):r.joinBuyCar(function(){window.location.href="/pay/#/shopping"}):layer.open({content:"\u53EA\u6709\u5B66\u751F\u8D26\u53F7\u624D\u80FD\u62A5\u540D\uFF01",btn:"\u786E\u5B9A"})},payBalance:function(e){var r=this,o=r.pre;layer.open({title:"\u8BF7\u786E\u8BA4",content:o[0]>0?"\u8BE5\u8BFE\u4EF6\u9700\u8981\u6D88\u8017"+o[0]/100+"\u4F59\u989D":"\u786E\u8BA4\u514D\u8D39\u5F00\u901A\u8BE5\u8BFE\u4EF6",className:"layer-onlybalance",btn:["\u786E\u8BA4\u52A0\u5165","\u53D6\u6D88"],yes:function(a){r.channels=r.getchannel(),r.channels.orderList=e,r.request({url:"/api/order/createOrder?projectid=22",data:JSON.stringify(r.channels),type:"POST",loading:!0,success:function(i){var s=i.code;i&&i.success?layer.open({title:"\u52A0\u5165\u6210\u529F",content:"\u524D\u5F80\u5B66\u4E60\u4E2D\u5FC3\u53EF\u76F4\u63A5\u5F00\u59CB\u5B66\u4E60",className:"layer-onlybalance",btn:["\u7ACB\u5373\u524D\u5F80","\u518D\u901B\u901B"],yes:function(n){r.gotoStudy(),layer.closeAll()}}):s=="605"?layer.open({title:"\u4F59\u989D\u4E0D\u8DB3",content:"\u8BF7\u5145\u503C\u540E\u518D\u8BD5",className:"layer-onlybalance",btn:["\u7ACB\u5373\u524D\u5F80","\u5173\u95ED"],yes:function(n){r.goBalance(),layer.closeAll()}}):layer.open({title:"\u63D0\u793A",content:i.message||"\u62A5\u540D\u5931\u8D25",className:"layer-onlybalance",btn:["\u5173\u95ED"],yes:function(n){layer.closeAll()}})}}),layer.closeAll()}})},payFree:function(e){var r=this;r.channels=r.getchannel(),r.channels.orderList=e,r.request({url:"/api/order/createOrder?projectid=22",data:JSON.stringify(r.channels),type:"POST",loading:!0,success:function(o){layer.open({type:1,offset:"auto",content:' \u62A5\u540D\u6210\u529F\uFF0C\u8FDB\u5165\u5B66\u4E60\u4E2D\u5FC3\uFF01
',btn:"\u786E\u8BA4",btnAlign:"c",yes:function(){r.gotoStudy(),layer.closeAll()}})}})},joinBuyCar:function(e){var r=this;r.channels=r.getchannel();var o=window.location.href,a=r.coursewareDetail,i=a.courseWareId,s=a.courseWareName,n=a.cover,t=a.introduce,c=a.price?JSON.parse(a.price):[],d=new Array;d[0]={goodsId:i,price:c[0],goodsUrl:o,goodsType:2,goodsName:s,cover:n,introduce:t,endTime:c[1]},r.request({url:"/api/order/shoppingCart?projectid=22",data:JSON.stringify({goodsList:d,pvid:r.channels.pvid,uvcid:r.channels.uvcid,shareUserId:r.channels.shareUserId,clientType:r.channels.channel}),type:"POST",loading:!1,success:function(l){l.success?e&&e():layer.msg(l.message)}})},gotoStudy:function(){var e=this,r=e.courseWareType,o=["1","2","3","4","5"],a=o.indexOf(r)>-1?"livecourse_wap":"course_wap";window.location.href="/views/wap/"+a+".html?cwid="+e.courseWareId+"&courseId="+e.courseId},goBalance:function(){window.location.href="/myroom/#/simplify/balance"},goHome:function(){window.location.href="/"},goCourse:function(){var e=this;e.staticTemplate?window.location.href="/course/"+e.courseId+".shtml?cid="+e.courseId:window.location.href="/pages/wap/info.html?cid="+e.courseId},goPersonal:function(){var e=this;e.userInfo?location.href="/myroom/#/personal":user.loginLayer(function(r){r.success&&(r.data.userTypeExact=="STUDENT"?location.href="/myroom/#/personal":location.href="/aroom/#/personal")})},getM3u8:function(){var e=this;e.request({url:"/api/common/mu/getAuditionM3u8.m3u8?projectid=45",data:{courseWareId:e.courseWareId,onlyQuery:1},success:function(r){if(parseInt(r.code)==200)e.brond=!0,e.m3u8="/api/common/mu/getAuditionM3u8.m3u8?courseWareId="+e.courseWareId,e.loadvideoJs();else{switch(parseInt(r.code)){case 403:r.message="\u8BFE\u4EF6\u6CA1\u6709\u8BBE\u7F6E\u8BD5\u542C!";break;case 404:r.message="\u8BFE\u4EF6\u89C6\u9891\u4E0D\u5B58\u5728!";break;case 503:r.message="\u8F6C\u7801\u672A\u5B8C\u6210!";break;case 406:r.message="\u8BD5\u542C\u8BBE\u7F6E\u4E0D\u6B63\u786E!";break}$(".curfengs .bose").hide()}}})},isplay:function(){var e=this;e.isEndplay(),e.brond&&e.videoAuditionSet&&(getPlayer("videod").pause(),clearTimeout("#divid"))},isEndplay:function(){$(".bose").show(),$(".zaimg").show(),$(".shareBox").show(),$("#divid").hide(),$(".curfengs").show(),$(".touspe").css("top","auto")},loadvideoJs:function(){var e=this,r=!1,o=!1,a=!1,i=!1;$("head").append(''),e.createPlayer()},createPlayer:function(){var e=this;if(e.brond&&e.videoAuditionSet){var r=navigator.userAgent.toLowerCase(),o=r.match(/cpu iphone os (.*?) like mac os/);if(!o)$(".curfengs").on("click",".bose",function(){$(".bose").hide(),$(".shareBox").hide(),$(".zaimg").hide(),$("#divid").show(),$(".curfengs").hide(),$(".touspe").css("top","0"),getPlayer("videod").play(),e.iter=!1});else{var a=(o[1].replace(/_/g,".")+"").split(".")[0];a>=10&&$(".curfengs").on("click",".bose",function(){$(".bose").hide(),$(".shareBox").hide(),$(".zaimg").hide(),$("#divid").show(),$(".curfengs").hide(),$(".touspe").css("top","0"),getPlayer("videod").play(),e.iter=!1})}var i=createPlayer("videod");$(i).attr({"x5-video-player-fullscreen":"true","webkit-playsinline":"true","x-webkit-airplay":"true",playsinline:"true","x5-playsinline":"true","x5-video-player-type":"h5-page"}),$("#divid").append(i),init("videod","html5",e.m3u8,!1,!1,!0,"",function(){getPlayer("videod").on("playing",function(){getPlayer("videod").controls(!0)}),getPlayer("videod").on("ended",function(){if(setSeek("videod",0),e.isEndplay(),getPlayer("videod").player_.isFullscreen_==!0&&getPlayer(videoPlayer.id_).exitFullscreen(),e.rtype==3)return!1;layer.open({content:"\u8BD5\u542C\u7ED3\u675F\uFF0C\u8BF7\u62A5\u540D\u540E\u89C2\u770B\u5B8C\u6574\u89C6\u9891\u3002",btn:["\u7ACB\u5373\u62A5\u540D","\u6682\u4E0D\u62A5\u540D"],yes:function(s){e.rtype==1?e.getCourseDetail(function(n){e.buyCourse(n)}):e.rtype==2&&(e.userInfo?e.studentBuy({data:e.userInfo}):user.loginLayer(function(n){n.success&&e.renderDetails(function(t){e.studentBuy(t)})})),layer.close(s)},no:function(s){layer.close(s)}})})})}},buyCourse:function(e){var r=this,o=e.data;o.isOpenSignUp==!0&&(r.userInfo?r.carryBuyCourse(r.userInfo,o):user.loginLayer(function(a){a.success&&r.getLoginUser(function(i){r.carryBuyCourse(i.data,o)})}))},carryBuyCourse:function(e,r){var o=this,a=r,i=a.price,s=a.introduce,n=a.courseName,t=a.courseId,c=a.cover,d=a.isPay,l=a.deadline,p=a.personNumLimit,f=a.personNumLimit-a.personNumCount,g=a.isInCart,u;a.courseType==3?u=3:u=1;var I=a.isInCart,w=window.location.href,y=a.parentCourseId,v=new Array,h=new Array;y==0?(h[0]={goodsId:t,price:i,goodsUrl:w,goodsType:u,goodsName:n,cover:c,operateType:1,introduce:s,endTime:l},v[0]={courseId:t,courseName:n,orderTitle:n,orderType:u,price:i}):(h[0]={goodsId:t,price:i,goodsUrl:w,goodsType:u,goodsName:n,cover:c,sourceSchoolCourseId:y,operateType:1,introduce:s,endTime:l},v[0]={courseId:t,courseName:n,orderTitle:n,orderType:u,price:i,sourceSchoolCourseId:y}),e.userTypeExact=="STUDENT"?d==!0?o.gotoStudy():f<=0&&p!=0?layer.open({content:"\u62A5\u540D\u4EBA\u6570\u5DF2\u6EE1\uFF01",btn:"\u786E\u5B9A"}):i==0?layer.open({type:1,offset:"auto",content:'\u62A5\u540D\u6210\u529F\uFF0C\u8FDB\u5165\u5B66\u4E60\u4E2D\u5FC3\uFF01
',btn:"\u786E\u8BA4",btnAlign:"c",yes:function(){o.createOrder(v,function(m){m.success&&o.gotoStudy()}),layer.closeAll()}}):o.shoppingCart(h,function(m){m.success&&(window.location.href="/pay/#/shopping")}):layer.open({content:"\u53EA\u6709\u5B66\u751F\u8D26\u53F7\u624D\u80FD\u62A5\u540D\uFF01",btn:"\u786E\u5B9A"})},getLoginUser:function(e){var r=this;user.isLogin(function(o){o.code==200&&(r.userInfo=o.data,e&&e(o))})},getCourseDetail:function(e){var r=this;r.request({url:"/api/course/getCourseDetail?projectid=12",data:{courseId:r.courseId},success:function(o){o.code==200&&e&&e(o)}})},getCourseWareDetail:function(e){var r=this;r.request({url:"/api/course/getCourseWareDetail?projectid=12",data:{courseId:r.courseId,courseWareId:r.courseWareId},success:function(o){o.code==200&&e&&e(o)}})},createOrder:function(e,r){var o=this;o.channels=o.getchannel(),o.channels.orderList=e,o.request({type:"POST",url:"/api/order/createOrder?projectid=22",data:JSON.stringify(o.channels),success:function(a){r&&r(a)}})},shoppingCart:function(e,r){var o=this;o.channels=o.getchannel(),o.request({type:"POST",url:"/api/order/shoppingCart?projectid=22",data:JSON.stringify({goodsList:e,pvid:o.channels.pvid,uvcid:o.channels.uvcid,shareUserId:o.channels.shareUserId,clientType:o.channels.channel}),success:function(a){r&&r(a)}})},getPar:function(e){var r=document.location.href,o=r.indexOf(e+"=");if(o==-1)return!1;var a=r.slice(e.length+o+1),i=a.indexOf("&");return i!=-1&&(a=a.slice(0,i)),a},getCookie:function(e){for(var r=document.cookie,o=r.split("; "),a=0;a