r_time.js
2.07 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
var util = require('../../utils/util.js')
Page({
data:{
start:{
startdate:'2021-01-25',
endate:'2021-01-25',
date:'',
timestamp:0
},
end:{
startdate:'2021-01-25',
endate:'2021-01-25',
date:'',
timestamp:0
}
},
onLoad(opt){
console.log(opt);
this.init();
if(opt.sdate || opt.edate){
let s_timestamp=0,e_timestamp=0;
if(opt.sdate!=''){
s_timestamp=util.timetouUnix(opt.sdate+' 00:00:00','-');
}
if(opt.edate!=''){
e_timestamp=util.timetouUnix(opt.edate+' 23:59:59','-');
console.log(e_timestamp)
}
console.log(e_timestamp)
this.setData({
'start.date':opt.sdate,
'start.timestamp':s_timestamp,
'end.date':opt.edate,
'end.timestamp':e_timestamp,
'start.enddate':opt.edate ? opt.edate : this.data.start.enddate,
'end.startdate':opt.sdate ? opt.sdate : this.data.end.startdate,
})
}
},
startchange(e){
let date=e.detail.value;
let timestamp=util.timetouUnix(date+' 00:00:00','-');
this.setData({
'end.startdate':date,
'start.date':date,
'start.timestamp':Number(timestamp),
})
},
endchange(e){
let date=e.detail.value;
let timestamp=util.timetouUnix(date+' 23:59:59','-');
this.setData({
'start.enddate':date,
'end.date':date,
'end.timestamp':Number(timestamp),
})
},
init(){
let timestamp=Date.parse(new Date())/1000
let date=util.unixtoTime(timestamp,'YYYY-MM-DD');
this.setData({
'start.enddate':date,
'end.enddate':date,
'start.date':'',
'end.date':'',
'start.timestamp:':0,
'end.timestamp:':0
})
},
select(){
let dur={
start:{
date:this.data.start.date,
timestamp:this.data.start.timestamp
},
end:{
date:this.data.end.date,
timestamp:this.data.end.timestamp
}
}
util.cache('select',true);
util.cache('dur',dur);
wx.navigateBack();
},
clear(){
this.init();
let dur={
start:{
date:this.data.start.date,
timestamp:this.data.start.timestamp
},
end:{
date:this.data.end.date,
timestamp:this.data.end.timestamp
}
}
util.cache('select',true);
util.cache('dur',dur);
}
})