var currentIndex $(document).ready(function(){ var href = window.location.href currentIndex = href.split('cate=')[1] ? href.split('cate=')[1] : '11,12,13' if(currentIndex.indexOf('&') != -1){ currentIndex = currentIndex.split('&')[0] } if($('.new_article').length){ currentIndex = $('.new_article').attr('data-index') } $('.news_kind_link').each(function(el,index){ var index = $(this).attr('data-index') if(currentIndex == index){ $(this).css('color','#407BFF') }else{ $(this).css('color','#333333') } }) }) $('.news_kind_link').click(function(){ var index = $(this).attr('data-index') var href = window.location.href if(href.indexOf('Search') != -1){ if(href.indexOf('cate=') != -1){ var url1 = href.split('cate=')[0] var url2 = href.split('cate=')[1].split('&')[1] window.location.href = url1 + 'cate=' + index + '&' + url2 }else{ var url = href.split('?')[0] + '?cate=' + index + '&' + href.split('?')[1] window.location.href = url } }else{ window.location.href = '/news.html?cate=' + index } }) $('.search_input input').focus(function(){ $(this).parent().css({'width':'340px','border-color':'#99999900','boxShadow':'0px 3px 6px #00000029'}) $(this).animate({ width: '250px' },50) $(this).siblings('.search-delete').css('display','flex') setTimeout(()=>{ var placeText = '杈撳叆浣犳兂瑕佹悳绱㈢殑鍐呭' if($(this).attr('id')=='search_keyword'){ placeText = '杈撳叆浣犳兂瑕佹悳绱㈢殑鍐呭' }else{ placeText = '閫夋嫨浣犳兂瑕佹悳绱㈢殑鏃堕棿' } $(this).attr('placeholder',placeText) },200) }) $('body').click(function(e) { var _con1 = $('.search_input');//璁剧疆鐩爣鍖哄煙 if (!_con1.is(e.target) && _con1.has(e.target).length === 0){ _con1.css({'width':'218px','border-color':'#999999','boxShadow':'none'}) _con1.find('input').animate({ width: '166px' },50) _con1.find('.search-delete').css('display','none') setTimeout(()=>{ _con1.find('#search_keyword').attr('placeholder','鎼滅储鍐呭') _con1.find('#search_time').attr('placeholder','鎼滅储鏃堕棿') },200) } }) layui.use('laydate', function(){ var laydate = layui.laydate; //甯歌鐢ㄦ硶 laydate.render({ elem: '#search_time' }); }) $('.search_close').click(function(){ $(this).parents('.search_input').find('input').val('') }) $('.search_new').click(function(){ console.log('鎼滅储') getSearchList() }) $('.search_input input').keydown(function(e){ if(e.keyCode==13){ getSearchList() } }) // var cate = window.location.href.split('cate=')[1] ? window.location.href.split('cate=')[1] : '11,12,13' function getSearchList(){ var keyword = $("#search_keyword").val() var time = $("#search_time").val() var searchUrl = '' if(keyword){ searchUrl = '&keyword=' + keyword } if(time){ searchUrl = searchUrl + '&time=' + time } if(keyword || time){ window.location.href = '/portal/Search?cate=' + currentIndex + searchUrl; } }