//导航条鼠标事件 $('.navbar-nav>li').hover( function(e,i){ $(this).find(".submenu").show(); $(this).addClass('active'); }, function(e,i){ $(this).find(".submenu").hide(); $(this).removeClass('active'); } ); //导航点击收起 $('#navbar-collapse > ul > li > a > b').click(function(){ let submenu = $(this).parent().parent().find(".submenu"); if ($(this).hasClass('glyphicon-menu-right')){ $('#navbar-collapse > ul > li > a > b').removeClass('glyphicon-menu-down'); $('#navbar-collapse > ul > li > a > b').addClass('glyphicon-menu-right'); $(".submenu").hide(); $(this).removeClass('glyphicon-menu-right'); $(this).addClass('glyphicon-menu-down'); submenu.show(); }else{ $(this).removeClass('glyphicon-menu-down'); $(this).addClass('glyphicon-menu-right'); submenu.hide(); } return false; }); var current_topcategory = $(".top-category>li.current"); //子导航条跳转 $('.top-category>li').click(current_topcategory,function(){ current_topcategory.toggleClass('current'); $(this).toggleClass('current'); current_topcategory = $(this); //非锚点直接打开网址 if ($(this).attr('data-anchor').substr(0,1)!=='#'){ location.href=$(this).attr('data-anchor'); } let anchorname = $(this).attr('data-anchor').replace(/#/g,""); let target = $("a[name="+anchorname+"]").offset(); $("html,body").animate({scrollTop:target.top - "100" + "px"}, 100); //移动端点击后隐藏 设置标签的文字 $('.navbar-list').addClass('hidden-xs'); $('.current_list>.list_text').html($(current_topcategory).html()); }); $('.current_list').click(function(){ let isopen = $(this).find('.right-arrow'); isopen.toggleClass('glyphicon-menu-right'); isopen.toggleClass('glyphicon-menu-down'); $(this).next().toggleClass('hidden-xs'); }); //子菜单弹出时,滚动时重新定位 var resetsubmenu = function (){ var scroH = $(this).scrollTop(); var menu = $('.navbar-nav'); $('.submenu').css({"top":menu.offset().top+menu.height()-scroH}); }; resetsubmenu(); $(window).scroll(function(){ resetsubmenu(); }); // 子导航固定 //获取要定位元素距离浏览器顶部的距离 var nav = $(".navbar-container"); //是否有水平导航条 var isfixed = nav.has('.horizontal').length > 0; if (isfixed && device!='mobile'){ var navH = nav.offset().top; //滚动条事件 $(window).scroll(function(){ //获取滚动条的滑动距离 var scroH = $(this).scrollTop(); //console.log(scroH,nav.height()); //滚动条的滑动距离大于等于定位元素距离浏览器顶部的距离,就固定,反之就不固定 //if(scroH>=navH+nav.height()){ if(scroH>=navH){ $(".navbar-container").css({"position":"fixed"}); $('.current_list').css({"margin-top":"50px"}); }else if(scroHli').removeClass('current'); current_topcategory.addClass('current'); //移动端滚动样式 $('.current_list>.list_text').html($(current_topcategory).html()); } }) } $(function () { $('input[name=keyword]').keydown(function(e) { if (e.keyCode == 13) { txt = encodeURIComponent($("input[name=keyword]").val()); location.href = "/portal/search/index/keyword/" + txt ; } }); $('input[name=search]').click(function(e){ txt = encodeURIComponent($('input[name=keyword]').val()); if(txt==""){alert("请输入关键词")}else{location.href = "/portal/search/index/keyword/" + txt ;} }); $('button[name=search]').click(function(e){ txt = encodeURIComponent($('input[name=keyword]').val()); if(txt==""){alert("请输入关键词")}else{location.href = "/portal/search/index/keyword/" + txt ;} }); $('.search-input').click(function(e){ txt = encodeURIComponent($('input[name=keyword]').val()); if(txt==""){alert("请输入关键词")}else{location.href = "/portal/search/index/keyword/" + txt ;} }); $('input[name=keyword_searchpage]').keydown(function(e) { if (e.keyCode == 13) { txt = encodeURIComponent($("input[name=keyword_searchpage]").val()); location.href = "/portal/search?keyword=" + txt +'/'; } }); $('input[name=searchpage]').click(function(e){ txt = encodeURIComponent($('input[name=keyword_searchpage]').val()); if(txt==""){alert("请输入关键词")}else{location.href = "/portal/search/index/keyword/" + txt ;} }); $("img").each(function(i) { //判断picture>img及img本身没有链接 if (!this.parentNode.parentNode.href && !this.parentNode.href && this.src.indexOf('.png')<0 ) { $(this).wrap("") } }); $("[data-fancybox]").fancybox(); $(".various").fancybox({ maxWidth : 800, maxHeight : 600, fitToView : false, width : '70%', height : '70%', autoSize : false, closeClick : false, openEffect : 'none', closeEffect : 'none' }); $('.more-btn>a,.more-btn>a>i').click(function(){ $('.summary').css({"height":"auto"}); $(this).hide(); }); //回到顶部 $(document).on("click", ".backtotop", function () { $('body,html').animate({scrollTop: 0}, 300); return false; }); //浮动操作框 if ($(".floatbtn-item-top").length > 0) { $(window).scroll(function () { if ($(this).scrollTop() > $("header").height()) { $(".floatbtn-item-top").fadeIn(); } else { $(".floatbtn-item-top").fadeOut(); } }); } function showEnquiry(subject){ $('#subject').val(subject); $('#content').val(subject); $('.box-sevices').show(); } $('.enquiry').find('.floatbar-btn').click(function(){ showEnquiry(); }); $('.close-box-sevices').click(function(){ $('.box-sevices').hide(); }); $('#formenquire').submit(function(){ $.post( "/user/feedback/submit", $(this).serialize(), function(data,status){ if (data['code']==0){ alert("Message submitted successfully,we will contact with you via email as soon as possible."); $('#formenquire')[0].reset(); $('#subject').val(''); $('.box-sevices').hide(); } else{ alert("Submit Error"); } }); return false; }); $('.footermenu-item').find('.icon-add-pluss-').click(function(){ $('.footermenu-item').find('.row').addClass('hidden-xs'); $(this).parent().parent().find('.row').toggleClass('hidden-xs'); }); $('button.en').click(function(){ location.href="https://www.linshangtech.com/" }); $(".navtitle").find('i.icon-add-pluss-').click(function(){ $(this).parent().parent().find('ul').toggleClass('hidden-xs'); }); $('#to_home_page').click(function(){ window.location.href = '/'; }); if ($('#product_id').val()!=undefined){ $product_id = $('#product_id').val(); console.log($product_id); $.post( "/product/product/update", {'id':$product_id,'timestamp':new Date().getTime()}, function(data,status){ console.log(data); }); } }); $('.wechatservice').find('.floatbar-btn').hover( function(){ $('.box-wechat').show(); }, function(){ $('.box-wechat').hide(); } );