"use strict"; var windowWidth = $(window).width(), windowHeight = $(window).height(); window.mobileUtil = (function(a, b) { var c = navigator.userAgent, isAndroid = /android|adr/gi.test(c), isIOS = /iphone|ipod|ipad/gi.test(c) && !isAndroid, isBlackBerry = /BlackBerry/i.test(c), isWindowPhone = /IEMobile/i.test(c), isMobile = isAndroid || isIOS || isBlackBerry || isWindowPhone; return { isAndroid: isAndroid, isIOS: isIOS, isMobile: isMobile, isWeixin: /MicroMessenger/gi.test(c), isQQ: /QQ/gi.test(c), isSafari: /Safari/gi.test(c) } })(window, document); $(function() { /** * =====common===== */ layer.config({ shade: [.6, '#000'], shadeClose: true, skin: 'layui-layer-custom' }); // 加载浮现动画效果 if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))) { new WOW().init(); }; document.body.addEventListener('touchstart', function() {}); // 页面高度不足时,footer居底 setTimeout(function() { var bodyHeight = $('body').height(); if (windowHeight > bodyHeight) { $('.footer').addClass('fixed'); var minBodyHeight = mobileUtil.isMobile ? (windowHeight - 50) : windowHeight; $('body').css('min-height', minBodyHeight); } }, 500); // 分享 socialShare('.header-share', { sites: ['qq', 'wechat', 'weibo'] }); socialShare('.footer-share', { sites: ['qq', 'wechat', 'weibo', 'qzone', 'douban'] }); if (mobileUtil.isMobile) { // 移动端 var $menu = $('nav#menu'); $menu.mmenu({ dragOpen: true }); // header $('#menu ul').eq(0).append('
  • ' + $('.header-tools').html() + '
  • '); $('.header-tools').remove(); // $('#menu ul').eq(0).append('
  • ' + $('.header-contact').html() + '
  • '); // $('#menu ul').eq(0).append(''); // 菜单展开 $('.btn-expand-toggle').click(function() { var type = $(this).data('type'); var isActive = $(this).hasClass('active'); if (isActive) { $(this).removeClass('active').addClass('cancel'); } else { $(this).removeClass('cancel').addClass('active'); } if (type == 'navbanner') { if (isActive) { $('.nav-banner').stop().slideUp(); } else { $('body,html').animate({ scrollTop: 200 }, 500); $('.nav-banner').stop().slideDown(); } } }); $('.submenu-toggle').click(function() { var isActive = $(this).hasClass('active'); if (isActive) { $(this).removeClass('active'); $('.submenu ul').stop().slideUp(); } else { $(this).addClass('active'); $('.submenu ul').stop().slideDown(); } }); $('.hidden-xs').remove(); } else { // PC端 $('.visible-xs').remove(); /** * header */ // 调整间距 var headerMainWidth = $('.header-main').width(), headerLogoWidth = $('.header .logo').width(), headerMenuWidth = $('.header #menu').width(), headerToolsWidth = $('.header .header-tools').width(), headerMenuLeft = (headerMainWidth - headerLogoWidth - headerMenuWidth - headerToolsWidth) / 2; $('.header #menu').css('margin-left', headerMenuLeft); // header-top 官方微信 $('.wechat-code').hover(function() { $(this).children('.content').stop().slideDown(); }, function() { $(this).children('.content').stop().slideUp(); }); // nav-header var $navSub = null; $('#menu .nav-list>li').hover(function() { var menuOffsetLeft = $(this).offset().left + 42 - 30; console.log(menuOffsetLeft); $navSub = $(this).children('.nav-sub'); $navSub.css('padding-left', menuOffsetLeft); if ($navSub.length) { $(this).addClass('fat'); $navSub.stop().slideDown(); } }, function() { if ($navSub.length) { $(this).removeClass('fat'); $navSub.stop().slideUp(); } }); // nav-banner $('.nav-banner .item').hover(function() { $(this).children('.nav-sub').stop().slideDown(); $(this).siblings().children('.nav-sub').stop().slideUp(); }, function() { $(this).children('.nav-sub').stop().slideUp(); }); $('.nav-sub li').hover(function() { $(this).children('.nav-sun').stop().slideDown(); $(this).siblings().children('.nav-sun').stop().slideUp(); }, function() { $(this).children('.nav-sun').stop().slideUp(); }); // nav-main $('.main-nav>li').click(function() { $(this).addClass('hover').children('.nav-sub').stop().slideToggle(); $(this).siblings().removeClass('active hover').children('.nav-sub').stop().slideUp(); }); } // 导航栏搜索表单 $('#formNavSearch').submit(function() { console.log($(this)); var $keywords = $($(this)[0][0]); console.log($keywords); if ($keywords.val() == '') { $keywords.focus().attr('placeholder', '请输入关键字') return false; } }); // 内页搜索表单 $('#formInnerSearch').submit(function() { console.log($(this)); var $searchType = $($(this)[0][0]), $keywords = $($(this)[0][1]); if ($keywords.val() == '') { $keywords.focus().attr('placeholder', '请输入关键字') return false; } else { console.log('您要搜索的类型为:' + $searchType.val()); console.log('搜索关键字为:' + $keywords.val()); return false; } }); // 播放视频 var playVideo = function(url, size) { console.log(size); var videoWidth, videoHeight, myPlayer; if ($('#myVideo').length == 0) { $('#layerVideo').html( '' ); } myPlayer = videojs('myVideo'); videojs("myVideo", {}, function() { window.myPlayer = this; myPlayer.src(url); myPlayer.load(url); }); if (mobileUtil.isMobile) { videoWidth = windowWidth + 'px'; videoHeight = windowWidth * size[1] / size[0] + 'px'; } else { videoWidth = size[0] + 'px', videoHeight = size[1] + 'px' } setTimeout(function() { layer.open({ type: 1, title: false, closeBtn: 1, area: [videoWidth, videoHeight], content: $('#layerVideo'), skin: 'layui-layer-close', success: function() { myPlayer.play(); }, end: function() { myPlayer.pause(); } }); }, 300); }; // 播放视频弹窗 $('.btn-play-video').click(function() { var videoUrl = $(this).data("video"), videoSize = $(this).data("size").split('*'); playVideo(videoUrl, videoSize); }); // 招聘列表 $('.list-recruitment .btn-toggle').click(function() { var $parent = $(this).parent(), isActive = $parent.hasClass('active'); if (isActive) { $(this).text('Learn More'); } else { $(this).text('↑'); } $parent.toggleClass('active'); $(this).prev().stop().slideToggle(); $(this).parent().siblings().children('.detail').slideUp(); }); // nat切换 $('.nav-tab-switch .item').hover(function() { var index = $(this).index(); console.log(index); $(this).addClass('active').siblings().removeClass('active'); // $(this).parent().next('.nav-content-switch').children('.nav-content-item').eq(index-1).stop().slideDown().siblings().stop().slideUp(); $('.nav-content-switch').children('.nav-content-item').eq(index).stop().slideDown().siblings().stop().slideUp(); }); /** * aside */ $('.aside-tool li').hover(function() { $(this).children('.content').stop().slideDown(); }, function() { $(this).children('.content').stop().slideUp(); }); // 返回顶部 $('#btnBackTop').click(function() { $('body,html').animate({ scrollTop: 0 }, 500); }); /** * 滑动门 */ $('.sliding-door .item').hover(function() { $(this).addClass('active').siblings().removeClass('active'); }); }); // 页面滚动 $(window).scroll(function() { var scrolls = $(this).scrollTop(); if (scrolls > 100) { $('.aside-tool').fadeIn(); } else { $('.aside-tool').fadeOut(); } }); // 简介轮播图 function swiperSimple(classname) { new Swiper(classname, { autoplay: 5000, grabCursor: true, autoplayDisableOnInteraction: false, nextButton: classname + ' .swiper-button-next', prevButton: classname + ' .swiper-button-prev' }); } function test() { var array = [ [175, 184], [364, 263], [400, 258], [440, 295], [476, 197], [275, 278], [321, 374], [667, 109], [653, 168], [373, 297], [416, 353], [511, 232], [481, 252], [437, 443], [390, 448], [610, 196], [496, 310], [529, 166] ]; // array.forEach(item => { // var left = item[0] / 746 * 100; // var top = item[1] / 565 * 100; // console.log('left: ' + left.toFixed(2) + '%;top:' + top.toFixed(2) + '%;'); // }) } function getViewportSize(w) { w = w || window; //除了IE8以及更早版本外,其它浏览器都能用 if (w.innerWidth != null) { return { w: w.innerWidth, h: w.innerHeight } }; //对标准模式下的IE或任何浏览器 var d = w.document; if (document.compatMode == "CSS1Compat") { return { w: d.documentElement.clientWidth, h: d.documentElement.clientHeight } } //对怪异模式下的浏览器 return { w: d.body.clientWidth, h: d.body.clientHeight } }