var isMobile = false, mobile = false, win_width = 0, win_height = 0, navItem = 0, atH =66, $menuBtn = jQuery('.menu-handler'), pageNavNum=0, scrollNav=0; var pageInit = { init: function () { win_width = $(window).width(); win_height = $(window).height(); if (win_width <= 1024) { isMobile = true; atH =54; } else if (win_width > 1024) { isMobile = false; atH =66; menu.close(); }; }, setImgMax: function (img, imgW, imgH, tW, tH) { var tWidth = tW || win_width; var tHeight = tH || win_height; var coe = imgH / imgW; var coe2 = tHeight / tWidth; if (coe < coe2) { var imgWidth = tHeight / coe; img.css({ height: tHeight, width: imgWidth, left: -(imgWidth - tWidth) / 2, top: 0 }); } else { var imgHeight = tWidth * coe; img.css({ height: imgHeight, width: tWidth, left: 0, top: -(imgHeight - tHeight) / 2 }); }; }, setScroll: function (anchorCur) { if(jQuery(anchorCur).length>=1){ jQuery("html,body").animate({ scrollTop: jQuery(anchorCur).offset().top-atH}, 0); } }, setErmbox:function (obj, title) { obj.click(function () { var str = '
' + title + '
'; $("body").append(str); jQuery(".ermsblack").fadeIn(); jQuery(".ermSBox").animate({ marginTop: "-132" }, 400); $(".ermSBox .close").click(function () { $(".ermsblack").remove(); }); jQuery(".ermsblack").click(function () { $(".ermsblack").remove(); }); return false; }) }, openbox:function(htmlAddress){ $.ajax({ url: htmlAddress, dataType: "html", success: function (data) { if (data == "" || data == null) { return; } else { if(jQuery(".md-modal").length>=1){ jQuery('html').removeClass('md-show'); jQuery('.md-modal').remove(); }; $("body").append('
'); $('.md-modal .vertical-inner').append(data); setTimeout(function(){$("html").addClass("md-show");},50); jQuery('.form-box-close').bind('click',function(e){ jQuery('html').removeClass('md-show'); setTimeout(function(){jQuery('.md-modal').remove();},400); }); jQuery('.md-modal .vertical-inner').bind('click', function (e) { if ($(e.target).hasClass('vertical-inner')) { jQuery('html').removeClass('md-show'); setTimeout(function(){jQuery('.md-modal').remove();},400); } }); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { jQuery('html').removeClass('md-show'); setTimeout(function(){jQuery('.md-modal').remove();},400); } }); }, pbanner:function(){ if(jQuery('.pbanner').length>=1){ if (!isMobile) { jQuery('.pbanner').css("height", jQuery(".pbanner .load-img").height()); } else { jQuery('.pbanner').css("height", "auto"); } } }, splitWords:function(el){ var _test = el.html().split('
'); el.html(''); for (var i = 0; i < _test.length; i++) { el.append(''); _test[i] = _test[i].split(''); var _span = el.find('span'); for (var j = 0; j < _test[i].length; j++) { _span.eq(i).append(''); var _i = _span.eq(i).find('i'); _i.eq(j).text(_test[i][j]).css({ 'animation-delay': 100*j + 'ms', '-webkit-animation-delay': 100*j + 'ms' }); } } } }, nav={ init:function(){ jQuery(".nav li").hover(function () { if (jQuery(this).find(".subnav").length > 0) { $(this).children("a").addClass("hov"); $(this).find(".subnav").stop(false, false).animate({top:"100%","opacity":"show"},350); }; }, function () { $(this).children("a").removeClass("hov"); $(this).children(".subnav").stop(false, false).fadeOut(250,function(){$(this).css("top","70%");}); }); jQuery(".pageNav a,.nav .subnav a").click(function(e){ var $this=jQuery(this); var hash = $this.attr("href").split("#")[1]; if(hash && jQuery("#"+hash).length>=1){ e.preventDefault(); jQuery("html,body").animate({ scrollTop: jQuery("#"+hash).offset().top-atH},800,'easeInOutExpo'); if(isMobile){ jQuery(this).parent().fadeOut(); } } }); } }, menu={ init:function(){ $menuBtn.click(function(){ if (navItem == 0) { jQuery("html").addClass("menuOpen"); navItem = 1; }else{ jQuery("html").removeClass("menuOpen"); navItem = 0; } }); $(document).on("click", ".menuMoblie .nav-link", function (e) { var mnavcur = $(this); var mnavbox = $(this).parents("li"); if (mnavbox.find(".subnav").length > 0) { if (mnavbox.hasClass("cur")) { mnavbox.find(".subnav").stop(false, false).slideUp(); mnavbox.removeClass("cur"); } else { jQuery(".menuMoblie li").removeClass("cur"); jQuery(".subnav").stop(false, false).slideUp(); mnavbox.find(".subnav").stop(false, false).slideDown(); mnavbox.addClass("cur"); e.preventDefault(); } } }); $(document).on("click", ".menuMoblie a", function (e) { var $this=jQuery(this); var hash = $this.attr("href").split("#")[1]; if(hash && jQuery("#"+hash).length>=1){ e.preventDefault(); jQuery("html,body").animate({ scrollTop: jQuery("#"+hash).offset().top-atH},0); menu.close(); } }); $(".pusher-black").click(function () { if (navItem == 1 ) { menu.close(); }; }); }, close:function(){ jQuery("html").removeClass("menuOpen"); navItem = 0; } }, pbanner={ init:function(){ if(jQuery(".load-img").length>=1){ _PreLoadImg([ jQuery(".load-img").attr("src") ],function(){ setTimeout(function() { jQuery(".pbanner-c").addClass("inview"); }, 50); pageInit.pbanner(); }); jQuery(window).resize(function () { pageInit.pbanner(); }); } } }, pageNav={ init:function(){ jQuery(".page-nav-btn a").click(function(e){ var $this=jQuery(this); var hash = $this.attr("href").split("#")[1]; if(hash && jQuery("#"+hash).length>=1){ e.preventDefault(); jQuery("html,body").animate({ scrollTop: jQuery("#"+hash).offset().top-atH},800,'easeInOutExpo'); } }); var $sec_nav = $('.page-nav-box'); if ($sec_nav.length) { var $sec_n = $sec_nav.find('.page-nav-btn'), $current_item = $sec_nav.find('.active').parent(); if (isMobile && $current_item.length>=1) { $sec_n.stop().animate({ scrollLeft: $current_item.position().left }); } $(window).resize(function () { if (isMobile && $current_item.length>=1) { $sec_n.stop().animate({ scrollLeft: $current_item.offset().left + $sec_n.scrollLeft() }); } }); } } }; jQuery(window).resize(function () { pageInit.init(); }); pageInit.init(); $(document).ready(function () { nav.init(); menu.init(); pbanner.init(); pageNav.init(); pageInit.setErmbox(jQuery('.ermItem'), "扫描此二维码关注我们"); var userAgent = navigator.userAgent; var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器 var fIEVersion = -1; if (isIE) { var reIE = new RegExp("MSIE (\\d+\\.\\d+);"); reIE.test(userAgent); fIEVersion = parseFloat(RegExp["$1"]); } if (fIEVersion === -1 || fIEVersion > 9 && jQuery(".pbanner").length>=1) { $('.pbanner-C .zh').animatext({ speed: 120, effect: 'zoomIn', reverse: false }); } }); $(window).on('load',function(){ var hash = location.href.split("#")[1]; if (hash) { pageInit.setScroll("#" + hash); } }) jQuery(".vwrap .close,.vwrap .videobtg").click(function () { jQuery(".vwrap").hide(); $('#videobox').html(""); });