// 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 }); }); // 璁剧疆瀵艰埅鑳屾櫙 function setNavBg() { var top = $(window).scrollTop(); var ww = $(window).width(); if ($('body[data-page="index"]').length === 0) { if (top > 50) { $(".header, .mobile-header").addClass("black"); updateBar(); setTimeout(function () { updateBar(); }, 350); } else { $(".header, .mobile-header").removeClass("black"); } } $(".header-space").height($(".header").height()); setTop(); $("*[data-width-full]").each(function () { $(this).width($(window).width() - (isMobile ? 48 : parseInt($(this).attr("data-width-full") || 0))); }); $("*[max-width]").each(function () { $(this).css({ "max-width": $(window).width() > 1200 ? $(window).width() : 1200 }); }); if ($(window).width() <= 320) { $("body").addClass("w320"); } else { $("body").removeClass("w320"); } $("*[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-size]").each(function () { if (isMobile) { return; } var height = parseInt($(this).attr("scale-size"), 10); var mw = $("body").width(); var unLimit = $(this).attr("scale-size-unlimit") === "true"; var lw = 1920; var scale = 1; if (mw > 1920) { mw = 1920; } if (ww > lw && !unLimit) { $(this).height(height); } else if (ww < mw) { scale = mw / lw; $(this).height(mw / lw * height); } else if (ww >= 1920) { scale = ww / mw; $(this).height(ww / mw * height); } else { scale = ww / lw; $(this).height(ww / lw * height); } $(this).find("*[scale]").css({ transform: "scale(" + scale + ")" }); }); updatePlatform(); setTimeout(function () { updateAnimate(); }); } 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"); }); // 鎼滅储鎸夐挳 $(".header>.inner .toolbar .search").click(function (e) { e.stopPropagation(); $(this).toggleClass("active"); $(".header .search-detail").toggleClass("show"); }); $("body").click(function () { $(".header .search-detail").removeClass("show"); }); $(".nav").hover(function () { $(".header .search-detail").removeClass("show"); }); $(".header .search-detail").click(function (e) { e.stopPropagation(); }); var hasActive = $(".nav > li.active").length > 0; if (!isMobile) { $(".header>.inner .nav>li").hover(function () { $(this).siblings(".expand").addClass("has-expand").removeClass("expand"); $(this).siblings(".active").addClass("has-active").removeClass("active"); $(".nav .bar").width($(this).outerWidth()).css({ left: $(this).offset().left - $(".nav").offset().left }); }, function () {}); $(".header>.inner .nav").hover(function () {}, function () { $(".header>.inner .nav>li.has-expand").removeClass("has-expand").addClass("expand"); $(".header>.inner .nav>li.has-active").removeClass("has-active").addClass("active"); updateBar(); }); } updateBar(); function updateBar() { if (hasActive) { $(".nav .bar").width($(".nav li.active").outerWidth()).css({ left: $(".nav li.active").offset().left - $(".nav").offset().left }); } else { $(".nav .bar").width(0); } } // 绉诲姩绔彍鍗 $(".mobile-side-menu li.sub > i, .mobile-side-menu li.sub > a").each(function () { var _this = this; $(_this).hammer().on("tap", function (e) { e.srcEvent.stopPropagation(); $(_this).parent().toggleClass("expand"); }); }); $(".mobile-header .menu").hammer().on("tap", function () { $(".mobile-side-menu").toggleClass("show"); overflowHiddenBody(); }); $(".mobile-side-menu .close").hammer().on("tap", function () { $(".mobile-side-menu").toggleClass("show"); overflowHiddenBody(); }); $(".mobile-side-menu .left").hammer().on("tap", function () { $(".mobile-side-menu").toggleClass("show"); overflowHiddenBody(); }); function overflowHiddenBody() { if ($(".mobile-side-menu").hasClass("show")) { $("body").css({ overflow: "hidden" }); } else { $("body").css({ overflow: "" }); } } function updateAnimate() { var selector = $(".fade-in-bottom-left, .show-in, .fade-in, .blur-in, .scale-in, .fade-in-up, .fade-in-left, .fade-in-left-long, .fade-in-right, .fade-in-right-long, .fade-in-down"); var wh = $(window).height(); var st = $(window).scrollTop(); var offset = 0; var space = 100; selector.each(function () { var _this3 = this; var oft = $(this).offset().top - wh - st; var elOuterHeight = $(this).outerHeight(); var delay = parseInt($(this).attr("data-fade-delay"), 10) || 0; var isDown = $(this).hasClass("animate-just-one") || $('body[data-page="index"]').length; if (oft < 0 && (oft > -wh - 10 || isDown) && $(this).attr("data-faded") !== "true") { $(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 { window.console && 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 { window.console && console.error(countUp.error); } } } }, $(this).attr("data-fade-immediately") === "true" ? delay : delay + offset); } else if (oft + wh < -elOuterHeight || oft + wh > wh) { $(this).removeClass("show"); $(this).attr("data-faded", false); } }); } 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 (!isMobile && !$('body[data-page="index"]').length) { var resize = function resize() { var ww = $(window).width(); if (ww < 1240) { ww = 1240; } $(".scale-height").each(function () { $(this).css({ height: ww / 1920 * parseInt($(this).attr("data-height"), 10) }); }); }; $(".scale-height").each(function () { $(this).attr("data-height", $(this).height()); }); $(window).on("resize", resize); resize(); } $(".tabs").each(function () { var _this = this; setTabContent(); setTabActive(); $(_this).find(".tab-content").on("scroll", setTabContent); $(_this).find(".tab-arrow.left").hammer().on("tap", function () { $(_this).find(".tab-content").stop(true).animate({ scrollLeft: $(_this).find(".tab-content").scrollLeft() - $(_this).find(".tab").eq(0).outerWidth() }); }); $(_this).find(".tab-arrow.right").hammer().on("tap", function () { $(_this).find(".tab-content").stop(true).animate({ scrollLeft: $(_this).find(".tab-content").scrollLeft() + $(_this).find(".tab").eq(0).outerWidth() }); }); $(_this).find(".tab").click(function () { $(this).addClass("active").siblings().removeClass("active"); $(_this).next(".t4").find(".tab-content-item").eq($(this).index()).show().siblings().hide(); setTabActive(); }); function setTabActive() { var active = $(_this).find(".tab.active"); if (!active.length) { return; } $(_this).next(".t4").find(".tab-content-item").eq(active.index()).show().siblings().hide(); var scroll = $(_this).find(".tab-content"); var scrollWidth = scroll.get(0).scrollWidth; var width = scroll.outerWidth(); scroll.stop(true).animate({ scrollLeft: active.offset().left - scroll.offset().left + active.outerWidth() / 2 + scroll.scrollLeft() - width / 2 }); } function setTabContent() { var arrow = $(_this).find(".tab-arrow"); var scroll = $(_this).find(".tab-content"); if (!arrow.length) { return; } var scrollLeft = scroll.scrollLeft(); var scrollWidth = scroll.get(0).scrollWidth; var width = scroll.outerWidth(); if (scrollWidth <= width) { arrow.eq(0).hide(); arrow.eq(1).hide(); } else if (scrollLeft === 0) { arrow.eq(0).hide(); arrow.eq(1).show(); } else if (scrollLeft >= scrollWidth - width) { arrow.eq(0).show(); arrow.eq(1).hide(); } else { arrow.eq(0).show(); arrow.eq(1).show(); } } }); // 鏌ョ湅澶у浘 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")); $("#lightgallery-box").remove(); $("body").append(template.render(galleryTemplate, { list: data })); $("#lightgallery-box").lightGallery({ share: false }); $("#lightgallery-box").find("li").trigger("click"); // blueimp.Gallery(data, { // container: '#blueimp-gallery', // carousel: true, // hidePageScrollbars: true, // disableScroll: true // }); }); }); } if (isMobile) { $(".index-part-3 .contents .content .table.table1").each(function () { var _this4 = this; new Hammer(this, {}).on("tap", function (e) { $(_this4).parent().addClass("active").siblings().removeClass("active"); }); }); $(".index-part-3 .contents .content .detail .close").each(function () { var _this5 = this; new Hammer(this, {}).on("tap", function (e) { $(_this5).parent().parent().removeClass("active"); }); }); } else { $(".index-part-3 .contents .content .table.table1").on("click", function () { $(this).parent().addClass("active").siblings().removeClass("active"); }); $(".index-part-3 .contents .content .detail .close").on("click", function () { $(this).parent().parent().removeClass("active"); }); } // 缁戝畾瑙嗛鎾斁寮瑰嚭鎾斁浜嬩欢 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, $(_this2).attr("data-video-url"))); $("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(); } // business-tab //$('.mini-tabs > div').bind('click', function () { // $(this).addClass('active').siblings().removeClass('active'); // $('.mini-contents > div').eq($(this).index()).show().siblings().hide(); //}); // PC绔悳绱 $(".handle-header-search").on("click", function () { $(".search-modal").addClass("show"); $("body, html").css("overflow", "hidden"); }); $(".search-modal .close").on("click", function () { $(".search-modal").removeClass("show"); $("body, html").css("overflow", ""); }); 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-form input").click(function (e) { e.stopPropagation(); }); $(".search-form input").focus(function () { $(this).addClass("focus"); $(this).parent().addClass("focus"); }).blur(function () { $(this).removeClass("focus"); $(this).parent().removeClass("focus"); }); }