$(function () { const weekdays = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]; // 获取当前年份 var date = new date(); var year = date .getfullyear(); $(".year").html(year); const month = date.getmonth() + 1; // 获取当前月份,注意getmonth()返回的是0-11,所以需要加1 const day = date.getdate(); // 获取当前日期 $(".newtime").html(year + '年' + month + '月' + day + '日') const weekday = date.getday(); $(".week").html(weekdays[weekday]) }) $(function () { var top = $(document).scrolltop(); //滚动条距离顶部的高度 if (top >= 10) { $('#header1').addclass('xg') $('.ss').addclass('seach_glide') $('.icon img').attr('src', './imgs/ss.png') } else { $('#header1').removeclass('xg') $('.ss').removeclass('seach_glide') $('.icon img').attr('src', './imgs/seach.png') } console.log(top) if (top <= 10) { $('#header1').mouseover(function () { $('.ss').addclass('seach_glide') $('.icon img').attr('src', './imgs/ss.png') }) $('#header1').mouseleave(function () { $('.ss').removeclass('seach_glide') $('.icon img').attr('src', './imgs/seach.png') }) } /* 监听滚动 */ $(document).scroll(function () { var top = $(document).scrolltop(); //滚动条距离顶部的高度 if (top >= 10) { $('#header1').addclass('xg') $('.ss').addclass('seach_glide') $('.icon img').attr('src', './imgs/ss.png') } else { $('#header1').removeclass('xg') $('.ss').removeclass('seach_glide') $('.icon img').attr('src', './imgs/seach.png') } }); }) $(function () { // 首页顶部 var swipertop = new swiper(".myswipertop", { loop: true, autoplay: true, pagination: { el: ".swiper-pagination", clickable: true, }, }); // 轮播 var swiperxw = new swiper(".myswiper", { loop: true, autoplay: true, }); effect = 0 var swiperxm = new swiper('.swiper-container', { loop: true, speed: 700, slidesperview: 3, spacebetween: 30, centeredslides: true, watchslidesprogress: true, autoplay: true, on: { settranslate: function () { slides = this.slides for (i = 0; i < slides.length; i++) { slide = slides.eq(i) progress = slides[i].progress //slide.html(progress.tofixed(2)); 看清楚progress是怎么变化的 slide.css({ 'opacity': '', 'background': '' }); slide.transform('');//清除样式 if (effect == 1) { slide.transform('scale(' + (1 - math.abs(progress) / 8) + ')'); } else if (effect == 2) { slide.css('opacity', (1 - math.abs(progress) / 6)); slide.transform('translate3d(0,' + math.abs(progress) * 20 + 'px, 0)'); } else if (effect == 3) { slide.transform('rotate(' + progress * 30 + 'deg)'); } else if (effect == 4) { slide.css('background', 'rgba(' + (255 - math.abs(progress) * 20) + ',' + (127 + progress * 32) + ',' + math.abs(progress) * 64 + ')'); } } }, settransition: function (transition) { for (var i = 0; i < this.slides.length; i++) { var slide = this.slides.eq(i) slide.transition(transition); } }, }, navigation: { nextel: '.swiper-button-next', prevel: '.swiper-button-prev', }, // pagination: { // el: '.swiper-pagination', // clickable: true, // }, }); })