var vinchinCase = function(){ var addListeners = function(){ var list_active = $("#type").val(); $("."+list_active).addClass('active'); $('.casetype').on('click', getCaseList); $('.case-box').mouseover(function(){ var parent = $(this); $(this).find('img').mouseover(function(){ $(parent).find('.case-circle1').removeClass('display-none'); $(parent).find('.case-circle2').removeClass('display-none'); }).mouseout(function(){ $(parent).find('.case-circle1').addClass('display-none'); $(parent).find('.case-circle2').addClass('display-none'); }); }) } //寰楀埌妗堜緥鍒楄〃 var getCaseList = function(){ $('.casetype').removeClass('active'); $(this).addClass('active'); var value = $(this).attr("value"); $("#type").val(value); let $type = $("#type").val(); let data = {} if ($.trim($type) !== "") { data.type = $type } data.page = 1 $.get("./list.php", data, function(response) { $("#list-container .list-group").html(response) }) } var initPagination = function(){ var casetype = $("#type").val(); var page = $("#page").val(); var country = getUrlParam('country'); var search = getUrlParam('search'); if(!page){ page = 1; } if(!casetype){ casetype = 0; } if(!country){ country = 'ALL'; } // $('.casetype').removeClass('active'); $('.tab'+casetype).addClass('active'); var params ={ 'page': page, 'type': casetype, 'country': country, 'search': search }; $.post('/api/', {m:4,f:'getCaseList',p:params}, function(d){ var data = JSON.parse(d); if(data.record.length == 0){ var info = '

娌℃湁鎵惧埌瀵瑰簲妗堜緥...

'; $('#caseList').empty().append(info); $('#case-page').hide(); }else if(data.totalpage <= 1){ $('#case-page').hide(); } }); } //鑾峰彇url鍙傛暟 var getUrlParam = function(name){ var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //鏋勯€犱竴涓惈鏈夌洰鏍囧弬鏁扮殑姝e垯琛ㄨ揪寮忓璞 var r = window.location.search.substr(1).match(reg); //鍖归厤鐩爣鍙傛暟 if (r != null) return decodeURI(r[2]); return null; //杩斿洖鍙傛暟鍊 } let toTop = function (){ $(".totop").click(function (){ $('html,body').animate({scrollTop: 0}, 800); }) } let runTabMenu = function () { let windowTop = $(window).scrollTop(); if(windowTop > 300){ $(".totop").show(); }else{ $(".totop").hide(); } } return{ init: function(){ initPagination(); addListeners(); toTop(); jQuery(window).load(runTabMenu()); jQuery(window).scroll(runTabMenu); } } }(); $(document).ready(function(){ vinchinCase.init(); });