...
|
...
|
@@ -9,46 +9,53 @@ var $ = require('yoho-jquery'), |
|
|
var $activityTime = $('.activity-time'),
|
|
|
endTime = $activityTime.data('time-ms');
|
|
|
|
|
|
var anHour = 3600000,
|
|
|
aMinute = 60000,
|
|
|
aSecond = 1000;
|
|
|
var params = {
|
|
|
anHour: 3600000, // 1小时=?毫秒
|
|
|
aMinute: 60000, // 1分钟=?毫秒
|
|
|
aSecond: 1000, // 1秒=?毫秒
|
|
|
timeDom: $activityTime, // 时间对象数组
|
|
|
endTime: [endTime] // 时间差数组
|
|
|
};
|
|
|
|
|
|
require('./sale/search');
|
|
|
|
|
|
lazyLoad($('img.lazy'));
|
|
|
|
|
|
|
|
|
// 倒计时
|
|
|
function getRTime() {
|
|
|
function getRTime(conf) {
|
|
|
var showTime = '',
|
|
|
d = 0,
|
|
|
h = 0,
|
|
|
m = 0,
|
|
|
s = 0;
|
|
|
|
|
|
endTime = endTime - 1000;
|
|
|
|
|
|
if (endTime > 1000) {
|
|
|
d = Math.floor(endTime / anHour / 24);
|
|
|
h = Math.floor(endTime / anHour % 24);
|
|
|
m = Math.floor(endTime / aMinute % 60);
|
|
|
s = Math.floor(endTime / aSecond % 60);
|
|
|
|
|
|
showTime += d > 0 ? d + '天' : '';
|
|
|
showTime += h > 0 ? h + '小时' : '';
|
|
|
showTime += m > 0 ? m + '分钟' : '';
|
|
|
showTime += s > 0 ? s + '秒' : '';
|
|
|
|
|
|
if (showTime.length !== '') {
|
|
|
showTime = '剩' + showTime;
|
|
|
conf.timeDom.each(function(key, item) {
|
|
|
showTime = '';
|
|
|
conf.endTime[key] = conf.endTime[key] - 1000;
|
|
|
|
|
|
if (conf.endTime[key] > 1000) {
|
|
|
d = Math.floor(conf.endTime[key] / conf.anHour / 24);
|
|
|
h = Math.floor(conf.endTime[key] / conf.anHour % 24);
|
|
|
m = Math.floor(conf.endTime[key] / conf.aMinute % 60);
|
|
|
s = Math.floor(conf.endTime[key] / conf.aSecond % 60);
|
|
|
|
|
|
showTime += d > 0 ? d + '天' : '';
|
|
|
showTime += h > 0 ? h + '小时' : '';
|
|
|
showTime += m > 0 ? m + '分钟' : '';
|
|
|
showTime += s > 0 ? s + '秒' : '';
|
|
|
|
|
|
if (showTime.length !== '') {
|
|
|
showTime = '剩' + showTime;
|
|
|
}
|
|
|
|
|
|
$(item).find('span').html(showTime);
|
|
|
$(item).fadeIn();
|
|
|
} else {
|
|
|
$(item).hide();
|
|
|
}
|
|
|
|
|
|
$activityTime.find('span').html(showTime);
|
|
|
|
|
|
$activityTime.attr('data-time-ms', endTime);
|
|
|
} else {
|
|
|
$activityTime.hide();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
setInterval(getRTime, 1000); |
|
|
setInterval(function() {
|
|
|
getRTime(params);
|
|
|
}, 1000); |
...
|
...
|
|