$(function () { //-- { $('.navA').click(function () { if ($('body').hasClass('navShow')) { $('body').removeClass('navShow') } else { $('body').addClass('navShow') } }); $('.g-nav2').find('li').each(function () { var li = $(this); if (li.find('.list').length > 0) { li.find('h2').addClass('h2'); li.find('h2').click(function () { if ($(window).width() > 800) return; if (li.hasClass('on')) { li.removeClass('on'); li.find('.list').hide() } else { li.addClass('on'); li.find('.list').show() } }) } }); if ($(window).width() < 800) { var elem = document.getElementsByClassName('search'); $('.g-nav2').append('
' + $('.g-head .btn-list').html() + '
'); elem[0].parentNode.removeChild(elem[0]); } } { $('.g-head').find('.search').hover( function () { $(this).addClass('on') }, function () { $(this).removeClass('on') } ) } //--杩斿洖椤堕儴 scroll2top(); //--js涓嬫媺閫夋嫨妗 { $('.select').each(function () { var select = $(this); select.find('select').change(function () { select.find('span').html($(this).find("option:selected").text()); }) }) } { $('.form').find('li').each(function () { var li = $(this); li.find('input').focus(function () { li.addClass('on') }); li.find('input').blur(function () { li.removeClass('on') }); li.find('textarea').focus(function () { li.addClass('on') }); li.find('textarea').blur(function () { li.removeClass('on') }) }) } { var layer = $('.p-layer'); layer.click(function () { layer.removeClass('show'); $('body').removeClass('hidden'); }); layer.find('.container').click(function (e) { e.stopPropagation() }) } }); // function swiperFun(swiper) { // this.dom = swiper.dom; // this.domList = this.dom; // this.dom.find('ul').addClass('swiper-wrapper'); // this.dom.find('li').addClass('swiper-slide'); // if(swiper.domList !== undefined){ // this.domList = this.dom.find(swiper.domList) // } // if(this.dom.find('.num').length > 0){ // this.dom.find('.num-total').html(this.dom.find('li').length) // } // this.change = function () {}; // var that = this; // this.mySwiper = new Swiper(that.domList, { // effect: swiper.effect !== undefined ? swiper.effect : 'slide', // loop: swiper.loop !== undefined ? swiper.loop : true, // autoplay: swiper.autoplay !== undefined ? swiper.autoplay : 5000, // autoplayDisableOnInteraction: false, // paginationClickable: true, // speed: 600, // slidesPerView: swiper.slidesPerView !== undefined ? swiper.slidesPerView : 1, // slidesPerGroup: swiper.slidesPerGroup !== undefined ? swiper.slidesPerGroup : 1, // centeredSlides: swiper.centeredSlides !== undefined ? swiper.centeredSlides : false, // slideToClickedSlide: swiper.slideToClickedSlide !== undefined ? swiper.slideToClickedSlide : false, // pagination: that.dom.find('.dots'), // loopAdditionalSlides : 10, // onSlideChangeStart: function(swiper){ // if(that.dom.find('.num').length > 0){ // that.dom.find('.num-curr').html(swiper.realIndex + 1) // } // that.change(swiper.realIndex); // } // }); // this.dom.find('.prev').click(function () { // that.mySwiper.slidePrev(); // return false // }); // this.dom.find('.next').click(function () { // that.mySwiper.slideNext(); // return false // }) // } //--閫夐」鍗?- tabFun({dom: $('.about'), curr: 0}); function tabFun(tab) { var btn = tab.dom.find('.tab-btn li'), box = tab.dom.find('.tab-box'); btn.each(function (i) { $(this).click(function () { change(i) }) }); change(tab.curr); function change(curr) { btn.removeClass('on'); btn.eq(curr).addClass('on'); box.hide(); box.eq(curr).fadeIn() } } function scroll2top() { var btn = $('.topA'); btn.click(function () { $('body,html').stop(true, true).animate({scrollTop: 0}, 300); }); $(window).scroll(function () { if($(window).scrollTop() > $(window).height()){ btn.addClass('show') }else{ btn.removeClass('show') } }); } function arrayOne2Two(baseArray, n) { var len = baseArray.length, lineNum = len % n === 0 ? len / n : Math.floor( (len / n) + 1 ), res = []; for (var i = 0; i < lineNum; i++) { // slice() 鏂规硶杩斿洖涓€涓粠寮€濮嬪埌缁撴潫锛堜笉鍖呮嫭缁撴潫锛夐€夋嫨鐨勬暟缁勭殑涓€閮ㄥ垎娴呮嫹璐濆埌涓€涓柊鏁扮粍瀵硅薄銆備笖鍘熷鏁扮粍涓嶄細琚慨鏀广€ var temp = baseArray.slice(i*n, i*n+n); res.push(temp); } return res } $.fn.countTo = function (options) { options = options || {}; return $(this).each(function () { // set options for current element 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); // how many times to update the value, and how much to increment the value on each update var loops = Math.ceil(settings.speed / settings.refreshInterval), increment = (settings.to - settings.from) / loops; // references & variables that will change with each update var self = this, $self = $(this), loopCount = 0, value = settings.from, data = $self.data('countTo') || {}; $self.data('countTo', data); // if an existing interval can be found, clear it first if (data.interval) { clearInterval(data.interval); } data.interval = setInterval(updateTimer, settings.refreshInterval); // initialize the element with the starting value render(value); function updateTimer() { value += increment; loopCount++; render(value); if (typeof(settings.onUpdate) == 'function') { settings.onUpdate.call(self, value); } if (loopCount >= loops) { // remove the interval $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, // the number the element should start at to: 0, // the number the element should end at speed: 1000, // how long it should take to count between the target numbers refreshInterval: 100, // how often the element should be updated decimals: 0, // the number of decimal places to show formatter: formatter, // handler for formatting the value before rendering onUpdate: null, // callback method for every time the element is updated onComplete: null // callback method for when the element finishes updating }; function formatter(value, settings) { return value.toFixed(settings.decimals); } // custom formatting example $('#count-number').data('countToOptions', { formatter: function (value, options) { return value.toFixed(options.decimals).replace(/\B(?=(?:\d{3})+(?!\d))/g, ','); } }); // start all the timers $('.timer').each(count); function count(options) { var $this = $(this); options = $.extend({}, options || {}, $this.data('countToOptions') || {}); $this.countTo(options); }