special-detail.page.js
1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* 折扣专场详情
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/5/20
*/
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload');
var $activityTime = $('.activity-time'),
endTime = $activityTime.data('time-ms');
require('./search');
lazyLoad($('img.lazy'));
// 倒计时
function getRTime() {
var anHour = 3600000,
aMinute = 60000,
aSecond = 1000,
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;
}
$activityTime.find('span').html(showTime);
$activityTime.attr('data-time-ms', endTime);
} else {
$activityTime.hide();
}
}
setInterval(getRTime, 1000);