2 lines
19 KiB
JavaScript
2 lines
19 KiB
JavaScript
|
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(){l
|