"use strict"; if ($(".banner video").length && !ismobile) { $(".banner video").each(function () { var slide = $(this).parents(".swiper-slide"); var index = slide.index(); $(this).attr("id", "video" + index); var bannervideo = videojs($(this).attr("id")); // bannervideo.play(); slide.data("video", bannervideo); bannervideo.on("ended", function () { gotoswiper(index + 1); }); }); } else { $(".banner video").remove(); } $(".header").addclass("fixed"); var homebannertimer = undefined; function observenextswiper(index) { var slides = $(".banner .swiper-container .swiper-slide"); if (slides.eq(index).find(".video").length === 0) { homebannertimer = settimeout(function () { gotoswiper(index + 1); // 图片轮播切换时间间隔 }, 6500); } else if (slides.eq(index).data("video")) { slides.eq(index).data("video").play(); } } function gotoswiper(index) { var slides = $(".banner .swiper-container .swiper-slide"); if (index > slides.length - 1) { index = 0; } cleartimeout(homebannertimer); slides.each(function () { if (slides.eq(index).data("video")) { slides.eq(index).data("video").pause(); } }); if (slides.eq(index).data("video")) { slides.eq(index).data("video").play(); } $(".banner .swiper-pagination .swiper-pagination-bullet").eq(index).addclass("swiper-pagination-bullet-active").siblings().removeclass("swiper-pagination-bullet-active"); (homeswiper.slideto || homeswiper.swipeto)(index); observenextswiper(index); } // 首页视频文字轮播 // var homebannertext = $('body[data-page="index"] .banner .banner-text'); // var homebannerinterval = parseint(homebannertext.attr("data-interval"), 10); // setinterval(changebannertext, homebannerinterval); // function changebannertext() { // var texts = homebannertext.find("> div"); // var active = homebannertext.find("> div.active"); // if (active.next().length) { // texts // .eq(active.index() + 1) // .addclass("active") // .siblings() // .removeclass("active"); // } else { // texts.eq(0).addclass("active").siblings().removeclass("active"); // } // } setbannervideo(); // 首页轮播 var homeswiper; if ($(".banner .swiper-container").length && !ismobile) { homeswiper = new (window.swiper3 || swiper)(".banner .swiper-container", { // pagination: ".banner .swiper-pagination", // loop: true, grabcursor: true, effect: "fade", // paginationclickable: true, // autoplay: 6500, speed: 800 }); $(".banner .swiper-container .swiper-slide").each(function (index) { var item = $(''); $(".banner .swiper-pagination").append(item); item.on("click", function () { gotoswiper($(this).index()); }); if (index === 0) { item.addclass("swiper-pagination-bullet-active"); } }); observenextswiper(0); } // 首页移动端轮播 if (window.swiper3) { $(".mobile-banner").css({ height: $(window).height() }); var swiper = new swiper3("#home-banner-swiper", { pagination: ".mobile-banner .swiper-pagination", paginationclickable: ".mobile-banner .swiper-pagination", spacebetween: 0, effect: "fade", autoplaydisableoninteraction: false, autoplay: 5000, speed: 600, loop: true }); } // 设置banner video $(window).on("scroll", setbannervideo); $(window).on("resize", setbannervideo); setbannervideo(); settimeout(function () { setbannervideo(); }); function setbannervideo() { var ww = $(window).width(); var hh = $(window).height(); var video = $('body[data-page="index"] .video'); var width = 1920; var height = 1080; // if (ww < 1200) { // ww = 1200; // } width = hh / height * width; if (width < ww) { width = ww; } // console.log(ww, width); if (/msie|like gecko/g.test(navigator.useragent)) { video.outerwidth(width); // video.find(".video-element").css({ // left: (width - ww) / 2 // }); } if (homeswiper) { homeswiper.resizefix && homeswiper.resizefix(); homeswiper.update && homeswiper.update(); } } // test var pageindex = 0; var prepageindex; var scrolling = false; var scrollingst; var parts = $(".parts .part"); if (!ismobile) { var debouncenextpage; var debounceprevpage; var prevy; var starty; var endy; (function () { var setpart = function setpart() { $(".parts").height($(window).height()); parts.height($(window).height()); var scale = $(window).width() / 2560; if (scale > 1) { scale = 1; } $(".part__box").css({ top: -$(window).height() * pageindex }); ifblack(); }; var ifblack = function ifblack() { var partcount = $(".parts .part").length; if ($(".parts .part").eq(pageindex).hasclass("header-is-white")) { $(".header, .mobile-header").addclass("white"); $(".part-pagination").removeclass("white"); } else { $(".header, .mobile-header").removeclass("white"); $(".part-pagination").addclass("white"); } if (pageindex === 0 || pageindex === partcount - 1) { $(".part-pagination").addclass("hide"); } else { $(".part-pagination").removeclass("hide"); } $(".part-pagination__count > div").eq(0).html("0" + (pageindex + 1)); $(".part-pagination__count > div").eq(2).html("0" + (partcount - 1)); if ($(".part-pagination__dot > div").length === 0) { for (var index = 0; index < partcount - 1; index++) { var dot = $("
"); $(".part-pagination__dot").append(dot); dot.on("click", function () { prepageindex = pageindex; pageindex = $(this).index(); jumppage(); }); } } $(".part-pagination__dot > div").eq(pageindex).addclass("active").siblings().removeclass("active"); }; var jumppage = function jumppage() { scrolling = true; cleartimeout(scrollingst); scrollingst = settimeout(function () { scrolling = false; }, 400); if (pageindex === 1 && prepageindex !== parts.length - 1) { $("*[count-up-to-p]").each(function () { $(this).html($(this).attr("count-up-to-p")); if ($(this).data("countup")) { $(this).data("countup").pauseresume(); } // settimeout(() => { // const to = parseint($(this).attr("count-up-to-p")); window.counterup["default"](this, { duration: 1500, delay: 50 }); // const countup = new countup(this, to, { // separator: "", // }); // $(this).data("countup", countup); // if (!countup.error) { // countup.start(); // } else { // console.error(countup.error); // } // }, 50); }); } if (pageindex === parts.length - 1) { $(".part__box").stop(true).animate({ top: -$(window).height() * (pageindex - 1) - $(".footer").outerheight() }, 400, function () { updateanimate(); }); } else { $(".part__box").stop(true).animate({ top: -$(window).height() * pageindex }, 400, function () { updateanimate(); }); } ifblack(); updatepageanimate(); }; var nextpage = function nextpage() { var isclick = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; if (pageindex < parts.length - 1 && (!scrolling || isclick)) { prepageindex = pageindex; pageindex++; jumppage(); } }; var prevpage = function prevpage() { var isclick = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; if (pageindex > 0 && (!scrolling || isclick)) { prepageindex = pageindex; pageindex--; jumppage(); } }; var updatepageanimate = function updatepageanimate() { if (pageindex === 0 || pageindex === parts.length - 1 || prepageindex === parts.length - 1) { settimeout(function () { updateanimate(); }, 50); return; } settimeout(function () { $(".part").eq(pageindex).find(".show-in, .fade-in, .blur-in, .scale-in, .fade-in-up, .fade-in-left, .fade-in-right, .fade-in-down").each(function () { $(this).removeclass("show").attr("data-faded", ""); }); }, 50); settimeout(function () { updateanimate(); }, 500); }; $(window).on("resize", function () { setpart(); }); setpart(); debouncenextpage = $.debounce(150, nextpage); debounceprevpage = $.debounce(150, prevpage); prevy = false; $(document).on("mousewheel", function (event) { var y = event.deltay; if ($(event.target).parents(".iscroll").length) return; if (y > 0) { if (prevy !== false && (ismac ? prevy < y : prevy <= y)) { debounceprevpage(); } } if (y < 0) { if (prevy !== false && (ismac ? prevy > y : prevy >= y)) { debouncenextpage(); } } prevy = y; }); $(document).on("keyup", function (e) { if (e.keycode === 38) { prevpage(true); } if (e.keycode === 40) { nextpage(true); } }); $(".parts").on("touchstart", function (e) { if ($(e.target).hasclass("prev") || $(e.target).hasclass("next") || $(e.target).attr("href")) {} else { e.preventdefault(); } starty = e.originalevent.touches[0].pagey; endy = starty; }); $(".parts").on("touchmove", function (e) { endy = e.originalevent.touches[0].pagey; }); $(".parts").on("touchend", function (e) { if (starty - endy > 30) { nextpage(); } if (starty - endy < -30) { prevpage(); } }); $(".controls .prev").click(function () { prevpage(true); }); $(".controls .next").click(function () { nextpage(true); }); if (ismobile) { $("body[data-page=index] .parts .part.p1 .next").hammer().on("tap", function () { nextpage(true); }); } else { $("body[data-page=index] .parts .part.p1 .next").click(function () { nextpage(true); }); } })(); } else { var checkcountupto = function checkcountupto() { $("*[count-up-to-p]").each(function () { if ($(this).offset().top - $(window).scrolltop() - $(window).height() > 0) return; if ($(this).data("countup")) { return; } $(this).html($(this).attr("count-up-to-p")); window.counterup["default"](this, { duration: 1500, delay: 50 }); $(this).data("countup", true); }); }; window.addeventlistener("touchend", checkcountupto); window.addeventlistener("scroll", checkcountupto); } var p4swiper = new (window.swiper3 || swiper)(".p4 .left .swiper-container", { pagination: ".p4 .left .swiper-pagination", loop: true, grabcursor: true, spacebetween: ismobile ? 50 : 70, paginationclickable: true, autoplay: 6500, speed: 800 });