// 手机导航收起展开 $('.hb').click(function(e) { e.preventDefault(); $('.center_span').toggleClass('hb_fadeout') $('.top_span').toggleClass('change1') $('.bottom_span').toggleClass('change2') }); $('.hb').click(function(e) { e.preventDefault(); $('.ml_mb_nav').stop().toggleClass('mb_navShow') }); $('.mb_item1_arrow').click(function(e) { e.preventDefault(); var num1 = $('.mb_item1_arrow').index(this) $('.ml_mbnav_2').eq(num1).stop().slideToggle() $('.mb_item1_arrow').eq(num1).stop().toggleClass('ml_mb_arrowChange') }); $('.mb_item2_arrow').click(function(e) { e.preventDefault(); var num2 = $('.mb_item2_arrow').index(this) $('.ml_mbnav_3').eq(num2).stop().slideToggle() $('.mb_item2_arrow').eq(num2).stop().toggleClass('ml_mb_arrowChange') }); // 动画 AOS.init({ duration: 800, disable: 'mobile' }) // 电脑侧边栏效果 $(document).ready(function() { $(window).scroll(function() { var topp = $(document).scrollTop(); if (topp > 200) { $('.backtotop').addClass('ml_sidebar_show') } else { $('.backtotop').removeClass('ml_sidebar_show') } }) }) // 首页banner var mySwiper = new Swiper('.ml_banner', { autoplay: { delay: 3000 }, loop: true, // 循环模式选项 // 如果需要分页器 pagination: { el: '.bannerpage', clickable: true }, // 如果需要前进后退按钮 navigation: { nextEl: '.bannerbtnright', prevEl: '.bannerbtnleft', }, }) $('.search i').click(function(e) { e.preventDefault(); $('.cover').addClass('covershow') $('.sou').addClass('searchshow') }); $('.close').click(function(e) { e.preventDefault(); $('.cover').removeClass('covershow') $('.sou').removeClass('searchshow') }); //定义变量获取屏幕视口宽度 var windowWidth = $(window).width(); if (windowWidth < 996) { var swiper = new Swiper(".case_small", { spaceBetween: 10, slidesPerView: 2.5, freeMode: true, watchSlidesProgress: true, }); var swiper2 = new Swiper(".case_big", { spaceBetween: 10, // thumbs: { // swiper: swiper, // }, }); } if (windowWidth >= 996) { var swiper = new Swiper(".case_small", { spaceBetween: 10, slidesPerView: 7, freeMode: true, watchSlidesProgress: true, }); var swiper2 = new Swiper(".case_big", { spaceBetween: 10, // thumbs: { // swiper: swiper, // }, }); } //窗口显示才加载 var wrapTop = $(".digital").offset().top; var istrue = true; $(window).on("scroll", function() { var s = $(window).scrollTop(); if (s > wrapTop - 500 && istrue) { $(".timer").each(count); function count(a) { var b = $(this); a = $.extend({}, a || {}, b.data("countToOptions") || {}); b.countTo(a) }; istrue = false; }; }) //设置计数 $.fn.countTo = function(options) { options = options || {}; return $(this).each(function() { //当前元素的选项 var settings = $.extend({}, $.fn.countTo.defaults, { from: $(this).data('from'), to: $(this).data('to'), speed: $(this).data('speed'), refreshInterval: $(this).data('refresh-interval'), decimals: $(this).data('decimals') }, options); //更新值 var loops = Math.ceil(settings.speed / settings.refreshInterval), increment = (settings.to - settings.from) / loops; //更改应用和变量 var self = this, self = $(this), loopCount = 0, value = settings.from, data = self.data('countTo') || {}; self.data('countTo', data); //如果有间断,找到并清除 if (data.interval) { clearInterval(data.interval); }; data.interval = setInterval(updateTimer, settings.refreshInterval); //初始化起始值 render(value); function updateTimer() { value += increment; loopCount++; render(value); if (typeof(settings.onUpdate) == 'function') { settings.onUpdate.call(self, value); } if (loopCount >= loops) { //移出间隔 self.removeData('countTo'); clearInterval(data.interval); value = settings.to; if (typeof(settings.onComplete) == 'function') { settings.onComplete.call(self, value); } } } function render(value) { var formattedValue = settings.formatter.call(self, value, settings); self.html(formattedValue); } }); }; $.fn.countTo.defaults = { from: 0, //数字开始的值 to: 0, //数字结束的值 speed: 1000, //设置步长的时间 refreshInterval: 100, //隔间值 decimals: 0, //显示小位数 formatter: formatter, //渲染之前格式化 onUpdate: null, //每次更新前的回调方法 onComplete: null //完成更新的回调方法 }; function formatter(value, settings) { return value.toFixed(settings.decimals); } //自定义格式 $('#count-number').data('countToOptions', { formmatter: function(value, options) { return value.toFixed(options.decimals).replace(/\B(?=(?:\d{3})+(?!\d))/g, ','); } }); //定时器 $('.timer').each(count); function count(options) { var $this = $(this); options = $.extend({}, options || {}, $this.data('countToOptions') || {}); $this.countTo(options); }