// video.js // videojs.options.flash = __uri('../node_modules/videojs-swf-saints/dist/video-js.swf'); // videojs.options.techOrder = ['flash']; "use strict"; var hasAni = false, animationstring = "animation", keyframeprefix = "", domPrefixes = "Webkit Moz O ms Khtml".split(" "), pfx = "", elm = document.createElement("div"); if (elm.style.animationName !== undefined) { hasAni = true; } if (hasAni === false) { for (var i = 0; i < domPrefixes.length; i++) { if (elm.style[domPrefixes[i] + "AnimationName"] !== undefined) { pfx = domPrefixes[i]; animationstring = pfx + "Animation"; keyframeprefix = "-" + pfx.toLowerCase() + "-"; hasAni = true; break; } } } console.log("hasAni", hasAni); if (!hasAni) { $("body").addClass("no-animation"); } var isMobile = /android|iphone|ipad|ipod/g.test(window.navigator.userAgent.toLowerCase()) || $(window).width() <= 1024; var isMac = /mac os x/g.test(window.navigator.userAgent.toLowerCase()); // 获取url传的参数,并赋值到searchParams $(function () { var search = window.location.search; var params = {}; if (search && /\?/g.test(search)) { search = search.split("?")[1]; } if (/&/g.test(search)) { search = search.split("&"); } else { search = [search]; } search.forEach(function (v, i, f) { if (/=/g.test(v)) { params[v.split("=")[0]] = v.split("=")[1]; } else { if (v) { params[v] = null; } } }); window.searchParams = params; }); // 获取url传的参数,并赋值到hashParams $(function () { function getHash() { var search = window.location.hash; var params = {}; if (search && /\#/g.test(search)) { search = search.split("#")[1]; } if (/&/g.test(search)) { search = search.split("&"); } else { search = [search]; } search.forEach(function (v, i, f) { if (/=/g.test(v)) { params[v.split("=")[0]] = v.split("=")[1]; } else { if (v) { params[v] = null; } } }); window.hashParams = params; return params; } getHash(); window.getHash = getHash; }); // hash 事件兼容 (function (window) { // 如果浏览器原生支持该事件,则退出 if ("onhashchange" in window.document.body) { return; } var location = window.location, oldURL = location.href, oldHash = location.hash; // 每隔100ms检测一下location.hash是否发生变化 setInterval(function () { var newURL = location.href, newHash = location.hash; // 如果hash发生了变化,且绑定了处理函数... if (newHash != oldHash && typeof window.onhashchange === "function") { // execute the handler window.onhashchange({ type: "hashchange", oldURL: oldURL, newURL: newURL }); oldURL = newURL; oldHash = newHash; } }, 100); })(window); //初始化hammer fn $.fn.hammer = function (opt) { var _this3 = this; var _this = this; if (/msie/g.test(window.navigator.userAgent.toLowerCase())) { return { on: function on(method, callback) { $(_this).on("click", callback); } }; } else { if (!this.length) { return { on: function on() {} }; } return { on: function on(type, fn) { if (_this.each) { _this.each(function () { new Hammer($(this).get(0), opt || {}).on(type, fn); }); } else { new Hammer($(_this3).get(0), opt || {}).on(type, fn); } } }; } }; // 修复active伪类无效 $("body").on("touchstart", function () {}); // fastclick $(function () { FastClick.attach(document.body); }); $("#toTop").hammer().on("tap", function () { $("html, body").animate({ scrollTop: 0 }); }); // 绑定header $(".header .nav > li").hover(function () { setHeaderUl(); }); function setHeaderUl() { var uls = $(".header .nav > li > ul"); uls.each(function () { var ul = $(this); var liw = $(this).parent().outerWidth(); var lis = $(this).find("li a"); var max = 0; lis.each(function () { if (max < $(this).outerWidth()) { max = $(this).outerWidth(); } }); if (max < liw) { max = liw; } ul.outerWidth(max); ul.css({ left: (liw - max) * 0.5 }); }); } setHeaderUl(); // 设置导航背景 var prevScrollTop = 0; function setNavBg() { var top = $(window).scrollTop(); var ww = $(window).width(); var wh = $(window).height(); if (prevScrollTop && !secondNavLock) { if (prevScrollTop > top || !$(".header.white").length) { $(".header.up-down-show").addClass("show"); } else { $(".header.up-down-show").removeClass("show"); } } prevScrollTop = top; updateSecondNav(); setSecondBannerVideo(); // if (top < 0) { // return; // } // if (top > document.body.scrollHeight - wh) { // return; // } if (!isMobile) { $("*[data-full-height]").outerHeight($(window).height()); } if (!$('body.pc[data-page="index"]').length) { var offset = ($(".second-banner").outerHeight() || 100) - 50; if (top > offset) { $(".header, .mobile-header").addClass("white"); $(".header, .mobile-header").addClass("bg-white"); setHeaderUl(); } else { $(".header, .mobile-header").removeClass("white"); $(".header, .mobile-header").removeClass("bg-white"); } } $(".header-space").height($(".header").height()); setTop(); if ($(window).width() <= 320) { $("body").addClass("w320"); } else { $("body").removeClass("w320"); } if (!isMobile) { $("*[scale-padding-top]").each(function () { var height = parseInt($(this).attr("scale-padding-top"), 10); var mw = $("body").width(); var unLimit = $(this).attr("scale-padding-top-unlimit") === "true"; var lw = 1920; if (mw > 1920) { mw = 1920; } if (ww > lw && !unLimit) { $(this).css("padding-top", height); } else if (ww < mw) { $(this).css("padding-top", mw / lw * height); } else if (ww >= 1920) { $(this).css("padding-top", ww / mw * height); } else { $(this).css("padding-top", ww / lw * height); } }); $("*[scale-padding]").each(function () { var height = parseInt($(this).attr("scale-padding"), 10); var mw = $("body").width(); var unLimit = $(this).attr("scale-padding-unlimit") === "true"; var lw = 1920; if (mw > 1920) { mw = 1920; } if (ww > lw && !unLimit) { $(this).css("padding", height); } else if (ww < mw) { $(this).css("padding", mw / lw * height); } else if (ww >= 1920) { $(this).css("padding", ww / mw * height); } else { $(this).css("padding", ww / lw * height); } }); $("*[scale-size]").each(function () { var height = parseInt($(this).attr("scale-size"), 10); var mw = $("body").width(); var unLimit = $(this).attr("scale-size-unlimit") === "true"; var lw = 1920; if (mw > 1920) { mw = 1920; } if (ww > lw && !unLimit) { $(this).outerHeight(height); } else if (ww < mw) { $(this).outerHeight(mw / lw * height); } else if (ww >= 1920) { $(this).outerHeight(ww / mw * height); } else { $(this).outerHeight(ww / lw * height); } }); $("*[scale-width]").each(function () { var height = parseInt($(this).attr("scale-width"), 10); var mw = $("body").width(); var unLimit = $(this).attr("scale-width-unlimit") === "true"; var lw = 1920; if (mw > 1920) { mw = 1920; } if (ww > lw && !unLimit) { $(this).css("width", height); } else if (ww < mw) { $(this).css("width", mw / lw * height); } else if (ww >= 1920) { $(this).css("width", ww / mw * height); } else { $(this).css("width", ww / lw * height); } }); $("*[scale-font-size]").each(function () { var height = parseInt($(this).attr("scale-font-size"), 10); var mw = $("body").width(); var unLimit = $(this).attr("scale-font-size-unlimit") === "true"; var lw = 1920; var scale = 1; if (ww < 1680) { if (height >= 30) { scale = 0.75; } else { scale = 0.85; } } if (ww < 1366) { if (height >= 30) { scale = 0.6; } else { scale = 0.7; } } if (mw > 1920) { mw = 1920; } if (ww >= lw && !unLimit) { $(this).css("fontSize", height); } else if (ww < mw) { // $(this).css("fontSize", (mw / lw) * height); $(this).css("fontSize", scale * height); } else if (ww >= 1920) { $(this).css("fontSize", ww / mw * height); } else { // $(this).css("fontSize", (ww / lw) * height); $(this).css("fontSize", scale * height); } }); $("*[scale-line-height]").each(function () { var height = parseInt($(this).attr("scale-line-height"), 10); var mw = $("body").width(); var unLimit = $(this).attr("scale-line-height-unlimit") === "true"; var lw = 1920; var scale = 1; if (ww < 1680) {} if (ww < 1366) { if (height >= 30) { scale = 0.75; } else { scale = 0.85; } } if (ww < 1280) { if (height >= 30) { scale = 0.7; } else { scale = 0.8; } } if (mw > 1920) { mw = 1920; } if (ww >= lw && !unLimit) { $(this).css("lineHeight", height + "px"); } else if (ww < mw) { // $(this).css("lineHeight", (mw / lw) * height + "px"); $(this).css("lineHeight", scale * height + "px"); } else if (ww >= 1920) { $(this).css("lineHeight", ww / mw * height + "px"); } else { // $(this).css("lineHeight", (ww / lw) * height + "px"); $(this).css("lineHeight", scale * height + "px"); } }); $("*[scale-scale]").each(function () { var height = parseInt($(this).attr("scale-scale"), 10) || 1; var mw = $("body").width(); var unLimit = $(this).attr("scale-scale-unlimit") === "true"; var lw = 1920; var convertScale = function convertScale(num) { var res = parseFloat(parseFloat(num).toFixed(1)); if (res * 10 % 2 === 1) { res += 0.1; } return res; }; if (mw > 1920) { mw = 1920; } if (ww > lw && !unLimit) { $(this).css("transform", "scale(" + height + ")"); } else if (ww < mw) { $(this).css("transform", "scale(" + convertScale(mw / lw * height) + ")"); } else if (ww >= 1920) { $(this).css("transform", "scale(" + convertScale(ww / mw * height) + ")"); } else { $(this).css("transform", "scale(" + convertScale(ww / lw * height) + ")"); } }); } updatePlatform(); updateAnimate(); // setTimeout(() => { // updateAnimate(); // }, 10); } function setTop() { var top = $("#toTop"); var scrollTop = $("body").scrollTop() || $("html").scrollTop(); var wh = $(window).height() * 0.5; if (scrollTop > wh) { top.addClass("show"); } else { top.removeClass("show"); } } $(window).on("scroll", setNavBg); $(window).on("resize", setNavBg); setNavBg(); $(document).ready(function () { setNavBg(); $("body").addClass("loaded"); }); // PC端搜索 $(".handle-header-search").on("click", function () { $(".header-search").toggleClass("show"); }); // 移动端菜单 $(".handle-search").hammer().on("tap", function () { $(".mobile-search").toggleClass("show"); }); $(" .handle-menu").hammer().on("tap", function () { $(".mobile-menu").toggleClass("show"); }); $(".mobile-menu li.sub > i, .mobile-menu li.sub > a").each(function () { var _this = this; $(_this).on("touchend", function (e) { e.stopPropagation(); $(_this).parent().toggleClass("expand"); }); }); $(".mobile-header .menu").hammer().on("tap", function () { $(".mobile-menu").toggleClass("show"); }); $(".mobile-menu .left").hammer().on("tap", function () { $(".mobile-menu").toggleClass("show"); }); function updateAnimate() { var selector = $(".show-in, .fade-in, .scale-in, .fade-in-up, .fade-in-left, .fade-in-right, .fade-in-down, *[count-up-to], *[count-up-to-p]"); var wh = $(window).height(); var st = $(window).scrollTop(); var offset = 0; var space = 150; selector.each(function () { var _this4 = this; var oft = $(this).offset().top - wh - st; var delay = parseInt($(this).attr("data-fade-delay"), 10) || 50; if (oft < 0 && !$(this).hasClass("show")) { $(this).attr("data-faded", true); if (oft > -wh) { offset += space; } setTimeout(function () { $(_this4).addClass("show"); window.animateShowCallback && animateShowCallback(_this4); if (!$('body[data-page="index"]').length) { if ($(_this4).attr("count-up-to")) { var to = parseInt($(_this4).attr("count-up-to")); var countUp = new CountUp(_this4, to, { separator: "" }); if (!countUp.error) { countUp.start(); } else { console.error(countUp.error); } } if ($(_this4).attr("count-up-to-p")) { var to = parseInt($(_this4).attr("count-up-to-p")); var countUp = new CountUp(_this4, to, { separator: "" }); if (!countUp.error) { countUp.start(); } else { console.error(countUp.error); } } } }, $(this).attr("data-fade-immediately") === "true" ? delay : delay + offset); } }); } function updatePlatform() { if (isMobile) { $("body").addClass("mobile").removeClass("pc"); } else { $("body").addClass("pc").removeClass("mobile"); } } if (isMobile) { setTimeout(function () { $(".mobile-menu").show(); }, 100); } $(window).on("resize", ifReload); function ifReload() { var _isMobile = /android|iphone|ipad|ipod/g.test(window.navigator.userAgent.toLowerCase()) || $(window).width() <= 1024; if (isMobile !== _isMobile) { window.location.reload(); } } // 绑定视频播放弹出播放事件 var videoArray = []; var videoJsKey = "data-videojs-id"; var videoTpl = '