$(function () { var videos1 = document.querySelectorAll('.mbanner .swiper-slide video'); var banner = new Swiper(".mbanner .swiper", { slidesPerView: 1, lazy: true, speed: 1000, autoplay: { disableOnInteraction: false, delay: 5000, }, pagination: { el: ".mbanner .swiper-pagination", clickable: true, }, navigation: { nextEl: '.mbanner .swiper-button-next', prevEl: '.mbanner .swiper-button-prev', }, effect: 'fade', on: { slideChangeTransitionEnd: function (swiper) { for (var i = 0; i < videos1.length; i++) { if (videos1[i].src.indexOf("mp4")!=-1) { if (i != this.realIndex) { videos1[i].pause() } else { videos1[i].play() } } } } } }); function initVideoControl() { var videoArray = Array.prototype.slice.call(videos1); for (var i = 0; i < videoArray.length; i++) { var video = videoArray[i]; if (video.addEventListener) { video.addEventListener('play', function () { banner.autoplay.stop(); banner.params.autoplay.delay = 0; }); } else { video.attachEvent('onplay', function () { banner.autoplay.stop(); banner.params.autoplay.delay = 0; }); } if (video.addEventListener) { video.addEventListener('ended', function () { banner.autoplay.start(); banner.params.autoplay.delay = 3000; }); } else { video.attachEvent('onended', function () { banner.autoplay.start(); banner.params.autoplay.delay = 3000; }); } } } initVideoControl(); $(".mbanner .news .news_video").each(function () { if ($(this).find("video").attr("src") == "") { $(this).hide(); $(this).siblings(".news_imgs").show(); } else { $(this).show(); $(this).siblings(".news_imgs").hide(); } }) var obt1 = new Vivus('numbg', { type: 'delayed', duration: 50 }); var swiper11 = new Swiper(".post-11 .swiper1", { slidesPerView: 1, lazy: true, speed: 1000, autoplay: { delay: 5000, }, navigation: { nextEl: '.post-11 .swiper-button-next', prevEl: '.post-11 .swiper-button-prev', }, pagination: { el: '.post-11 .swiper-pagination', clickable: true, renderBullet: function (index, className) { return '0' + (index + 1) + ''; }, }, on: { init: function (swiper) { document.querySelector(".scrollBall").classList.add("run") }, slideChangeTransitionStart: function () { var index2 = this.activeIndex; document.querySelector(".dot_box .num").innerText = "0" + (index2 + 1) document.querySelector(".post-11 .con1").style.setProperty("--nowIndex", index2); obt1.reset().play(); document.querySelector(".scrollBall").classList.remove("run") setTimeout(function () { document.querySelector(".scrollBall").classList.add("run") }) }, }, }); var swiper12 = new Swiper(".post-11 .swiper2", { slidesPerView: 1, lazy: true, speed: 1000, effect: 'fade', }); swiper11.controller.control = swiper12; //Swiper1控制Swiper2,需要在Swiper2初始化后 swiper12.controller.control = swiper11; $(".back_bb").click(function () { $("html, body").animate({ scrollTop: $(".body_m").offset().top, }, 600); }); new Swiper(".post-21 .swiper", { slidesPerView: 1, lazy: true, speed: 1000, loop: true, autoplay: { disableOnInteraction: false, delay: 5000, }, navigation: { nextEl: '.post-21 .swiper-button-next', prevEl: '.post-21 .swiper-button-prev', }, }); new Swiper(".post-41 .swiper", { slidesPerView: 1, lazy: true, speed: 1000, spaceBetween: "2.68%", autoplay: { disableOnInteraction: false, delay: 5000, }, scrollbar: { el: '.post-41 .swiper-scrollbar', draggable: true, }, navigation: { nextEl: '.post-41 .swiper-button-next', prevEl: '.post-41 .swiper-button-prev', }, breakpoints: { 320: { //当屏幕宽度大于等于320 slidesPerView: 1, }, 479: { //当屏幕宽度大于等于768 slidesPerView: 2, }, 767: { //当屏幕宽度大于等于768 slidesPerView: 3, }, 999: { //当屏幕宽4, slidesPerView: 4, } } }); new Swiper(".post-61 .swiper", { slidesPerView: 4, lazy: true, speed: 1000, spaceBetween: "2.68%", autoplay: { disableOnInteraction: false, delay: 5000, }, navigation: { nextEl: '.post-61 .swiper-button-next', prevEl: '.post-61 .swiper-button-prev', }, breakpoints: { 320: { //当屏幕宽度大于等于320 slidesPerView: 2, }, 767: { //当屏幕宽度大于等于768 slidesPerView: 3, }, 999: { //当屏幕宽4, slidesPerView: 4, } } }); $(".main3 .sudy-tab").sudyTab({ handle: ".tab-menu .tit", content: ".tab-con .post", trigger: "mouseenter", start: 1, autoPlay: { active: false } }); $(".main5 .post2 .news .news_video").each(function () { if ($(this).find("video").attr("src") == "") { $(this).hide(); $(this).siblings("a").show(); } else { $(this).show(); $(this).siblings("a").hide(); } }); const videos = document.querySelectorAll(".main5 .post2 .news .news_video video"); const buttons = document.querySelectorAll(".main5 .post2 .news .news_video .play"); buttons.forEach(function (button, index) { button.addEventListener("click", function () { videos.forEach(function (el, index2) { if (index != index2) { videos[index2].pause(); buttons[index2].classList.remove("pause"); } }); button.classList.toggle("pause"); if (button.classList.contains("pause")) { videos[index].play(); } else { videos[index].pause(); } }); }); // //监听滑动或者鼠标滚动 // ScrollTrigger.observe({ // target: ".body_b", // can be any element (selector text is fine) // type: "wheel,touch,scroll,pointer", // comma-delimited list of what to listen for ("wheel,touch,scroll,pointer") // onUp: function (self) { // }, // onDown: function (self) { // if (!ScrollTrigger.isTouch) { // $(".back_bb").click() // $(".body_m").addClass("showdiv") // $("body").addClass("ovAuto") // } // }, // }); // ScrollTrigger.observe({ // target: ".body_m", // can be any element (selector text is fine) // type: "wheel,touch,scroll,pointer", // comma-delimited list of what to listen for ("wheel,touch,scroll,pointer") // onUp: function (self) { // //self.event.type 判断触发类型(touch,wheel...) // const rect = document.querySelector(".body_m").getBoundingClientRect(); // if ($(".body_m").scrollTop() == 0) { // $(".body_m").removeClass("showdiv") // $("body").removeClass("ovAuto") // } // } // }); particlesJS('particles-js', { particles: { number: { //下面这个数约大越密集 太大浏览器会卡 value: 20, density: { enable: true, //下面这个数约大越稀疏 太小浏览器会卡 value_area: 80 } }, //交点的颜色 color: { value: '#ffffff' }, opacity: { value: 0.1, random: false, anim: { enable: false, speed: 10, opacity_min: 0, sync: false } }, //别动就对了-—— shape: { type: 'circle', stroke: { width: 0, color: '#98aee8' }, polygon: { nb_sides: 5 }, image: { src: 'img/github.svg', width: 100, height: 100 } }, //透明度 opacity: { value: 0.1, random: false, anim: { enable: false, speed: 1, opacity_min: 0.1, sync: false } }, //端点尺寸 size: { value: 2, random: true, anim: { enable: false, speed: 40, size_min: 0.1, sync: false } }, //线 line_linked: { enable: true, distance: 80, //距离内连线 color: '#ffffff', opacity: 0.2, width: 1 }, //移动属性 move: { enable: true, //动画速度在这里!! speed: 3, direction: 'none', random: false, straight: false, out_mode: 'out', attract: { enable: false, rotateX: 600, rotateY: 1200 } } }, //交互 interactivity: { detect_on: 'canvas', events: { //鼠标滑过 和 鼠标点击 属性模式 //true表示开启 false 关闭 onhover: { enable: true, mode: 'grab' }, onclick: { enable: false, mode: 'push' }, resize: true }, //各种模式属性 把属性名替换 两个状态的 "mode": 即可1653/1657附近 "grab" "bubble" "repulse" "push" "remove" //下面是鼠标事件名称 modes: { //鼠标与distance范围内点连线 grab: { distance: 100, line_linked: { opacity: 1 } }, //改变周围点相应属性 bubble: { distance: 100, size: 10, duration: 2, opacity: 8, speed: 3 }, //鼠标周围distance范围排斥 repulse: { distance: 100 }, //添加 或 删除点de数量 push: { particles_nb: 4 }, remove: { particles_nb: 2 } } }, retina_detect: true }); });