var is_scroll_ing = false $(function () { //menu $('.menu-btn').click(function () { $(this).toggleClass('menu-btn-on'); if ($(this).hasClass('menu-btn-on')) { $(".nav-mb>ul").slideDown(); } else { $(".nav-mb>ul").slideUp(); } }); // nav-pc $('.header-nav ul>li').each(function () { if ($(this).children().length !== 1) { $(this).addClass('has-childnav'); } }) // nav-mb // $('.nav-mb ul>li>a').each(function () { // if ($(this).parent('li').children().length != 1) { // $(this).addClass('has-childnav'); // $(this).on('click', function () { // $(this).next('ol').slideToggle(); // $(this).toggleClass('on'); // return false // }) // } // }) $('.nav-mb ul>li>a').each(function () { if ($(this).parent('li').children().length != 1){ $(this).addClass('has-childnav'); if($(this).hasClass('has-childnav')){ $(this).append('') } $(this).find('i').on('click', function (e){ e.stopPropagation(); // e.preventDefault(); $(this).parent().next('ol').slideToggle(); $(this).parent().toggleClass('on'); if($(this).parent().hasClass('on')){ setTimeout(function(){ $('.nav-mb ul').css({ 'height':'calc(100vh - 70px)', 'padding-bottom':'80px' }) },500) }else{ $('.nav-mb ul').css({ 'height':'auto', 'padding-bottom':'10px' }) } return false }) } }) $(".yuyue").click(function() { $(".yuyue-list").toggleClass('on') }) $(".yuyue-list li").click(function() { var _text = $(this).text() $("#yuyue_pro").val(_text) $(".yuyue").find('span').text(_text) }) header(); function header() { $(window).on('scroll', function () { if ($(window).scrollTop() > 0) { $('.index').removeAttr('id') } else { $('.index').attr('id', 'home') } }) } // search-click $(".header-search-icon").click(function () { $(".search-from").addClass('show'); }); $(".search-bg,.search-close-btn").click(function () { $(".search-from").removeClass('show'); }) var mySwiper = new Swiper('.banner-swiper', { on: { init: function(){ swiperAnimateCache(this); //隐藏动画元素 swiperAnimate(this); //初始化完成开始动画 }, slideChangeTransitionEnd: function(){ swiperAnimate(this); //每个slide切换结束时也运行当前slide动画 //this.slides.eq(this.activeIndex).find('.ani').removeClass('ani'); 动画只展现一次,去除ani类名 } }, direction: 'horizontal', autoplay: { delay: 3200, }, loop: true, pagination: { el: '.banner-pagination', clickable: true }, navigation: { nextEl: '.banner-pagination .swiper-button-next', prevEl: '.banner-pagination .swiper-button-prev', }, }) // $('.arrow-left').on('click', function (e) { // e.preventDefault(); // mySwiper.swipePrev(); // }) // $('.arrow-right').on('click', function (e) { // e.preventDefault(); // mySwiper.swipeNext(); // }) var _href = window.location.href; $(".page-nav-bar").find('li').each(function (i) { $(this).children('a').attr('data-id', 'nav' + i); $(this).children('a').attr('href', _href + '?location=nav' + i); }); $("#nav-bar-page-wrap").children('section').each(function (i) { $(this).attr('id', 'nav' + i); }); var _header_height = $(".header").height() var _nav_top = 0 if ($("#nav-bar-tab").length) { _nav_top = $("#nav-bar-tab").offset().top } nav_top = _nav_top - _header_height // console.log(_header_height) $("#nav-bar-tab").css('top', _header_height+'px') $("#nav-bar-tab").after($('')) // 回到顶部 var totop = document.getElementById('totop'); window.addEventListener('scroll',handle); handle(); function handle(){ var oTop = document.body.scrollTop || document.documentElement.scrollTop; if(oTop>200){ totop.className = 'aside-totop show'; }else{ totop.className = 'aside-totop'; } if (oTop>nav_top) { $("#nav-bar-tab").addClass('nav-fixed') $(".nav-bar-placeholder").show() } else { $("#nav-bar-tab").removeClass('nav-fixed') $(".nav-bar-placeholder").hide() } totop.onclick = function(){ window.scrollTo({ top:0, behavior:"smooth" }) } } // $('.left-right').children('section').each(function (i) { // if (i % 2 === 0) { // $(this).addClass('pic-right'); // $(this).find('.tedian-left').addClass('wow fadeInLeftBig'); // $(this).find('.tedian-right').addClass('wow fadeInRightBig'); // } else { // $(this).addClass('pic-left'); // $(this).find('.tedian-left').addClass('wow fadeInRightBig'); // $(this).find('.tedian-right').addClass('wow fadeInLeftBig'); // } // }); // $('.left-right2').children('section').each(function (i) { // if (i % 2 === 0) { // $(this).addClass('pic-left'); // $(this).find('.tedian-right').addClass('wow fadeInLeftBig'); // $(this).find('.tedian-left').addClass('wow fadeInRightBig'); // } else { // $(this).addClass('pic-right'); // $(this).find('.tedian-right').addClass('wow fadeInRightBig'); // $(this).find('.tedian-left').addClass('wow fadeInLeftBig'); // } // }); var index2List = $('.index-2-list') index2List.owlCarousel({ items: 3, loop: true, autoplay: true, navRewind:false, dots: false, nav: false, margin: 29, navText:['',''], responsive:{ 0:{ items: 1, margin: 0 }, 640:{ items: 2, margin: 12 }, 1024:{ items: 3, margin: 29, } } }); $('.index-2-arrow-left').click(function () { index2List.trigger('prev.owl'); }); $('.index-2-arrow-right').click(function () { index2List.trigger('next.owl'); }); var historyCarousel = $(".history-list") historyCarousel.owlCarousel({ items: 0, loop: false, autoplay: false, navRewind:false, dots: false, nav: false, margin: 60, navText:['',''], responsive:{ 0:{ items: 1, margin:0 }, 640:{ items: 4 }, 1024:{ items:5, margin: 30, } } }); $('.history-left').click(function () { historyCarousel.trigger('prev.owl'); }); $('.history-right').click(function () { historyCarousel.trigger('next.owl'); }); var wow = new WOW({ offset: 10 }); wow.init(); // 条纹颜色 // color-zebra $(".color-zebra").children('section').each(function (i) { i % 2 !== 0 ? $(this).addClass('bg-f2f4f5') : null; }) $(".color-zebra-2").children('section').each(function (i) { i % 2 === 0 ? $(this).addClass('bg-f2f4f5') : null; }) $('.recruitment-list').find('li').each(function () { $(this).click(function () { $(this).find('.job-more').toggleClass('active'); $(this).find('.job-bottom').slideToggle(); }); }); // 新的 $("#index-partner-bar").find('li').eq(0).addClass('on'); $('.index-partner-content').find('.index-partner-content-item').eq(0).addClass('on').siblings('.index-partner-content-item').removeClass('on'); $("#index-partner-bar").find('li').each(function(){ $(this).click(function(){ var index = $(this).index(); $("#index-partner-bar").find('li').eq(index).addClass('on').siblings('li').removeClass('on'); $('.index-partner-content').find('.index-partner-content-item').eq(index).addClass('on').siblings('.index-partner-content-item').removeClass('on'); }) }) var index_0_listCarousel = $('.index-0-list'); index_0_listCarousel.owlCarousel({ items: 3, loop: true, autoplay: true, navRewind:false, margin: 55, dots: false, nav: false, navText:['',''], }); var honorCarousel = $(".index-honor-list") honorCarousel.owlCarousel({ items: 5, loop: true, autoplay: true, navRewind:false, dots: false, nav: false, margin: 12, navText:['',''], responsive:{ 0:{ items: 2, margin:20, }, 641:{ items: 3, margin:20, }, 767:{ items: 3, }, 992:{ margin:12, items: 5, } } }); $('.honor-left').click(function () { honorCarousel.trigger('prev.owl'); }); $('.honor-right').click(function () { honorCarousel.trigger('next.owl'); }); baguetteBox.run('.baguetteBox'); if ($('#nav-bar-tab').length > 0) { var imgSrcList = [] $("img").each(function () { imgSrcList.push($(this).attr('src')) }) if ($(window).width() > 768) { Promise.all(loadImg(imgSrcList)).then(function () { console.log('图片加载完成') sidebarNav() }).catch(function (err) { sidebarNav() console.log('图片加载失败' + err) }); } } function sidebarNav() { // sidebar var asidebar = [] var asidebarHtml = '' $('#has-navbar').find('.sub-section').each(function() { var id = $(this).attr('data-id') var title = $(this).attr('data-title') asidebar.push({id: id, title: title}) }) if (!$("#nav-bar-tab a").length) { for (var i = 0; i < asidebar.length; i++) { asidebarHtml += '
  • '+ asidebar[i].title +'
  • ' } $("#nav-bar-tab ol").html(asidebarHtml) } for (var i = 0; i < asidebar.length; i++) { scrollToID(asidebar[i].id, 0); } var _header_height = $('.header').height(); var nav_height_list = []; $("#nav-bar-tab").find('a').each(function () { var id_name = $(this).attr('data-id'); var _height = $('#' + id_name).offset().top - _header_height - $('#nav-bar-tab').height() - 50 nav_height_list.push(_height); }); $(window).scroll(function () { if (is_scroll_ing) { return } for (var i = 0; i < nav_height_list.length; i++) { if ($(this).scrollTop() > (nav_height_list[i])) { $('#nav-bar-tab').find('a').removeClass('on'); $('#nav-bar-tab').find('a').eq(i).addClass('on'); continue; } } }) $('#nav-bar-tab').find('a').each(function () { $(this).click(function () { var href = window.location.href; var hrefArr = href.split('='); var newHref = ''; if (hrefArr.length == 1) { newHref = hrefArr[0] + '?location=' + $(this).attr('data-id'); } else { newHref = hrefArr[0] + '=' + $(this).attr('data-id'); } history.pushState('', '', newHref); scrollToID($(this).attr('data-id'), 0); return false; }) }) } // tab $(".tab-list").each(function () { var this_tab = $(this) var classN = $(this).attr('data-type') // 切换内容的Class var classPN = $(this).attr('data-parent_type') // 切换内容的父类的Class var currentId = $(this).attr('data-id') // Id var child_el = $(this).attr('data-child_el') || 'span' // tab-item的元素 var trigger = $(this).attr('data-trigger') || 'click' // 触发方式 默认点击 ['click','hover'] if (classPN) { $("." + classPN).each(function () { $(this).find("." + classN).eq(currentId).show().siblings().hide() }) } else { $("." + classN).eq(currentId).show().siblings().hide() } this_tab.find(child_el).eq(currentId).addClass('on').siblings(child_el).removeClass('on') var _is_mb = false if ($(window).width() < 740) { trigger = 'click' _is_mb = true } if (trigger === 'click') { this_tab.find(child_el).each(function (s_index) { $(this).click(function (e) { this_tab.attr('data-id', s_index) this_tab.find(child_el).eq(s_index).addClass('on').siblings(child_el).removeClass('on') if (classPN) { $("." + classPN).each(function () { $(this).find("." + classN).eq(s_index).show().siblings().hide() }) } else { $("." + classN).eq(s_index).show().siblings().hide() } if (_is_mb) { return false } }) }) } else if (trigger === 'hover') { console.log('a') this_tab.find(child_el).each(function (s_index) { $(this).hover(function () { this_tab.attr('data-id', s_index) this_tab.find(child_el).eq(s_index).addClass('on').siblings(child_el).removeClass('on') if (classPN) { $("." + classPN).each(function () { $(this).find("." + classN).eq(s_index).show().siblings().hide() }) } else { $("." + classN).eq(s_index).show().siblings().hide() } }) }) } }) }); // 加载完先 function GetRequest() { var url = location.search; //获取url中"?"符后的字串 var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.substr(1); strs = str.split("&"); for (var i = 0; i < strs.length; i++) { theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]); } } return theRequest; } function scrollToID(id, height) { if (GetRequest().location == id) { var scrollTo = $("#" + id).offset().top - height - $(".header").height() - $("#nav-bar-tab").height(); is_scroll_ing = true $("html,body").animate({ "scrollTop": scrollTo }, 0, 'linear', function() { setTimeout(function() { is_scroll_ing = false },10) }); $("[data-id]").removeClass('on'); $("[data-id=" + id + "]").addClass('on'); } } /** *加载图片 * @param arr ['图片链接'] * @returns {Array} */ function loadImg(arr) { var newimages = []; var arr = (typeof arr != "object") ? [arr] : arr //确保参数总是数组 for (var i = 0; i < arr.length; i++) { newimages[i] = new Promise(function (resolve, reject) { var image = new Image(); image.addEventListener('load', function listener() { resolve(image); this.removeEventListener('load', listener); }); image.src = arr[i]; image.addEventListener('error', reject); }) } return newimages }