filesbox/web/dist/design/designstatic/front/js/elective.js
2024-07-26 14:10:54 +08:00

2 lines
12 KiB
JavaScript

"use strict";var cdnPath="",wapurl=window.location.origin+"/pages/wap/elective.html"+window.location.search;/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(navigator.userAgent)&&(window.location.href=wapurl);var pid=getPar("mainClassify")?+getPar("mainClassify"):void 0,cid=getPar("childClassify")?+getPar("childClassify"):void 0,keyWord=getPar("keyword"),classifyData=[],classifyData2=[],classifyData3=[],classifyData4=[],classifyData5=[],classifyData6=[],tab="";keyWord="";function getCookie(a){var e=document.cookie.match(new RegExp("(^| )"+a+"=([^;]*)(;|$)"));return e?unescape(e[2]):""}function getPar(a){var e=decodeURI(decodeURI(window.location.search)),i=e.indexOf(a+"=");if(i===-1)return"";var s=e.slice(a.length+i+1),o=s.indexOf("&");return o!==-1&&(s=s.slice(0,o)),s}function coverError(a){var e=event.target;parseInt(e.dataset.errorcount)==0?(e.setAttribute("data-errorcount",1),e.src=a):parseInt(e.dataset.errorcount)==1&&(e.setAttribute("data-errorcount",2),e.src="/static/common/image/course/defult.jpg")}function resetImgSrc(a){var e=a.replace(/([^.]*).([^.]*)$/g,"$1!large.$2");return e}function renderBottomInfo(a){var e='<span class="price">'+(a.showPrice==1?a.price=="0"?'<span style="color: #43bc60;">\u514D\u8D39</span>':'<span style="color: #fa5353;font-size: 16px;">\uFFE5'+(a.price/100).toFixed(2)+"</span>":"")+"</span>",i='<span class="mainTeacher" title='+a.mainTeacher+">"+a.mainTeacher+"</span>",s=parseInt(a.orderCount)?'<span class="buynum">'+a.orderCount+"\u4EBA\u8D2D\u4E70</span>":"",o=parseInt(a.popularityCount)?'<span class="viewnum">'+a.popularityCount+"\u4EBA\u89C2\u770B</span>":"",t='<div class="course-info"><p>'+e+i+'</p><p style="clear: both;">'+s+o+"</p></div>";return t}function list(a,e,i,s,o){if(e||i||s)var t="/api/course/getSelectionCourseList?projectid=12";else var t="/api/course/getAllSelectionCourseList?projectid=12";var n=12;$.ajax({headers:{token:getCookie("token"),resolution:window.screen.width+"*"+window.screen.height},type:"GET",url:t,data:{sortType:a,currentPage:o,sortord:7,mainClassify:e,condition:s,childClassify:i,pageSize:n,needPage:"1"},dataType:"json",async:!0,success:function(P){var I=P.data,l="",S="",x=I.list||[];e||i||s?x.forEach(function(r){var c=r.isPay,g=c===void 0?!1:c,h=+r.courseType,p=+r.type,C=+r.price,u=void 0,v=getPar("att")?"&att="+decodeURIComponent(getPar("att")):"",b=getPar("vcardId")?"&vcardId="+decodeURIComponent(getPar("vcardId")):"",y=getPar("shareId")?"&shareId="+decodeURIComponent(getPar("shareId")):"";g?u="/myroom/#/learn/detail/"+r.courseId:h===2||h===4?u="/pages/bundle.html?cid="+r.courseId+v+b+y:u="/pages/info.html?cid="+r.courseId+v+b+y,r.isAllAudio&&(u="/liveclass/songsheet.html?courseId="+r.courseId+v+b+y);var j=r.cover,m='<div class="course-cover"><a class="course-link" href="'+u+'" target="_blank">',d='<a class="li-btn" href="'+u+'" target="_blank"><a class="item-name" href="'+u+'" title="'+r.courseName+'">'+r.courseName+"</a>"+m,w="<img src="+(cdnPath+r.cover)+">";r.originalCover&&(w="<img src="+(cdnPath+resetImgSrc(r.cover))+' data-errorcount="0" onerror="coverError(&quot'+(cdnPath+r.cover)+'&quot)" >'),l+="<li>"+d+w+"<div></div></a>";var f={};g?f={addClass:"study",href:"/myroom/#/learn/detail/"+r.courseId,content:"\u7ACB\u5373\u5B66\u4E60"}:p===1?f={addClass:"secondkill",href:"/pages/info.html?cid="+r.courseId,content:"\u9650\u65F6\u79D2\u6740"}:p===2?f={addClass:"collage",href:"/pages/info.html?cid="+r.courseId,content:"\u62FC\u56E2\u5546\u54C1"}:p===3?f={addClass:"redprice",href:"/pages/info.html?cid="+r.courseId,content:"\u780D\u4EF7\u5546\u54C1"}:C===0?f={addClass:"freeup",href:"/pages/info.html?cid="+r.courseId,content:"\u514D"}:h===2||h===4?f={addClass:"coursepack",href:"/pages/bundle.html?cid="+r.courseId,content:"\u8BFE\u7A0B\u5305"}:f={addClass:"",href:"/pages/info.html?cid="+r.courseId,content:"\u7ACB\u5373\u8D2D\u4E70"};var z='<a class="course-oper '+f.addClass+'" href="'+f.href+'" target="_blank">'+f.content+"</a>";l+=z,l+="</div>",l+=renderBottomInfo(r),l+="</a>",l+="</li>"}):x.forEach(function(r){l+='<div class="pdtit">'+r.classifyName+"</div>",r.courseList.forEach(function(c){var g=c.isPay,h=g===void 0?!1:g,p=+c.courseType,C=+c.type,u=+c.price,v=void 0;h?v="/myroom/#/learn/detail/"+c.courseId:p===2||p===4?v="/pages/bundle.html?cid="+c.courseId:v="/pages/info.html?cid="+c.courseId;var b=c.cover,y='<div class="course-cover"><a class="course-link" href="'+v+'" target="_blank">',j='<a class="li-btn" href="'+v+'" target="_blank"><a class="item-name" href="'+v+'" title="'+c.courseName+'">'+c.courseName+"</a>"+y,m="<img src="+(cdnPath+c.cover)+">";c.originalCover&&(m="<img src="+(cdnPath+resetImgSrc(c.cover))+' data-errorcount="0" onerror="coverError(&quot'+(cdnPath+c.cover)+'&quot)" >'),l+="<li>"+j+m+"<div></div></a>";var d={};h?d={addClass:"study",href:"/myroom/#/learn/detail/"+c.courseId,content:"\u7ACB\u5373\u5B66\u4E60"}:C===1?d={addClass:"secondkill",href:"/pages/info.html?cid="+c.courseId,content:"\u9650\u65F6\u79D2\u6740"}:C===2?d={addClass:"collage",href:"/pages/info.html?cid="+c.courseId,content:"\u62FC\u56E2\u5546\u54C1"}:C===3?d={addClass:"redprice",href:"/pages/info.html?cid="+c.courseId,content:"\u780D\u4EF7\u5546\u54C1"}:u===0?d={addClass:"freeup",href:"/pages/info.html?cid="+c.courseId,content:"\u514D"}:p===2||p===4?d={addClass:"coursepack",href:"/pages/bundle.html?cid="+c.courseId,content:"\u8BFE\u7A0B\u5305"}:d={addClass:"",href:"/pages/info.html?cid="+c.courseId,content:"\u7ACB\u5373\u8D2D\u4E70"};var w='<a class="course-oper '+d.addClass+'" href="'+d.href+'" target="_blank">'+d.content+"</a>";l+=w,l+="</div>",l+=renderBottomInfo(c),l+="</a>",l+="</li>"})});var k=I.result?I.result.totalPage:1,N=I.hasNextPage?o+parseInt(k):o;$("#pagination2").pagination({currentPage:o,totalPage:N,isShow:!1,keepShowPN:!0,count:4,prevPageText:'<svg style="margin-top: 7px;" viewBox="64 64 896 896" focusable="false" class="" data-icon="left" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"></path></svg>',nextPageText:'<svg style="margin-top: 7px;" viewBox="64 64 896 896" focusable="false" class="" data-icon="right" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"></path></svg>',callback:function(c){list(tab,e,i,s,c)}});var E=x.length>0?l:"<div class='nodata'></div>";$(".coursemain ul").html(E)}})}list(1,pid,cid,keyWord,1),$(".filterrig").on("click","a",function(){var a=$(this);if(a.text()==="\u5168\u90E8")$(".plate-nav2,.plate-nav3,.plate-nav4,.plate-nav5,.plate-nav6").hide(),$(".filterrig a").removeClass("curs"),pid="",cid="",keyWord="",$(this).addClass("curs");else if(a.hasClass("cid")){var e=a.attr("zindex")||0;if(e==5)cid=a.attr("tabs"),$(".plate-nav6 a").removeClass("curs"),$(this).addClass("curs");else if(e==4){cid=a.attr("tabs"),$(".plate-nav5 a").removeClass("curs"),$(".plate-nav6").hide(),$(this).addClass("curs");var i=classifyData5.filter(function(o){return o.courseClassifyId==cid});if(classifyData6=(i[0]||{}).children||[],classifyData6.length){var s='<a class="cid curs" zindex="5" tabs="" href="javascript:void(0);">\u5168\u90E8 </a>';classifyData6.forEach(function(o){s+='<a class="cid" zindex="5" tabs="'+o.courseClassifyId+'" href="javascript:void(0);">'+o.classifyName+"</a>"}),$(".plate-nav6").html(s),$(".plate-nav6").show()}}else if(e==3){cid=a.attr("tabs"),$(".plate-nav4 a").removeClass("curs"),$(".plate-nav5,.plate-nav6").hide(),$(this).addClass("curs");var i=classifyData4.filter(function(t){return t.courseClassifyId==cid});if(classifyData5=(i[0]||{}).children||[],classifyData5.length){var s='<a class="cid curs" zindex="4" tabs="" href="javascript:void(0);">\u5168\u90E8 </a>';classifyData5.forEach(function(n){s+='<a class="cid" zindex="4" tabs="'+n.courseClassifyId+'" href="javascript:void(0);">'+n.classifyName+"</a>"}),$(".plate-nav5").html(s),$(".plate-nav5").show()}}else if(e==2){cid=a.attr("tabs"),$(".plate-nav3 a").removeClass("curs"),$(".plate-nav4,.plate-nav5,.plate-nav6").hide(),$(this).addClass("curs");var i=classifyData3.filter(function(t){return t.courseClassifyId==cid});if(classifyData4=(i[0]||{}).children||[],classifyData4.length){var s='<a class="cid curs" zindex="3" tabs="" href="javascript:void(0);">\u5168\u90E8 </a>';classifyData4.forEach(function(n){s+='<a class="cid" zindex="3" tabs="'+n.courseClassifyId+'" href="javascript:void(0);">'+n.classifyName+"</a>"}),$(".plate-nav4").html(s),$(".plate-nav4").show()}}else if(e==1){cid=a.attr("tabs"),$(".plate-nav2 a").removeClass("curs"),$(".plate-nav3,.plate-nav4,.plate-nav5,.plate-nav6").hide(),$(this).addClass("curs");var i=classifyData2.filter(function(t){return t.courseClassifyId==cid});if(classifyData3=(i[0]||{}).children||[],classifyData3.length){var s='<a class="cid curs" zindex="2" tabs="" href="javascript:void(0);">\u5168\u90E8 </a>';classifyData3.forEach(function(n){s+='<a class="cid" zindex="2" tabs="'+n.courseClassifyId+'" href="javascript:void(0);">'+n.classifyName+"</a>"}),$(".plate-nav3").html(s),$(".plate-nav3").show()}}else{pid=a.attr("tabs"),$(".plate-nav a").removeClass("curs"),$(".plate-nav2,.plate-nav3,.plate-nav4,.plate-nav5,.plate-nav6").hide(),$(this).addClass("curs");var i=classifyData.filter(function(t){return t.courseClassifyId==pid});if(classifyData2=i[0].children||[],classifyData2.length){var s='<a class="cid curs" zindex="1" tabs="" href="javascript:void(0);">\u5168\u90E8 </a>';classifyData2.forEach(function(n){s+='<a class="cid" zindex="1" tabs="'+n.courseClassifyId+'" href="javascript:void(0);">'+n.classifyName+"</a>"}),$(".plate-nav2").html(s),$(".plate-nav2").show()}}}list(tab,pid,cid,keyWord,1)}),$(".searchtxt").val(keyWord),$(".searchbtn").on("click",function(){keyWord=$(".searchtxt").val(),list(tab,pid,cid,keyWord,1)}),$.ajax({type:"GET",url:"/api/course/getClassifys?projectid=12",contentType:"application/json",dataType:"json",data:{needShare:!0,needOther:!1},async:!0,success:function(e){classifyData=e.data||[];var i="";if(classifyData.forEach(function(t){i+='<a class="cid" tabs="'+t.courseClassifyId+'" href="javascript:void(0);">'+t.classifyName+"</a>",t.courseClassifyId===pid&&(classifyData2=t.children||[])}),$(".plate-nav").append(i),classifyData2.length){$(".plate-nav a").removeClass("curs"),$(".plate-nav a[tabs="+pid+"]").addClass("curs");var s='<a class="cid curs" zindex="1" tabs="" href="javascript:void(0);">\u5168\u90E8 </a>';classifyData2.forEach(function(t){s+='<a class="cid" zindex="1" tabs="'+t.courseClassifyId+'" href="javascript:void(0);">'+t.classifyName+"</a>",t.courseClassifyId===cid&&(classifyData3=t.children||[])}),$(".plate-nav2").html(s),$(".plate-nav2").show(),cid&&($(".plate-nav2 a").removeClass("curs"),$(".plate-nav2 a[tabs="+cid+"]").addClass("curs"))}if(classifyData3.length){var o='<a class="cid curs" zindex="2" tabs="" href="javascript:void(0);">\u5168\u90E8 </a>';classifyData3.forEach(function(t){o+='<a class="cid" zindex="2" tabs="'+t.courseClassifyId+'" href="javascript:void(0);">'+t.classifyName+"</a>"}),$(".plate-nav3").html(o),$(".plate-nav3").show()}}}),$(".coursetit li").on("click",function(){$(".coursetit li").removeClass("curs"),$(this).addClass("curs"),tab=$(this).attr("tabs"),list(tab,pid,cid,keyWord,1)});function getGlobalDesignConfig(){var a=setInterval(function(){if(window.roominfo){clearInterval(a);var e=window.roominfo.schoolId;$.getScript(cdnPath+"/uploads/common/designConfig/"+e+".js",function(){if(window.DesignConfig){var i=(window.DesignConfig.viewNum?"viewNumShow ":"")+(window.DesignConfig.buyNum?"buyNumShow ":"")+(window.DesignConfig.price?"priceShow ":"");$(".coursemain ul").addClass(i)}})}},200)}getGlobalDesignConfig();