Commit 449fe173 by end

工作台日期展示

parent e0cfb985
No preview for this file type
......@@ -31,8 +31,8 @@ class homePage extends Component {
super(props);
this.state = {
dllTime: 3, //1年 2月 3日 4周
dllXtitle: [`${month}-${day - 4}`, `${month}-${day - 3}`, `${month}-${day - 2}`, `${month}-${day - 1}`, `${month}-${day}`],
tgXtitle: [`${month}-${day - 4}`, `${month}-${day - 3}`, `${month}-${day - 2}`, `${month}-${day - 1}`, `${month}-${day}`],
dllXtitle: this.getDateRange(),
tgXtitle: this.getDateRange(),
lllTime: 3, //1年 2月 3日 4周
hdlTime: 3, //1年 2月 3日 4周
hdlType: 6, //11点赞 12收藏 13评论 6阅读
......@@ -53,7 +53,18 @@ class homePage extends Component {
};
}
// 登录量
getDateRange = () => {
const dates = [];
for (let i = 4; i >= 0; i--) {
const currentDate = new Date();
currentDate.setDate(currentDate.getDate() - i);
const m = currentDate.getMonth() + 1;
const d = currentDate.getDate();
dates.push(`${m}-${d < 10 ? '0' + d : d}`);
}
return dates;
};
// 在dllChange方法中调用
dllChange = e => {
if (e == 1) {
this.setState({ dllTime: e, currentPeriod: "今年", oldCurrentPeriod: "去年", dllXtitle: [`${year - 4}年`, `${year - 3}年`, `${year - 2}年`, `${year - 1}年`, `${year}年`] }, () => {
......@@ -64,7 +75,13 @@ class homePage extends Component {
this.getDllRes();
});
} else if (e == 3) {
this.setState({ dllTime: e, currentPeriod: "今日", oldCurrentPeriod: "昨日", dllXtitle: [`${month}-${day - 4}`, `${month}-${day - 3}`, `${month}-${day - 2}`, `${month}-${day - 1}`, `${month}-${day}`] }, () => {
const dateTitles = this.getDateRange();
this.setState({
dllTime: e,
currentPeriod: "今日",
oldCurrentPeriod: "昨日",
dllXtitle: dateTitles
}, () => {
this.getDllRes();
});
}
......@@ -187,20 +204,20 @@ class homePage extends Component {
hdlChange = (type, e) => {
if (type == 1) {
if (e == 1) {
this.setState({ hdlTime: e, hdlcurrentPeriod: "今年", oldHdlCurrentPeriod: "去年" }, () => {
this.getHdlRes();
});
}
if (e == 2) {
this.setState({ hdlTime: e, hdlcurrentPeriod: "本月", oldHdlCurrentPeriod: "上月" }, () => {
this.getHdlRes();
});
}
if (e == 3) {
this.setState({ hdlTime: e, hdlcurrentPeriod: "今日", oldHdlCurrentPeriod: "昨日", }, () => {
this.getHdlRes();
});
}
this.setState({ hdlTime: e, hdlcurrentPeriod: "今年", oldHdlCurrentPeriod: "去年" }, () => {
this.getHdlRes();
});
}
if (e == 2) {
this.setState({ hdlTime: e, hdlcurrentPeriod: "本月", oldHdlCurrentPeriod: "上月" }, () => {
this.getHdlRes();
});
}
if (e == 3) {
this.setState({ hdlTime: e, hdlcurrentPeriod: "今日", oldHdlCurrentPeriod: "昨日", }, () => {
this.getHdlRes();
});
}
} else if (type == 2) {
this.setState({ hdlType: e }, () => {
this.getHdlRes();
......@@ -556,7 +573,7 @@ class homePage extends Component {
this.getTgRes();
});
} else if (e == 3) {
this.setState({ tgTime: e, tgXtitle: [`${month}-${day - 4}`, `${month}-${day - 3}`, `${month}-${day - 2}`, `${month}-${day - 1}`, `${month}-${day}`] }, () => {
this.setState({ tgTime: e, tgXtitle: this.getDateRange() }, () => {
this.getTgRes();
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment