ChineseWithLastDateFooter.js
1.66 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
/*
*
* Created by Stone
* https://github.com/bolan9999
* Email: shanshang130@gmail.com
* Date: 2019/1/25
*
*/
import {WithLastDateFooter} from "./WithLastDateFooter";
export class ChineseWithLastDateFooter extends WithLastDateFooter{
getText() {
return "最后加载: ";
}
getTimeDescription() {
if (!this.lastTime) {
return "从未加载";
}
const now = new Date();
let timeInterval = Math.floor(
(now.getTime() - this.lastTime.getTime()) / 1000
);
if (timeInterval < 60) {
return `${timeInterval}秒前`;
} else if (timeInterval < 3600) {
return `${Math.floor(timeInterval / 60)}分钟前`;
} else if (
now.getFullYear() === this.lastTime.getFullYear() &&
now.getMonth() === this.lastTime.getMonth() &&
now.getDate() === this.lastTime.getDate()
) {
return `${this.lastTime.getHours()}:${this.lastTime.getMinutes()}`;
} else if (now.getFullYear() === this.lastTime.getFullYear()) {
return `${this.lastTime.getMonth() + 1}-${this.lastTime.getDate()}`;
} else {
return `${this.lastTime.getFullYear()}-${this.lastTime.getMonth() +
1}-${this.lastTime.getDate()}`;
}
}
getTitle() {
const s = this.state.status;
if (s === "dragging" || s === "waiting") {
return "上拉加载更多";
} else if (s === "draggingEnough") {
return "松开加载更多";
} else if (s === "loading") {
return "正在加载数据...";
} else if (s === "draggingCancel") {
return "放弃加载更多";
} else if (s === "rebound") {
return "加载完成";
} else if (s === "allLoaded") {
return "已经到底啦";
}
}
}