"use strict"; var windowWidth = $(window).width(), windowHeight = document.documentElement.clientHeight, layerWidth = '520px', layerHeight = 'auto'; 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; if (isMobile) { layerWidth = layerHeight = '90%'; } 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' }); document.body.addEventListener('touchstart',function(){}); // 椤甸潰楂樺害涓嶈冻鏃?footer灞呭簳 setTimeout(function(){ var bodyHeight = $('body').height(); if (windowHeight > bodyHeight) { $('.footer').addClass('fixed'); var minBodyHeight = mobileUtil.isMobile ? (windowHeight - 96) : (windowHeight - 154); $('body').css('min-height', minBodyHeight); } }, 500); /** * 鍔犺浇娴幇鍔ㄧ敾鏁堟灉 */ if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))){ new WOW().init(); }; if(mobileUtil.isMobile) { // 绉诲姩绔 $('.hidden-xs').remove(); // 绉诲姩鑿滃崟鑺傜偣 $('.search').prependTo('#menu'); $('.menu-list>li').each(function() { var iconfont = $(this).children('a').find('.iconfont'); iconfont.prependTo($(this)); }); $('#menu>ul>li').click(function() { console.log(1); $(this).children('.menu-sub').slideToggle(); }); // 鑿滃崟灞曞紑 $('.btn-expand-toggle').click(function(event){ event.stopPropagation(); var type = $(this).data('type'); var isActive = $(this).hasClass('active'); console.log(type); if (isActive) { $(this).removeClass('active').addClass('cancel'); } else { $(this).removeClass('cancel').addClass('active'); } switch(type) { case 'navbanner': if (isActive) { $('.nav-banner').stop().slideUp(); } else { $('body,html').animate({ scrollTop: 200 }, 500); $('.nav-banner').stop().slideDown(); } break; case 'headermenu': // header鑿滃崟鍒囨崲 if (isActive) { $('#menu').removeClass('active'); } else { $('#menu').addClass('active'); } break; case 'mainnav': // main瀵艰埅鍒囨崲 if (isActive) { $('.main-nav-sub ul').stop().slideUp(); } else { $('.main-nav-sub ul').stop().slideDown(); } break; } }); // main-瀵艰埅鍒囨崲 $('.selected').click(function(){ var $btn = $(this).children('.btn-expand-toggle'); var isActive = $btn.hasClass('active'); if (isActive) { $btn.removeClass('active').addClass('cancel'); $(this).parent().children('ul').stop().slideUp(); } else { $btn.removeClass('cancel').addClass('active'); $(this).parent().children('ul').stop().slideDown(); } }); } else { // PC绔 $('.visible-xs').remove(); // heder menu鑿滃崟 $('#menu>ul>li').hover(function() { var index = $(this).index(); console.log(index); let cssStyle = ''; switch(index) { case 4: // 鍋ュ悍涓績 cssStyle = { left: $(this).position().left } break; case 5: case 7: case 8: // 妫€楠屼腑蹇冦€佷汉鎵嶆垬鐣ャ€佽祫鏂欎笅杞 cssStyle = { left: 'auto', right: 0 } break; } $(this).children('.menu-sub').stop().slideDown().css(cssStyle); $(this).siblings().children('.menu-sub').stop().slideUp(); }, function() { $(this).children('.menu-sub').stop().slideUp(); }); /** * 闈㈡澘-浜斿僵 */ if($('.list-panel-colorful').length > 0) { var contentMaxHeight = 0; $('.list-panel-colorful .item').each(function() { var contentHeight = $(this).find('.middle-box').height(); if (contentHeight > contentMaxHeight) { contentMaxHeight = contentHeight; } }); $('.list-panel-colorful .middle-box').height(contentMaxHeight); } } /** * 鎼滅储琛ㄥ崟 */ $('#formSearch').submit(function() { var $keywords = $($(this)[0][0]); if ($keywords.val() == '') { $keywords.focus(); return false; } return false; }); /** * main-nav鍒囨崲 */ $('.main-nav .item').click(function(){ var index = $(this).index(); $(this).addClass('active').siblings().removeClass('active'); $('.content-item').eq(index).stop().slideDown().siblings().stop().slideUp(); }); /** * main-aside-nav灞曞紑 */ $('.list-aside-nav .title').click(function() { var that = $(this); $(this).parent().toggleClass('show').siblings().removeClass('show'); $(this).next().stop().slideToggle(); $(this).parent().siblings().children('.list-sub').stop().slideUp(); // setTimeout(function() { // that.parent().toggleClass('active'); // that.parent().siblings().removeClass('active'); // }, 300); }); /** * 灞曠ず鍏ㄩ儴鏂囩珷 */ $('.btn-show-leftover').click(function() { $(this).hide(); $('.article-leftover').css({ 'margin': 0, 'padding': 0 }); $('.article-leftover-content').css({ 'max-height': 'none' }); }); /** * 鍒楄〃-闈㈡澘 */ $('.list-panel .title').click(function(){ var $parent = $(this).parent(), active = $parent.hasClass('active'); if (active) { $(this).find('.btn-show').addClass('icon-increase').removeClass('icon-reduce'); } else { $(this).find('.btn-show').removeClass('icon-increase').addClass('icon-reduce'); } $parent.toggleClass('active'); $(this).next().stop().slideToggle(); $(this).parent().siblings().removeClass('active').children('.content').slideUp().prev().find('.btn-show').addClass('icon-increase').removeClass('icon-reduce'); }); /** * 鑽h獕 */ $('.list-honor li').click(function() { var certificate = $(this).data('certificate'), name = $(this).text(); $('.certificate img').attr('src', certificate); $('.certificate .name').text(name); }); /** * 鎷涜仒鍒楄〃 */ $('.list-recruitment .btn-toggle').click(function(){ var $parent = $(this).parent(), isActive = $parent.hasClass('active'); if (isActive) { $(this).text('鏌ョ湅璇︽儏'); } else { $(this).text('鐐瑰嚮鏀惰捣'); } $parent.toggleClass('active'); $(this).prev().stop().slideToggle(); $(this).parent().siblings().children('.detail').slideUp(); }); // 杩斿洖椤堕儴 $('#btnBackTop').click(function(){ $('body,html').animate({scrollTop: 0},500); }); // 鎾斁瑙嗛 var playVideo = function(url, size) { console.log(size); var videoWidth, videoHeight, myPlayer; if ($('#myVideo').length == 0) { $('#layerVideo').html(url); } // 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('*'); // console.log(videoSize) playVideo(videoUrl, videoSize); }); }); /** * swiper鍒囨崲-鍒嗛〉 */ function swiperBtnPagination(classname, focusClass, loop, callback) { var loop = loop ? true : false; var objName = classname; if (focusClass) objName = classname + ' ' + focusClass; var config = { loop: loop, autoplay: 5000, grabCursor: true, paginationClickable: true, autoplayDisableOnInteraction: false, resistanceRatio: 0, roundLengths : true, pagination: classname + ' .swiper-pagination', nextButton: classname + ' .swiper-button-next', prevButton: classname + ' .swiper-button-prev' }; if (callback) { // 鍒囨崲鍓嶇殑鍥炶皟 config.onSlideChangeStart = function(swiper){ callback(swiper.activeIndex); } } new Swiper(objName, config); } /** * swiper鍒嗛〉 */ function swiperPagination(classname, focusClass) { var objName = classname; if (focusClass) objName = classname + ' ' + focusClass; var config = { loop: true, autoplay: 5000, grabCursor: true, paginationClickable: true, autoplayDisableOnInteraction: false, resistanceRatio: 0, roundLengths : true, pagination: classname + ' .swiper-pagination' }; new Swiper(objName, config); } /** * swiper鍒嗙粍 */ function swiperGroupPagination(classname, focusClass, loop, view, group, spaceBetween) { var loop = loop || true; var objName = classname; if (focusClass) objName = classname + ' ' + focusClass; var config = { loop: loop, autoplay: 5000, grabCursor: true, paginationClickable: true, autoplayDisableOnInteraction: false, resistanceRatio: 0, roundLengths : true, slidesPerView: view, slidesPerGroup: group, spaceBetween: spaceBetween, pagination: classname + ' .swiper-pagination', nextButton: classname + ' .swiper-button-next', prevButton: classname + ' .swiper-button-prev' }; new Swiper(objName, config); } function test() { var array = [ [133, 134], [259, 372], [276, 294], [307, 229], [321, 341], [329, 305], [346, 249], [392, 327], [398, 381], [402, 243], [405, 145], [422, 196], [418, 254], [445, 167], [455, 214], [464, 351], [477, 310], [484, 265], [485, 214], [502, 295], [504, 175], [519, 150], [529, 115] ]; // array.forEach(item => { // var left = item[0] / 617 * 100; // var top = item[1] / 601 * 100; // console.log('left: ' + left.toFixed(2) + '%;top:' + top.toFixed(2) + '%;'); // }) } // test();