mobileMenu('#gp-menu');//移动端导航 asideMenu('#gp-subLeft') mobileAsideMenu('#gp-m-subNav') headerFix() // 搜索弹出效果 $('.search_btn').click(function () { $('.search_box').addClass('on') setTimeout(function () { $(".search_box .notxt").focus(); }, 100) }) $('.close').click(function () { $('.search_box').removeClass('on') }) // 鼠标滚动渐渐出现 $('.effect3').each(function() { $(this).find("li").each(function(index){ var len = $(this).parent().find("li").length; $( this ).css({'transition-delay': (index*0.5/len)+'s'}); }) }); $('.effect6').each(function() { $(this).find("tr").each(function(index){ var len = $(this).parent().find("tr").length; $( this ).css({'transition-delay': (index*1/len)+'s'}); }) }); $(document).ready(function(){ enterEffects(); }) $(window).resize(function(){ var resizeTimer = null; if (resizeTimer) clearTimeout(resizeTimer); resizeTimer = setTimeout(function(){ enterEffects(); },50); }); $(window).scroll(function(){ enterEffects(); }); function enterEffects(){ var sWSon = document.documentElement.clientWidth; if(sWSon >= 992){ $(".effect").each(function(index, element) { var e = $(this); var c = $(window).height(); if($(window).scrollTop()>=$(e).offset().top - 0.9 * c){ $(e).addClass("isView"); }else{ $(e).removeClass("isView"); } }); } } function mobileMenu(id) { var oMenu = $(id); oMenu.find(".gp-menu-header .gp-menu-header-icon").click(function () { oMenu.find(this).toggleClass("gp-menu-header-icon-click gp-menu-header-icon-out"); $('.mobile_bg').fadeToggle(300) oMenu.find(".gp-menu-nav").filter('.gp-menu-dropdown1').slideToggle(300); //下拉竖排 oMenu.find(".gp-menu-nav").filter('.gp-menu-dropdown2').slideToggle(300); //下拉横排 oMenu.find(".gp-menu-nav").filter('.gp-menu-dropdown2').find('ul:first').children('li').find('a.iconfont').attr('href', 'javascript:void(0)') // oMenu.find(".gp-menu-nav").filter('.gp-menu-offcanvas1').slideToggle(300);//下拉横排 $('body').toggleClass('open') }); $('.mobile_bg').click(function () { oMenu.find('.gp-menu-header-icon').toggleClass("gp-menu-header-icon-click gp-menu-header-icon-out"); oMenu.find(".gp-menu-nav").filter('.gp-menu-dropdown1,.gp-menu-dropdown2').slideToggle(300); $(this).fadeToggle(300) $('body').removeClass('open'); }) oMenu.find(".gp-menu-nav > ul > li").each(function (index) { var len = oMenu.find(".gp-menu-nav > ul > li").length; $(this).css({ 'animation-delay': (index / len) + 's' }); }); oMenu.find(".gp-menu-nav li > ul").each(function () { var $this = $(this); $this.find('li').each(function (index) { var len = $this.find('li').length; $(this).css({ 'animation-delay': (index / len) + 's' }); }) }); oMenu.find('.gp-menu-nav li .gp-menu-arrow').click(function () { if ($(this).parent('li').hasClass('on')) { $(this).next('ul').slideUp(500) $(this).parent('li').removeClass('on') } else { $(this).next('ul').slideDown(500); $(this).parent().siblings().find('ul').slideUp(500) $(this).parent().siblings().removeClass('on') $(this).parent('li').addClass('on') } }) oMenu.find('.gp-menu-nav').filter('.gp-menu-dropdown2').find('a.icon-down').click(function () { if ($(this).parent('li').hasClass('on')) { $(this).next('ul').slideUp(500) $(this).parent('li').removeClass('on') } else { $(this).next('ul').slideDown(500); $(this).parent().siblings().find('ul').slideUp(500) $(this).parent().siblings().removeClass('on') $(this).parent('li').addClass('on') } }) } function asideMenu(menu) { //当前状态高亮 $(menu).find('.active').each(function () { if ($(this).parents('li').hasClass('active')) { $(this).parents('dl').css('display', 'block'); // $(this).parents('li').addClass('active') // $(this).parents('li').find('.gp-toggles').addClass('icon-jian').removeClass('icon-jia'); } }) $(menu).find('.gp-toggles').click(function () { if ($(this).parents('li').hasClass('active')) { $(this).addClass('icon-jia').removeClass('icon-jian') $(this).next('.gp-second-nav').slideUp(500) $(this).parents('li').removeClass('active') } else { $(this).addClass('icon-jian').removeClass('icon-jia'); $(this).next('.gp-second-nav').slideDown(500); $(this).parents('li').siblings().find('.gp-second-nav').slideUp(500) $(this).parents('li').siblings().removeClass('active') $(this).parents('li').siblings().find('.gp-toggles').addClass('icon-jia').removeClass('icon-jian') $(this).parents('li').addClass('active') } }) } //移动端侧边栏菜单 function mobileAsideMenu(menu, main) { $(menu).find('.gp-m-inner-header').click(function () { $(this).toggleClass("gp-m-inner-header-icon-click gp-m-inner-header-icon-out"); $(this).find('.iconfont').toggleClass("icon-down icon-u") $(".gp-subNavm").slideToggle(500); }); $('.gp-subNavm').find('.gp-m-toggle').click(function () { if ($(this).parents('li').hasClass('active')) { $(this).addClass('icon-right').removeClass('icon-down') $(this).next('dl').slideUp(500) $(this).parents('li').removeClass('active') } else { $(this).addClass('icon-down').removeClass('icon-right'); $(this).next('dl').slideDown(500); $(this).parents('li').siblings().find('dl').slideUp(500) $(this).parents('li').siblings().removeClass('active') $(this).parents('li').siblings().find('.gp-m-toggle').addClass('icon-right').removeClass('icon-down') $(this).parents('li').addClass('active') } }) }; /* tab切换 例调用: $(".tab").tab({ev : 'mouseover',more : false,auto : false}); */ ; (function ($) { $.fn.extend({ tab: function (options) { var defaults = { //默认参数 ev: 'mouseover', //默认事件'mouseover','click' delay: 100, //延迟时间 auto: true, //是否自动切换 true,false speed: 2000, //自动切换间隔时间(毫秒) more: false //是否有more,false,true }; var options = $.extend(defaults, options); //用户设置参数覆盖默认参数 return this.each(function () { var o = options; var obj = $(this); var oTil = obj.find('.til_tab'); var oBoxs = obj.find('.tabList') var oBox = oBoxs.find('.tabListBox'); var oMore = null; var iNum = 0; var iLen = oTil.length; obj.find('.til_tab').eq(0).addClass('on') oBoxs.each(function () { $(this).find('.tabListBox').eq(0).css('display', 'block') }) obj.find('.more_tab').eq(0).css('display', 'block') //鼠标事件绑定 oTil.bind(o.ev, function () { var _this = this; if (o.ev == 'mouseover' && o.delay) { _this.timer = setTimeout(function () { change(_this); }, o.delay); } else { change(_this); }; }) oTil.bind('mouseout', function () { var _this = this; clearTimeout(_this.timer); }); //自动切换效果 (function autoPlay() { var timer2 = null; if (o.auto) { function play() { iNum++; if (iNum >= iLen) { iNum = 0; }; change(oTil.eq(iNum)); }; timer2 = setInterval(play, o.speed); obj.on('mouseover', function () { clearInterval(timer2); }) obj.on('mouseout', function () { timer2 = setInterval(play, o.speed); }) }; })(); function change(box) { iNum = $(box).index(); oTil.removeClass('on'); oBoxs.each(function () { $(this).find('.tabListBox').css('display', 'none') }) if (o.more) { oMore = obj.find('.more_tab'); oMore.css('display', 'none'); oMore.eq(iNum).css('display', 'block'); }; oTil.eq(iNum).addClass('on'); oBoxs.each(function () { $(this).find('.tabListBox').eq(iNum).css('display', 'block') }) } }); }, tab2: function (options){ var defaults = { //默认参数 ev : 'mouseover', //默认事件'mouseover','click' delay : 200, //延迟时间 auto : true, //是否自动切换 true,false speed : 2000, //自动切换间隔时间(毫秒) more : false //是否有more,false,true }; var options = $.extend(defaults, options); //用户设置参数覆盖默认参数 return this.each(function (){ var o = options; var obj = $(this); var oTil = obj.find('.til_tab'); var oBox = obj.find('.tabListBox'); var oMore = null; var iNum = 0; var iLen = oTil.length; obj.find('.til_tab').eq(0).addClass('on') obj.find('.tabListBox').eq(0).addClass('show') obj.find('.more_tab').eq(0).css('display','block') //鼠标事件绑定 oTil.bind(o.ev , function (){ var _this = this; if(o.ev == 'mouseover' && o.delay){ _this.timer = setTimeout(function (){ change(_this); },o.delay); }else{ change(_this); }; }) oTil.bind('mouseout',function (){ var _this = this; clearTimeout(_this.timer); }); //自动切换效果 (function autoPlay(){ var timer2 = null; if(o.auto){ function play(){ iNum++; if(iNum >= iLen){ iNum =0; }; change(oTil.eq(iNum)); }; timer2 = setInterval(play,o.speed); obj.on('mouseover',function (){ clearInterval(timer2); }) obj.on('mouseout',function (){ timer2 = setInterval(play,o.speed); }) }; })(); function change(box){ iNum = $(box).index(); oTil.removeClass('on'); oBox.addClass('hide').removeClass('show') if(o.more){ oMore = obj.find('.more_tab'); oMore.css('display','none'); oMore.eq(iNum).css('display','block'); }; oTil.eq(iNum).addClass('on'); oBox.eq(iNum).addClass('show').removeClass('hide') // $('.tabList4').find('.slick-slider').eq(iNum).slick('slickNext',1) } }); } }) })(jQuery); // 页面加载效果 $(window).scroll(function () { $(".effect2").each(function (index, element) { var e = $(this); var f = 9; if (!f && f != 0) { f = $(window).height() * 6 * 0.1; } else { f = $(window).height() * f * 0.1; } if ($(window).scrollTop() >= $(e).offset().top - f) { if (!$(e).hasClass("isView")) { $(e).addClass("isView"); } } else { if ($(e).hasClass("isView")) { $(e).removeClass("isView"); } } }); }); //头部置顶固定 function headerFix() { var iWSon = document.documentElement.clientWidth; var $windowHeight = $(window).height(); var bodyHeight = $(document.body).height(); var $headerHeight = $('header').height(); $(window).scroll(function() { var scrollTop = $(window).scrollTop(); if (scrollTop >= $headerHeight && bodyHeight > $windowHeight + $headerHeight * 2) { if (iWSon > 1020) { $('header,body').addClass('currents'); } else { $('header,body').removeClass('currents'); } } else { $('header,body').removeClass('currents'); } }) } window.onresize=function() { headerFix() }