-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
51 lines (48 loc) · 1.09 KB
/
main.js
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
new Vue({
el: '#app',
data(){
return{
weeks: 0,
days: 0,
hours: 0,
minutes: 0,
seconds: 0,
interested: 1129
}
},
methods: {
updateDiff: function() {
if(moment().seconds() == 0 || this.seconds < 0){
this.setDiff();
} else{
this.seconds -= 1;
}
},
increment: function (){
this.interested ++;
},
decrement: function (){
if (this.interested !== 0) {
this.interested --;
}
},
setDiff() {
var now = moment();
var theDay = moment("20191108", "YYYYMMDD");
this.weeks = theDay.diff(now, 'weeks');
now.weeks(now.weeks() + this.weeks);
this.days = theDay.diff(now, 'days');
now.days(now.days() + this.days);
this.hours = theDay.diff(now, 'hours');
now.hours(now.hours() + this.hours);
this.minutes = theDay.diff(now, 'minutes');
now.minutes(now.minutes() + this.minutes);
this.seconds = theDay.diff(now, 'seconds');
}
},
mounted() {
moment().format();
this.setDiff();
setInterval(this.updateDiff, 1000);
}
})