"use strict"; (function () { console.log("浏览器分辨率是" + document.documentElement.clientWidth + "*" + document.documentElement.clientHeight); console.log("屏幕分辨率是" + window.screen.width + "*" + window.screen.height); let isPc = true; let isPad = false; let isPhone = false; checkSize() $(window).resize(function () { checkSize() }); function checkSize() { let windowsWidth = document.documentElement.clientWidth; if (windowsWidth > 991) { isPc = true; isPad = false; isPhone = false; console.log("isPc", isPc); } else if (windowsWidth >= 768 && windowsWidth <= 991) { isPc = false; isPad = true; console.log("isPad", isPad); } else if (windowsWidth < 768) { isPc = false; isPad = false; isPhone = true; console.log("isPhone", isPhone); } console.log("windowsWidth", windowsWidth); } var mybanner = new Swiper('#sw_banner', { loop: true, speed: 300, autoplay: { disableOnInteraction: false, delay: 4000 }, navigation: { nextEl: '.swiper-button-next-banner', prevEl: '.swiper-button-prev-banner', }, pagination: { el: '.swiper-pagination-banner', clickable: true, }, on: { init: function (item) { bannerReSize() } } }) var sw_pagebanner = new Swiper('#sw_pagebanner', { loop: true, speed: 300, on: { init: function (item) { bannerReSize(item) } } }) function bannerReSize(e) { // console.log(e); let pcHeight = $(".sw_banner")[0].dataset.pcheight; let padHeight = $(".sw_banner")[0].dataset.padheight; let phoneHeight = $(".sw_banner")[0].dataset.phoneheight; if (isPc) { $(".sw_banner .swiper-slide").css({ "background-size": "auto " + pcHeight + "px", "height": pcHeight + "px" }) $(".sw_banner .swiper-slide div").css({ "height": pcHeight + "px" }) } if (isPad) { $(".sw_banner .swiper-slide").css({ "background-size": "auto " + padHeight + "px", "height": padHeight + "px" }) $(".sw_banner .swiper-slide div").css({ "height": padHeight + "px" }) } if (isPhone) { $(".sw_banner .swiper-slide").css({ "background-size": "auto " + phoneHeight + "px", "height": phoneHeight + "px" }) $(".sw_banner .swiper-slide div").css({ "height": phoneHeight + "px" }) } } $(window).resize(function () { bannerReSize() console.log("bannerUpdata"); } ); //产品1 var index_product1_sw = new Swiper('.index_product1_sw', { autoplay: true, autoplay: { disableOnInteraction: false, }, watchSlidesVisibility: true, slidesPerView: 3, slidesPerColumn: 2, slidesPerColumnFill: 'row', spaceBetween: 20, breakpoints: { 1024: { slidesPerView: 3, }, 768: { slidesPerView: 3, }, 640: { slidesPerView: 2, }, 320: { slidesPerView: 2, } } }) //产品1 //产品1 var index_product3_sw = new Swiper('#index_product3_sw', { spaceBetween: 10, }) $('.index_product1_left_nav a').each(function(e){ if(e < $('.index_product1_left_nav a').length - 1){ $(this).attr("data-index",e) } }) $('.index_product1_left_nav_item').hover(function (e) { var targer_index = e.target.dataset['index']; index_product3_sw.slideTo(targer_index, 1000, false); }) $('a').attr('target','_blank'); //产品2 var mySwiper_product2 = new Swiper('#index_product2_sw', { autoplay: true, autoplay: { disableOnInteraction: false, }, watchSlidesVisibility: true, slidesPerView: 4, spaceBetween: 20, breakpoints: { 1024: { slidesPerView: 4, }, 768: { slidesPerView: 3, }, 640: { slidesPerView: 2, }, 320: { slidesPerView: 2, } }, navigation: { nextEl: '.swiper_button_next_product', prevEl: '.swiper_button_prev_product', }, }) //产品2 //产品3 var index_product3_sw_text = new Swiper('#index_product3_sw_text', { slidesPerView: 4, watchSlidesVisibility: true, breakpoints: { 1024: { slidesPerView: 4, }, 768: { slidesPerView: 4, }, 640: { slidesPerView: 2, }, 320: { slidesPerView: 2, } }, }) var mySwiper_product2 = new Swiper('.index_product3_sw_item', { autoplay: true, autoplay: { disableOnInteraction: false, }, watchSlidesVisibility: true, slidesPerView: 4, slidesPerColumn: 2, slidesPerColumnFill: 'row', spaceBetween: 20, breakpoints: { 1024: { slidesPerView: 4, }, 768: { slidesPerView: 2, }, 640: { slidesPerView: 2, }, 320: { slidesPerView: 2, } }, }) //产品3 $('.clearfix iframe').css('height', $('.clearfix iframe').width() * 0.56); }());