$(document).ready(function() { // 动画初始化 if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))) { var wow = new WOW({ boxClass: 'wow', animateClass: 'animated', offset: 0, mobile: true, live: true }); wow.init(); }; // 手机导航 $('.menuBtn').append(''); $('.menuBtn').click(function(event) { $(this).toggleClass('open'); $('.h-r').toggleClass("on"); }); /* $('.full_so .close').on('click', function (e) { $('.full_so').stop().slideUp(); e.stopPropagation(); }); */ var _winw = $(window).width(); if (_winw > 1199) { $('.nav li').hover(function() { $(this).find('.sub').stop().slideDown(); if ($(this).find('.sub').length) { $(this).addClass('ok'); $('.header').addClass('on'); } else { $('.header').removeClass('on'); } }, function() { $(this).removeClass('ok'); $(this).find('.sub').stop().slideUp(); }); $('.nav').mouseleave(function(event) { if ($('.header').hasClass('on')) { $('.header').removeClass('on'); }; }); $('.h-so').on('click', function(e) { $('.h-so .form').stop().slideToggle(); e.stopPropagation(); }); $('.h-so').on('click', '.form', function(e) { e.stopPropagation(); }); $('body').on('click', function(e) { $('.h-so .form').stop().slideUp(); }); } else { $('.nav li').unbind('mouseenter mouseleave') $('.nav .v1').click(function() { if ($(this).siblings('.sub').length) { $(this).parents('li').toggleClass('on').siblings('li').removeClass('on').find('.sub').stop().slideUp(); $(this).siblings('.sub').stop().slideToggle(); return false; } }); $('.f-dl').on('click', 'dt', function() { $(this).siblings('dd').stop().slideToggle().parents('dl').toggleClass('on').siblings('dl').removeClass('on').find('dd').stop().slideUp(); }); } // 头部动态加类 var header = $('.header'), headerH = header.height(), initScrh = $(window).scrollTop(); function changeHeader(scrH) { if (scrH > headerH) { header.addClass('fixed'); } else { header.removeClass('fixed'); } } changeHeader(initScrh); $(window).on('scroll', function() { var _scrH = $(window).scrollTop(); changeHeader(_scrH); }); // 弹窗 $(".playBtn").on('click', function() { var url = $(this).attr('data-src'); $('.maskBg').fadeIn(); var video = '' $(".maskCon").html(video); $("#video")[0].play(); }) $(".js-close").on('click', function() { $('.maskBg').fadeOut(); $("#video")[0].pause(); $(".maskCon").html(''); }) // 返回顶部 $('.g-backtop').click(function(e) { e.stopPropagation(); $("body,html").animate({ scrollTop: 0 }, 500); }); // 设置时间轴位置 $(window).scroll(function() { var banheight = $(".banner").height(); console.log(banheight) // 滚动条距离顶部的距离 大于 200px时 if ($(window).scrollTop() >= banheight) { $(".flex-right").addClass("on") } else { $(".flex-right").removeClass("on") } }); // 弹出层 /* $('[data-fancybox]').fancybox({ youtube: { controls: 0, showinfo: 0 }, vimeo: { color: 'f00' } });*/ // 选项卡 鼠标点击 $(".TAB_CLICK li").click(function() { var tab = $(this).parent(".TAB_CLICK"); var con = tab.attr("id"); var on = tab.find("li").index(this); $(this).addClass('on').siblings(tab.find("li")).removeClass('on'); console.log($(con)); // $(con).eq(on).addClass('show').siblings(con).removeClass('show'); $(con).eq(on).show().siblings(con).hide(); }); $('.TAB_CLICK').each(function(index, el) { if ($(this).find('li.on').length) { $(this).find("li.on").trigger('click'); } else { $(this).find("li").filter(':first').trigger('click'); } }); // 选项卡 鼠标点击 $(".TAB_HOVER .icon").on('mouseenter', function() { console.log(1111); var tab = $(this).parents(".TAB_HOVER"); var con = tab.attr("id"); var on = tab.find("li").index($(this).parents('li')); $(this).parents('li').addClass('on').siblings().removeClass('on'); console.log($(con)); // $(con).eq(on).addClass('show').siblings(con).removeClass('show'); $(con).eq(on).show().siblings(con).hide(); }); $('.TAB_HOVER').each(function(index, el) { if ($(this).find('li.on').length) { $(this).find("li.on").find('.icon').trigger('mouseenter'); } else { $(this).find("li").filter(':first').find('.icon').trigger('mouseenter'); } }); });