2 lines
10 KiB
JavaScript
2 lines
10 KiB
JavaScript
getPar("cid")||(window.location.href="/");var urls=location.search;if(urls.indexOf("?")!=-1)var ster=urls.substr(1),sty=ster.split("&"),cide=sty[0].split("cid="),usid=ster.split("&uid=");var deusid=usid[1]?usid[1].split(","):[],sceneId=getPar("sceneId")||"",sceneType=getPar("sceneType")?getPar("sceneType"):0,urlpd=window.location.href,channels=getchannel();function details(){$.ajax({headers:{token:getCookie("token")},type:"GET",url:"/api/disk/options?projectid=45",data:{},dataType:"json",async:!0,success:function(n){if(n.code==200){for(var e=n.data.userId,o="",c="",l="\u8BFE\u7A0B\u8BE6\u60C5",p="",s=deusid,a=[],i=0;i<s.length;i++)e!=parseInt(s[i])&&a.push(s[i]);for(var i=0,w=a.length;i<w;i++){var d=a[i];i<3&&(p+=","+d)}p=usid[0]+"&uid="+e+p,o=window.location.origin+window.location.pathname+"?"+p,window.history.replaceState(c,l,o)}}}),$.ajax({headers:{token:getCookie("token")},type:"GET",contentType:"application/json",url:"/api/course/getCourseDetail?projectid=12",data:{courseId:getPar("cid"),isFromLive:sceneType=="1"?1:void 0,sceneId:sceneId||void 0},dataType:"json",async:!0,success:function(n){var e=n.data,o=e.personNumLimit,c=e.personNumLimit-e.personNumCount,l=e.isInCart,p="<img src="+((window.cdnPath||"")+e.cover)+' /><span class="touspe">'+e.courseName+"</span>";$(".curfeng").html(p);var s="";e.childClassifyName==""?s+='<p class="curint">'+e.mainClassifyName+"</p>":s+='<p class="curint">'+e.mainClassifyName+" > "+e.childClassifyName+"</p>",e.deadline==0?s+='<p class="curexplain">\u81EA\u8D2D\u4E70\u4E4B\u65E5\u8D77<span class="curseorange">\u6C38\u4E45\u6709\u6548':s+='<p class="curexplain">\u81EA\u8D2D\u4E70\u4E4B\u65E5\u8D77<span class="curseorange">'+e.deadline+"\u5929</span>\u6709\u6548",s+='<p class="cursered">',e.price==0?s+='<span class="curselv">\u514D\u8D39</span>':(s+='<span class="cursi">\uFFE5</span>'+(e.price/100).toFixed(2)+"",s+='<span class="cursezhe">\uFFE5'+(e.oldPrice/100).toFixed(2)+"</span>"),s+="</p>",e.personNumLimit!=0&&(s+='<span class="ml10" style="color:#999;">\u5DF2\u8D2D\u4E70<span class="redes">'+e.personNumCount+"</span>/"+e.personNumLimit+"</span>"),s+="</p>",s+='<p class="cursimp">'+e.introduce+"</p>",s+='<div class="inrout">',e.isFavorite==!0?(s+='<span class="curcolls">\u5DF2\u6536\u85CF</span>',s+='<span style="display:none;" class="curcoll">\u6536\u85CF</span>'):(s+='<span class="curcoll">\u6536\u85CF</span>',s+='<span style="display:none;" class="curcolls">\u5DF2\u6536\u85CF</span>'),s+='<span class="curshare">\u5206\u4EAB</span>',e.isOpenSignUp==!0?e.isPay==!0?s+='<div class="cursign" style="border-radius:20px">\u8FDB\u5165\u5B66\u4E60</div>':e.price==0?s+='<div class="cursign" style="border-radius:20px">\u514D\u8D39\u8D2D\u4E70</div>':(s+='<div class="cursign">\u7ACB\u5373\u8D2D\u4E70</div>',l==!0?s+='<div class="curshop huise">\u52A0\u5165\u8D2D\u7269\u8F66</div>':s+='<div class="curshop">\u52A0\u5165\u8D2D\u7269\u8F66</div>'):(s+='<div class="cursign huise">\u7ACB\u5373\u8D2D\u4E70</div>',s+='<div class="curshop huise">\u52A0\u5165\u8D2D\u7269\u8F66</div>'),s+="</div>";for(var a="",i=0,w=e.courseSubList.length;i<w;i++){var d=e.courseSubList[i];a+='<div class="detailedlist">',a+='<a class="aster" href="/pages/routine/info.html?cid='+d.courseId+'">',a+='<h2 class="detailedtit">'+d.courseName+"</h2>",a+='<img class="detailedico" src='+((window.cdnPath||"")+d.cover)+" />",a+='<div class="detailedrig">',a+='<span class="detailedar" href="/pages/routine/info.html?cid='+d.courseId+'">\u67E5\u770B\u8BE6\u60C5</span>',a+='<p class="detailedmain">'+d.introduce+"</p>",a+='<p class="detaileder">',d.price==0?a+='<span class="curselv">\u514D\u8D39</span>':(a+='<span class="detailedred">\uFFE5'+(d.price*(e.price/e.oldPrice)/100).toFixed(2)+"</span>",a+='<span class="detailedzhe">\uFFE5'+(d.price/100).toFixed(2)+"</span>"),a+="</p>",a+="</div>",a+="</a>",a+="</div>"}$(".detailed").html(a),$(".curwithin").html(s),$(".coursemain").html(e.detail)==""?$(".coursemain").html("<div class='nodata'></div>"):$(".coursemain").html(e.detail),$(".active span").html(e.courseCount),$(".curcoll").on("click",function(){channels=getchannel(),user.isLogin(function(t){t.success?$.ajax({headers:{token:getCookie("token")},type:"GET",url:"/api/course/collectCourse?projectid=37",data:{courseId:v,pvid:channels.pvid,uvcid:channels.uvcid,shareUserId:channels.shareUserId,clientType:channels.channel},dataType:"json",async:!0,success:function(r){$(".curcoll").hide(),$(".curcolls").show()}}):parseInt(t.code)==401?user.loginLayer(function(r){r.success&&details()}):layer.open({content:"\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\uFF01",btn:"\u786E\u5B9A"})})}),$(".curcolls").on("click",function(){user.isLogin(function(t){t.success?$.ajax({headers:{token:getCookie("token")},type:"GET",url:"/api/course/cancelCollectCourse?projectid=37",data:{courseId:v},dataType:"json",async:!0,success:function(r){$(".curcolls").hide(),$(".curcoll").show()}}):parseInt(t.code)==401?user.loginLayer(function(r){r.success&&details()}):layer.open({content:"\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\uFF01",btn:"\u786E\u5B9A"})})}),$(".curshare").on("click",function(){var t=layer.open({type:2});user.isLogin(function(r){if(r.success){var P=window.imgEditor,G=this,D=r.data.userId;if(window.ajaxSend)return!1;var j=window.location.href.indexOf("bundle.html")>-1?"b":"c",C=location.search;if(C.indexOf("?")!=-1){var E=C.substr(1);if(strs=E.split("&"),j+=","+strs[0].split("=")[1],strs[1]){var F=strs[1].split("=")[1].split(",");j+=","+F.slice(0,3).join(",")}}$.ajax({type:"post",headers:{token:getCookie("token")},url:"/api/user/other/getPicCode?projectid=45",contentType:"application/json;charset=utf-8",dataType:"json",data:JSON.stringify({page:"pages/logs/logs",scene:j,width:"680"}),success:function(h){window.ajaxSend=!1,layer.close(t),h.success?P.shareLayer(h.data.picCode,lepic):layer.open({content:"\u751F\u6210\u5C0F\u7A0B\u5E8F\u7801\u5F02\u5E38\uFF0C"+h.message,skin:"msg",time:2})},error:function(h){window.ajaxSend=!1}})}else parseInt(r.code)==401?user.loginLayer(function(h){h.success&&details()}):layer.open({content:"\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\uFF01",btn:"\u786E\u5B9A"})})});var g=e.price,J=window.location.href,u=e.courseName,v=e.courseId,b=e.isPay,S=e.cover,O=e.isInCart;if(e.courseType==3)var y=3;else var y=4;var x=location.search;if(x.indexOf("?")!=-1)var T=x.substr(1),U=T.split("&"),A=U[0].split("cid="),k=T.split("&uid=");var L=window.location.origin+window.location.pathname+"?"+T,f=k[1]?k[1].split(","):[],N=e.parentCourseId,I=new Array,m=new Array;e.parentCourseId==0?(I[0]={goodsId:v,price:g,goodsUrl:L,goodsType:y,goodsName:u,cover:S},m[0]={courseId:v,courseName:u,orderTitle:u,orderType:y,price:g,firstLevelId:f[1],secondLevelId:f[2],thirdLevelId:f[3]}):(I[0]={goodsId:v,price:g,goodsUrl:L,goodsType:y,goodsName:u,cover:S,sourceSchoolCourseId:N},m[0]={courseId:v,courseName:u,orderTitle:u,orderType:y,price:g,firstLevelId:f[1],secondLevelId:f[2],thirdLevelId:f[3],sourceSchoolCourseId:N}),sceneType==1&&(m[0].sceneType="1",m[0].sceneId=sceneId),$(".cursign").on("click",function(){channels=getchannel(),e.isOpenSignUp==!0&&user.isLogin(function(t){t.success?t.data.userTypeExact=="STUDENT"?b==!0?window.location.href="/myroom/#/learn/center":c<=0&&o!=0?layer.open({content:"\u8D2D\u4E70\u4EBA\u6570\u5DF2\u6EE1\uFF01",btn:"\u786E\u5B9A"}):g==0?layer.open({type:1,offset:"auto",content:'<div style="padding: 20px 80px;">\u8D2D\u4E70\u6210\u529F\uFF0C\u8FDB\u5165\u5B66\u4E60\u4E2D\u5FC3\uFF01</div>',btn:"\u786E\u8BA4",btnAlign:"c",yes:function(){channels.orderList=m,$.ajax({headers:{token:getCookie("token")},type:"POST",url:"/api/order/createOrder?projectid=22",contentType:"application/json",dataType:"json",data:JSON.stringify(channels),async:!0,success:function(r){window.location.href="/myroom/#/learn/center"}}),layer.closeAll()}}):$.ajax({headers:{token:getCookie("token")},type:"POST",url:"/api/order/shoppingCart?projectid=22",contentType:"application/json",dataType:"json",data:JSON.stringify({goodsList:I,pvid:channels.pvid,uvcid:channels.uvcid,shareUserId:channels.shareUserId,clientType:channels.channel}),async:!0,success:function(r){window.location.href="/myroom/#/shopping"}}):layer.open({content:"\u53EA\u6709\u5B66\u751F\u8D26\u53F7\u624D\u80FD\u8D2D\u4E70\uFF01",btn:"\u786E\u5B9A"}):parseInt(t.code)==401?user.loginLayer(function(r){r.success&&details()}):layer.open({content:"\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\uFF01",btn:"\u786E\u5B9A"})})}),$(".curshop").on("click",function(){channels=getchannel(),e.isOpenSignUp==!0&&user.isLogin(function(t){t.success?t.data.userTypeExact=="STUDENT"?l==!0?$(".curshop").addClass("huise"):c==0&&o!=0?layer.open({content:"\u8D2D\u4E70\u4EBA\u6570\u5DF2\u6EE1\uFF01",btn:"\u786E\u5B9A"}):O==!1&&$.ajax({headers:{token:getCookie("token")},type:"POST",url:"/api/order/shoppingCart?projectid=22",contentType:"application/json",dataType:"json",data:JSON.stringify({goodsList:I,pvid:channels.pvid,uvcid:channels.uvcid,shareUserId:channels.shareUserId,clientType:channels.channel}),async:!0,success:function(r){details(),layer.open({content:"\u52A0\u5165\u6210\u529F\uFF01",skin:"msg",time:2})}}):layer.open({content:"\u53EA\u6709\u5B66\u751F\u8D26\u53F7\u624D\u80FD\u52A0\u5165\u8D2D\u7269\u8F66\uFF01",btn:"\u786E\u5B9A"}):parseInt(t.code)==401?user.loginLayer(function(r){r.success&&details()}):layer.open({content:"\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\uFF01",btn:"\u786E\u5B9A"})})})}})}details();function getchannel(){var n,e=localStorage.appAdapt===!0||localStorage.appAdapt==="true";if(e){var o=sessionStorage.getItem("ip")||"",c=sessionStorage.getItem("channel")||"",l=sessionStorage.getItem("gmtStart")||0,p=sessionStorage.getItem("sourceId")||0,s=sessionStorage.getItem("sourceJson")||"",a=sessionStorage.getItem("sourceType")||"";n={ip:o,channel:c,gmtStart:l,sourceId:p,sourceJson:s,sourceType:a}}else{n=sessionStorage.getItem("cluechannel")?JSON.parse(sessionStorage.getItem("cluechannel")):{};var o=sessionStorage.getItem("sourceip");n.ip=o||""}var i=getPar("channel")||"";return i&&(n.channel=i),n.uvcid=localStorage.uvcid||"",n.pvid=sessionStorage.getItem("pvid")||"",n}function getCookie(n){for(var e=document.cookie,o=e.split("; "),c=0;c<o.length;c++){var l=o[c].split("=");if(l[0]==n)return l[1]}return""}function getPar(n){var e=document.location.href,o=e.indexOf(n+"=");if(o==-1)return!1;var c=e.slice(n.length+o+1),l=c.indexOf("&");return l!=-1&&(c=c.slice(0,l)),c}
|