$(function () { //$('#header').load('header.html') //$('#footer').load('footer.html') $('body').css('opacity', 1) if (!$('[data-type="wow"]').hasClass('wow')) { $('[data-type="wow"]').addClass('wow fadeInUp') } var wowList = 0 var wow = new WOW({ boxClass: 'wow', // 需要执行动画的元素的 class animateClass: 'animated', // animation.css 动画的 class offset: 0, // 元素的位置露出后距离底部多少像素执行 mobile: true, // 是否在移动设备上执行动画 live: true, // 异步加载的内容是否有效 callback: function (e) { if ($(e).attr('data-type') === 'wow') { wowList += 100 $(e).css('animation-delay', wowList + 'ms') } if (['index3Content', 'dealer1Content'].includes($(e).attr('id'))) { $(e).addClass('active') } } }) wow.init() setTimes() var timeOuts = null function setTimes() { timeOuts = setTimeout(function () { wowList = 0 }, 150) } /*****************************手机站导航切换按钮*******************************/ $('body').on('click', '.headerSJ .navbar', function (event) { $('.headerSJ .navwrap').animate({ 'left': '0px', 'opacity': '1' }, 800) $('.headerSJ .navbg').fadeIn(800) }) $('body').on('click', '.headerSJ .navbg', function (event) { $(this).fadeOut(800) $('.headerSJ .navwrap').animate({ 'left': '-50%', 'opacity': '0' }, 800) }) $('body').on('click', '.headerSJ .plus', function () { //二级栏目手风琴切换效果 $(this).toggleClass('minus').parent().siblings().find('.minus').removeClass('minus') $(this).next('.SJbod').stop().slideToggle(300).parent().siblings().find('.SJbod').stop().slideUp(500) }) var st = $(window).scrollTop() $('.countup').each(function (index, el) { var id = $(el).attr('id') || '_countup' + (new Date().getTime()) + $(el).index('.countup') $(el).attr('id', id) el.countOnOff = true el.options = $(el).attr('options') ? JSON.parse($(el).attr('options')) : { "separator": "" } el.num = new CountUp(id, 0, $(el).text(), 0, 5, el.options) if (st > $(el).offset().top - $(window).height() + $(el).outerHeight() && el.countOnOff) { el.num.start() el.countOnOff = false } }) $(window).scroll(function () { /*滚动时先清除上一个定时器,然后再设置新的定时器,以免出现多个定时器造成混乱*/ clearTimeout(timeOuts) setTimes() st = $(window).scrollTop() $('.countup').each(function (index, el) { if (st > $(el).offset().top - $(window).height() + $(el).outerHeight() && el.countOnOff) { el.num.start() el.countOnOff = false } }) if (st > 100) { $('.banner2_text').addClass('active') } else { $('.banner2_text').removeClass('active') } if (st > 0) { $('.header').addClass('active') } else { $('.header').removeClass('active') } }) // 优化a标签 $('a').each(function () { if ($(this).attr('href') == '') { $(this).attr('href', 'javascript:;') } else if ($(this).attr('href') == undefined) { $(this).css('cursor', 'pointer') } }) $('body').on('click', '.video_btn', function () { $('.z_tanchuang').removeClass('out').addClass('one'); var src = $(this).attr('data-src'); $('html').addClass('act'); $(".z_tanchuang video").attr({src: src}).trigger('play'); }); $('.z_tanchuang .out').on('click',function(){ $('.z_tanchuang').addClass('out'); $('html').removeClass('act'); $(".z_tanchuang video").trigger('pause'); }); $('body').on('mouseenter', '.header_nav > li', function () { $(this).children('.header_nav2, .header_nav3').stop().slideDown(200) $(this).addClass('on').siblings('.active').addClass('unactive').removeClass('active') }) $('body').on('mouseleave', '.header_nav > li', function () { $(this).children('.header_nav2, .header_nav3').stop().slideUp(200) $(this).removeClass('on').siblings('.unactive').addClass('active').removeClass('unactive') }) var navI = $('body').data('index') setTimeout(function () { $('.header_nav li').eq(navI).addClass('active').siblings().removeClass('active') }) $('body').on('click', '.header_search .img_h', function () { var keyword = $('#keyword').val() if (keyword) { window.location.href = 'result.html?keyword=' + keyword } }) $('body').on('keyup', '#keyword', function (e) { var keyword = $('#keyword').val() if (e.keyCode === 13 && keyword) { if (keyword) { window.location.href = 'result.html?keyword=' + keyword } } }) })