-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp.txt
68 lines (64 loc) · 1.55 KB
/
temp.txt
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<script>
var endActive = function(opts){
var defaults = {
endtime: '2015-09-25-14-30',
id:'end-active',
alertMsg:{
title:'提示',
content:'对不起,活动已经结束!'
}
};
this.opts=$.extend(defaults,opts);
console.log(this.opts);
return this.init();
};
endActive.prototype = {
init:function(){
return this.runTime();
},
resolveTime:function(){
var objArr=this.opts.endtime.split('-');
if (objArr.length==5) {
var oEndTime=new Date(objArr[0],objArr[1],objArr[2],objArr[3],objArr[4]);
}else{
alert('error:参数\'endtime\'初始化错误!');
return false;
}
return oEndTime;
},
runTime:function(){
var _this=this;
var oEndTime=_this.resolveTime(),t;
setInterval(function(){
var oNowTime=new Date();
t = oEndTime.getTime()-oNowTime.getTime();
_this.seconds = Math.round(t/1000);
var timeNum=_this.timeToNum();
return timeNum;
}, 5000);
},
timeToNum:function(seconds){
seconds==null?seconds=this.seconds:seconds;
var days=Math.floor(seconds/86400);
var hours=Math.floor((seconds-86400*days)/3600);
var minutes=Math.floor((seconds-86400*days-3600*hours)/60);
var second=Math.floor(seconds-86400*days-3600*hours-60*minutes);
return {
days : days,
hours : hours,
minutes : minutes,
seconds : second
};
}
};
new endActive();
/* $('#end-active').click(function(){
var alertDialog=xzmui.dialog({
title: '提示',
content:'对不起,活动已经结束!'
});
alertDialog.show();
return false;
});*/
</script>
<!-- 结束活动 -->