// 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妫€娴嬩竴涓媗ocation.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); //鍒濆鍖杊ammer fn $.fn.hammer = function (opt) { if (/msie/g.test(window.navigator.userAgent.toLowerCase())) { var _this = this; return { on: function on(method, callback) { $(_this).on("click", callback); } }; } else { if (!this.length) { return { on: function on() {} }; } return new Hammer(this.get(0), opt || {}); } }; // 淇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(); // 璁剧疆瀵艰埅鑳屾櫙 function setNavBg() { var top = $(window).scrollTop(); var ww = $(window).width(); var wh = $(window).height(); if (top < 0) { return; } if (top > document.body.scrollHeight - wh) { return; } if (!isMobile) { $("*[data-full-height]").outerHeight($(window).height()); } if (top > 50) { $(".header, .mobile-header").addClass("black"); setHeaderUl(); } else { $(".header, .mobile-header").removeClass("black"); var w = $(window).width() - 80; if (w > 1600) { w = 1600; } } $(".header-space").height($(".header").height()); setTop(); if ($(window).width() <= 320) { $("body").addClass("w320"); } else { $("body").removeClass("w320"); } if (!isMobile) { $("*[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.85; } else { scale = 1; } } if (ww < 1366) { if (height >= 30) { scale = 0.70; } else { scale = 0.85; } } if (ww < 1280) { 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 (height >= 30) { scale = 0.85; } else { scale = 1; } } 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"); }); // 绉诲姩绔彍鍗 $(".mobile-side-menu li.sub > i, .mobile-side-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-side-menu").toggleClass("show"); }); $(".mobile-side-menu .close").hammer().on("tap", function () { $(".mobile-side-menu").toggleClass("show"); }); $(".mobile-side-menu .left").hammer().on("tap", function () { $(".mobile-side-menu").toggleClass("show"); }); function updateAnimate() { var selector = $(".show-in, .fade-in, .scale-in, .fade-in-up, .fade-in-left, .fade-in-left-long, .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 _this3 = this; var oft = $(this).offset().top - wh - st; var delay = parseInt($(this).attr("data-fade-delay"), 10) || 0; if (oft < 0 && !$(this).hasClass("show")) { $(this).attr("data-faded", true); if (oft > -wh) { offset += space; } setTimeout(function () { $(_this3).addClass("show"); if (!$('body[data-page="index"]').length) { if ($(_this3).attr("count-up-to")) { var to = parseInt($(_this3).attr("count-up-to")); var countUp = new CountUp(_this3, to, { separator: "" }); if (!countUp.error) { countUp.start(); } else { console.error(countUp.error); } } if ($(_this3).attr("count-up-to-p")) { var to = parseInt($(_this3).attr("count-up-to-p")); var countUp = new CountUp(_this3, 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-side-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(); } } if ($(".second-banner__nav").length) { var setBarArrow = function setBarArrow(e) { if ($(".second-banner__nav .inner ul").scrollTop() > 0) { $(".second-banner__nav .inner ul").scrollTop(0); } if (this.scrollWidth <= $(this).outerWidth()) { $(".second-banner__nav .mobile-arrow.right").addClass("hide"); $(".second-banner__nav .mobile-arrow.left").addClass("hide"); } else if ($(this).scrollLeft() <= 10) { $(".second-banner__nav .mobile-arrow.right").removeClass("hide"); $(".second-banner__nav .mobile-arrow.left").addClass("hide"); } else if ($(this).scrollLeft() >= this.scrollWidth - $(this).outerWidth() - 10) { $(".second-banner__nav .mobile-arrow.right").addClass("hide"); $(".second-banner__nav .mobile-arrow.left").removeClass("hide"); } else { $(".second-banner__nav .mobile-arrow.right").removeClass("hide"); $(".second-banner__nav .mobile-arrow.left").removeClass("hide"); } }; $(".second-banner__nav .inner ul").bind("scroll", setBarArrow); // console.log($(".second-banner__nav .inner ul li.active").offset().left, $(window).width() / 2, $(".second-banner__nav .inner ul li.active").outerWidth() / 2); // console.log($(".second-banner__nav .inner ul li.active").offset().left + $(".second-banner__nav .inner ul").scrollLeft() - $(window).width() / 2 + $(".second-banner__nav .inner ul li.active").outerWidth() / 2); if ($(".second-banner__nav .inner ul li.active").length) { $(".second-banner__nav .inner ul").scrollLeft($(".second-banner__nav .inner ul li.active").offset().left + $(".second-banner__nav .inner ul").scrollLeft() - $(window).width() / 2 + $(".second-banner__nav .inner ul li.active").outerWidth() / 2); } setBarArrow.call($(".second-banner__nav .inner ul").get(0)); } $(".header .search, .search-modal .close").click(function () { $(".search-modal").toggleClass("show"); }); if (!isMobile) { $(".select").each(function () { var el = $('
'); var val = $('
'); $(this).find("select option").each(function (i) { var item = $("
" + $(this).text() + "
"); if (i === 0) { item.hide(); val.text(item.text()); } item.click(function () { $(this).parent().parent().find("select").val($(this).attr("data-value")); val.text(item.text()); item.hide().siblings().show(); }); el.append(item); }); $(this).append(val); $(this).append(el); }); $(".select .select-value").click(function (e) { e.stopPropagation(); $(this).parent().toggleClass("focus"); $(this).parent().parent().toggleClass("focus"); }); $("body").click(function () { $(".select").removeClass("focus"); $(".select").parent().removeClass("focus"); }); $(".search-modal input").click(function (e) { e.stopPropagation(); }); $(".search-modal input").focus(function () { $(this).addClass("focus"); $(this).parent().addClass("focus"); }).blur(function () { $(this).removeClass("focus"); $(this).parent().removeClass("focus"); }); } // 缁戝畾瑙嗛鎾斁寮瑰嚭鎾斁浜嬩欢 var videoArray = []; var videoJsKey = "data-videojs-id"; var videoTpl = '
' + '
' + '" + '
' + "
" + "
"; var videoTencentTpl = '
' + '
' + "{{tencent}}" + '
' + "
" + "
"; bindVideoDialog(); function bindVideoDialog() { $("*[data-video-url]").each(function () { if ($(this).attr("rendered")) return; $(this).attr("rendered", true); $(this).click(function () { var _this2 = this; var isFull = /ipad|iphone|ipod/g.test(navigator.userAgent.toLocaleLowerCase()); var type = $(this).attr("data-video-type"); var id = parseInt($(this).attr(videoJsKey)); if (type === "link") { window.open($(this).attr("data-video-url")); return; } if (type === "tencent") { var _ret = (function () { var video = $(videoTencentTpl.replace(/{{tencent}}/g, "")); $("body").append(video); video.find(".close").on("click", function () { $(this).parents(".video-dialog").remove(); }); setTimeout(function () { video.addClass("show"); }, 300); return { v: undefined }; })(); if (typeof _ret === "object") return _ret.v; } if (!isNaN(id)) { videoArray[id].video.play(); if (!isFull) { videoArray[id].container.addClass("show"); } return; } var url = $(this).attr("data-video-url"); var vid = "video_" + +new Date(); var video = $(videoTpl); video.find("video").attr("id", vid); video.find("source").attr("src", url); $("body").append(video); video.find(".close").on("click", hideVideoDialog); videoArray.push({ container: video, video: videojs(vid) }); video.attr("video-index", videoArray.length - 1); $(this).attr(videoJsKey, videoArray.length - 1); setTimeout(function () { if (!isFull) { video.addClass("show"); videoArray[parseInt(video.attr("video-index"), 10)].video.play(); } }, 300); if (isFull) { videoArray[parseInt(video.attr("video-index"), 10)].video.play(); } }); }); } function hideVideoDialog() { $(this).parents(".video-dialog").removeClass("show"); videoArray[parseInt($(this).parents(".video-dialog").attr("video-index"), 10)].video.pause(); } // 鏌ョ湅澶у浘 bindGallery(); var galleryTemplate = "\n"; function bindGallery() { $("*[data-gallery]").each(function () { if ($(this).attr("data-bind") === "true") { return; } $(this).attr("data-bind", true).bind("click", function () { var data = eval($(this).attr("data-gallery")); var index = parseInt($(this).attr("data-gallery-index"), 10) || 0; $("#lightgallery-box").remove(); $("body").append(template.render(galleryTemplate, { list: data })); $("#lightgallery-box").lightGallery({ share: false }); $("#lightgallery-box").find("li").eq(index).trigger("click"); // blueimp.Gallery(data, { // container: '#blueimp-gallery', // carousel: true, // hidePageScrollbars: true, // disableScroll: true // }); }); }); } //浼佷笟鏂囧寲 $('*[data-full]').css('height', $(window).height()); $('*[data-accordion]').each(function () { $(this).find('> *').hover(function () { $(this).addClass('show').removeClass('hide').siblings().addClass('hide').removeClass('show'); }, function () { $(this).removeClass('hide').removeClass('show').siblings().removeClass('hide').removeClass('show'); }); });