/**** contactUs ****/
var swiperList = {};
var oldNum = 0;
var creatSwiper = function (num) {
var _html = '';
oldNum = num;
// _html += str_swiper(0)
for (var i = 0; i < String(num).length; i++) {
_html += str_swiper(i + 1)
}
$("#num_box").html(_html)
// swiperList.mySwiper0 = new Swiper('#swiper0', {
// paginationClickable: true,
// simulateTouch: false,
// loop: true,
// mode: 'vertical'
// });
for (var i = 0; i < String(num).length; i++) {
swiperList['mySwiper' + (i + 1)] = new Swiper('#swiper' + (i + 1), {
paginationClickable: true,
simulateTouch: false,
loop: true,
mode: 'vertical'
});
var _num = Number(String(num)[i]);
if (_num != 0) {
swiperList['mySwiper' + (i + 1)].swipeTo(Number(String(num)[i]), 1000, false)
}
}
}
var str_swiper = function (num) {
var _html = '';
_html += '
';
_html += '
';
_html += '
';
for (var i = 0; i < 10; i++) {
_html += '
' + i + '
';
}
_html += '
';
_html += '
'
_html += '
'
return _html
}
var bitAdd = function (num, index) {
if(isIE()){
var arr_num = String(num);
if (arr_num.length > String(oldNum).length) {
swiperList['mySwiper' + (arr_num.length - index - 1)].swipeNext();
} else {
swiperList['mySwiper' + (arr_num.length - index)].swipeNext();
}
if (Number(arr_num[arr_num.length - index - 1]) + 1 > 9) {
bitAdd(num, index + 1)
}
}else{
$("#num_box").eleRun();
}
}
var creatCounter = function (num) {
if (isIE()) {
creatSwiper(num)
} else {
var arr_num = String(num);
var _html = '';
for(var i=0;i';
}
$("#num_box").html(_html)
$("#num_box").dataStatistics({min:num,max:num,time:1000,len:5})
}
}
var isIE = function () {
if (!!window.ActiveXObject || "ActiveXObject" in window) {
return true;
} else {
return false;
}
}
$.fn.dataStatistics = function (options) {
options = $.extend({
min: 100, //鍒濆鏁板€
max: 150, //鏈€澶ф暟瀛
time: 60000, //鏃堕暱
len: 6 //鏁板瓧鏄嚑浣嶆暟
}, options || {});
var ths = this; //瑙e喅this鎸囧悜闂
//鍒濆鍖?--------------------------------------start
var el = ths.find('.set_last');
var html = '' +
'
' +
' ' +
'
' +
'
' +
'
' +
' ' +
'
' +
'
' +
'
'
//鍒濆鍖栧€
var nowNums = zfill(options.min, options.len).toString().split("");
//琛?
function zfill(num, size) {
var s = "000000000" + num;
return s.substr(s.length - size);
}
ths.find('.digit_set').each(function () {
for (i = 0; i <= 9; i++) {
$(this).append(html);
currentDigit = $(this).find('.digit')[i];
$(currentDigit).find('.digit_wrap').append(i);
}
});
//鍒濆鍖栨暟鍊煎~鍏
$.each(nowNums, function (index, val) {
var set = ths.find('.digit_set').eq(index);
var i = parseInt(val)
set.find('.digit').eq(i).addClass('active');
set.find('.digit').eq(i + 1).addClass('previous');
});
//鍒濆鍖?--------------------------------------end
//鎵ц
function run() {
var difference = options.max - options.min; //瑕佹墽琛屽姩鐢荤殑娆℃暟
//姣忔瑕佹墽琛屽姩鐢荤殑鏃堕棿
var t = options.time / difference;
//鍚庝竴浣嶆暟
function increase() {
//鎵ц娆℃暟涓?鏃?鍋滄鎵ц
if (difference < 1) {
clearInterval(timer1);
return false;
console.info('缁撴潫')
}
difference--;
console.info(difference);
//缈婚〉鍔ㄧ敾
var current = el.find('.active'),
previous = el.find('.previous');
previous.removeClass('previous');
current.removeClass('active').addClass('previous');
if (current.next().length == 0) {
el.find('.digit:first-child').addClass('active');
var prev = el.prev();
prevNumber(prev);
} else {
current.next().addClass('active');
}
}
var timer1 = setInterval(increase, t);
}
//褰撴暟瀛楃炕鍒?鐨勬椂鍊欙紝鍓嶄竴浣嶆暟鎵ц涓€娆″姩鐢
function prevNumber(ths) {
var current = ths.find('.active'),
previous = ths.find('.previous');
previous.removeClass('previous');
current.removeClass('active').addClass('previous');
if (current.next().length == 0) {
ths.find('.digit:first-child').addClass('active');
var prev = ths.prev();
if (prev.length > 0) {
prevNumber(prev);
}
} else {
current.next().addClass('active');
}
}
run();
};
$.fn.eleRun = function () {
var ths = this;
var el = ths.find('.set_last');
function increase() {
//缈婚〉鍔ㄧ敾
var current = el.find('.active'),
previous = el.find('.previous');
previous.removeClass('previous');
current.removeClass('active').addClass('previous');
if (current.next().length == 0) {
el.find('.digit:first-child').addClass('active');
var prev = el.prev();
prevNumber(prev);
} else {
current.next().addClass('active');
}
}
function prevNumber(ths) {
var current = ths.find('.active'),
previous = ths.find('.previous');
previous.removeClass('previous');
current.removeClass('active').addClass('previous');
if (current.next().length == 0) {
ths.find('.digit:first-child').addClass('active');
var prev = ths.prev();
if (prev.length > 0) {
prevNumber(prev);
}
} else {
current.next().addClass('active');
}
}
increase();
}
var swiperFun=function(){
setTimeout(function(){
var mySwiper = new Swiper('#img_box', {
loop: true,
centeredSlides: true,
slidesPerView: 3,
watchActiveIndex: true
});
},200)
}
$.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);
}