$(function () { $('#header').load('header.html') $('#footer').load('footer.html') $('body').css('opacity', 1) for (let i = 0; i < $('[data-type="wow"]').length; i++) { if (!$('[data-type="wow"]').eq(i).hasClass('wow')) { $('[data-type="wow"]').eq(i).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') } } }) wow.init() setTimes() var timeOuts = null function setTimes() { timeOuts = setTimeout(function () { wowList = 0 }, 150) } /*****************************手机站导航切换按钮*******************************/ $('body').on('click', '.headerSJ .navbar', function (event) { $(this).toggleClass('active unactive') }) $('body').on('click', '.headerSJ .navbar.unactive', function (event) { $('.headerSJ .navwrap').animate({ 'top': '60px', 'opacity': '1' }, 500) }) $('body').on('click', '.headerSJ .navbar.active', function (event) { $('.headerSJ .navwrap').animate({ 'top': '100%', 'opacity': '0' }, 500) }) $('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 var decimals = $(el).attr('decimals') || 0 el.options = $(el).attr('options') ? JSON.parse($(el).attr('options')) : { "separator": "" } el.num = new CountUp(id, 0, $(el).text(), decimals, 5, el.options) if (st > $(el).offset().top - $(window).height() + $(el).outerHeight() && el.countOnOff) { el.num.start() el.countOnOff = false } }) if (!$('.header').hasClass('forceFixed')) { if (st > 0) { $('.header').addClass('fixed') } else { $('.header').removeClass('fixed') } } $(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 (!$('.header').hasClass('forceFixed')) { if (st > 0) { $('.header').addClass('fixed') } else { $('.header').removeClass('fixed') } } }) // 优化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 () { var videoSrc = $(this).attr('data-videoSrc') || '' var tit = $(this).attr('data-tit') || '' var subTit = $(this).attr('data-subTit') || '' $('#video_model video').attr('src', videoSrc) $('#video_model .text h6').text(tit) $('#video_model .text p').text(subTit) if (!tit) $('#video_model .text h6').hide() if (!subTit) $('#video_model .text p').hide() $('#video_model').fadeIn() }) $('body').on('click', '#video_model .mask, #video_model .close', function () { $('#video_model').fadeOut() $('#video_model video').attr('src', '') }) $('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').stop().slideUp(200) $(this).removeClass('on').siblings('.unactive').addClass('active').removeClass('unactive') }) $('body').on('change', '[name="websit"]', function (e) { var url = $('[name="websit"]').find('option:selected').val() $('[name="websit"]').val('') window.open(url) }) $('body').on('keydown', '[name="keyword"]', function (e) { var keyword = $('[name="keyword"]').val() if (e.keyCode === 13 && keyword) { window.location.href = 'result.html?keyword=' + keyword } }) $('body').on('click', '.header .header_nav li.search .img', function (e) { var keyword = $('[name="keyword"]').val() if (keyword) { window.location.href = 'result.html?keyword=' + keyword } }) $('body').on('click', '.header_search_m .img', function () { var keyword = $('[name="keywordm"]').val() if (keyword) { window.location.href = 'result.html?keyword=' + keyword } }) var navI = $('body').data('index') setTimeout(function () { $('.header_nav > li').eq(navI).addClass('active').siblings().removeClass('active') }, 200) })