// 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; } } } window.console && 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) { if (prevscrolltop > top || !$(".header.white").length) { $(".header.up-down-show").addclass("show"); } else { $(".header.up-down-show").removeclass("show"); } } prevscrolltop = top; // 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) { // const offset = ($(".second-banner").outerheight() || 100) - 100; var offset = 10; 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"); settimeout(function () { if ($(".header .nav").data("bar") && $(".header .nav").data("bar").updateactivebar) { $(".header .nav").data("bar").updateactivebar(); } }, 350); } } $(".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 () { $(".search-modal").addclass("show"); $("body, html").css("overflow", "hidden"); }); $(".search-modal .close").on("click", function () { $(".search-modal").removeclass("show"); $("body, html").css("overflow", ""); }); $(".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").on("click", function () { $(".mobile-menu").addclass("show"); $("body, html").css("overflow", "hidden"); }); $(".mobile-menu .mobile-menu__header, .mobile-menu .mobile-menu__left").on("click", function () { $(".mobile-menu").removeclass("show"); $("body, html").css("overflow", ""); }); 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 { window.console && console.error(countup.error); } } } if ($('body[data-page="aboutus"]').length > 0) { if ($(_this4).attr("count-up-to-p")) { $(_this4).html($(_this4).attr("count-up-to-p")); if ($(_this4).data("countup")) { $(_this4).data("countup").pauseresume(); } window.counterup["default"](_this4, { duration: 1500, delay: 50 }); } } }, $(this).attr("data-fade-immediately") === "true" ? delay : delay + offset); } }); } function updateplatform() { if (ismobile) { $("body").addclass("mobile").removeclass("pc"); } else { $("body").addclass("pc").removeclass("mobile"); } } $(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 = '
' + '
' + '" + "
" + '
' + "
"; 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 // }); }); }); } // 红色状态条计算,动画 if (!ismobile) { var activebars = $(".has-active-bar"); activebars.each(function () { var _this5 = this; var bar = $(''); var children = $(this).find("> *"); var firstchild = children.eq(0); var activeindex = $(this).find("> .active").index(); var timer = undefined; var updateactivebar = function updateactivebar() { activeindex = $(_this5).find("> .active").index(); setactive(activeindex); }; $(this).data("bar", { updateactivebar: updateactivebar }); var setactive = function setactive(index) { var left = 0; var top = 0; for (var _i = 0; _i <= index; _i++) { left += children.eq(_i).outerwidth(); if (_i === index) { top = children.eq(_i).outerheight() - bar.outerheight(); left -= children.eq(_i).outerwidth() * 0.5; left -= bar.outerwidth() * 0.5; } } if (index < 0) { bar.hide(); } else { bar.show(); } bar.css({ transform: "translatex(" + left + "px)", top: top }); }; children.css("position", "relative"); firstchild.append(bar); setactive(activeindex); children.hover(function () { cleartimeout(timer); setactive($(this).index()); }, function () { timer = settimeout(function () { setactive(activeindex); }, 150); }); }); } 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"); }); } if ($(".second-nav").length) { var setbararrow = function setbararrow(e) { if ($(".second-nav .inner ul").scrolltop() > 0) { $(".second-nav .inner ul").scrolltop(0); } if (this.scrollwidth <= $(this).outerwidth()) { $(".second-nav .mobile-arrow.right").addclass("hide"); $(".second-nav .mobile-arrow.left").addclass("hide"); } else if ($(this).scrollleft() <= 10) { $(".second-nav .mobile-arrow.right").removeclass("hide"); $(".second-nav .mobile-arrow.left").addclass("hide"); } else if ($(this).scrollleft() >= this.scrollwidth - $(this).outerwidth() - 10) { $(".second-nav .mobile-arrow.right").addclass("hide"); $(".second-nav .mobile-arrow.left").removeclass("hide"); } else { $(".second-nav .mobile-arrow.right").removeclass("hide"); $(".second-nav .mobile-arrow.left").removeclass("hide"); } }; $(".second-nav .inner ul").bind("scroll", setbararrow); if ($(".second-nav .inner ul li.active").length) { $(".second-nav .inner ul").scrollleft($(".second-nav .inner ul li.active").offset().left + $(".second-nav .inner ul").scrollleft() - $(window).width() / 2 + $(".second-nav .inner ul li.active").outerwidth() / 2); } setbararrow.call($(".second-nav .inner ul").get(0)); }