|
@@ -1,18 +1,18 @@
|
|
|
import React, { Component } from 'react';
|
|
|
import { Link } from 'react-router-dom';
|
|
|
import './index.less';
|
|
|
-import { Tooltip, Icon } from 'antd';
|
|
|
+import { Tooltip, Icon, Calendar } from 'antd';
|
|
|
import Page from '@src/containers/Page';
|
|
|
import Assets from '@src/components/Assets';
|
|
|
import { formatPercent, formatDate, formatSeconds } from '@src/services/Tools';
|
|
|
import { asyncSMessage } from '@src/services/AsyncTools';
|
|
|
+import moment from 'moment';
|
|
|
import UserLayout from '../../../layouts/User';
|
|
|
import Tabs from '../../../components/Tabs';
|
|
|
import Button from '../../../components/Button';
|
|
|
import { Icon as GIcon } from '../../../components/Icon';
|
|
|
import UserTable from '../../../components/UserTable';
|
|
|
import Examination from '../../../components/Examination';
|
|
|
-import Tabs from '../../../components/Tabs';
|
|
|
import menu from '../index';
|
|
|
import { BindPhone, BindEmail, EditInfo, RealAuth, EditAvatar, InviteModal } from '../../../components/OtherModal';
|
|
|
import VipRenew from '../../../components/VipRenew';
|
|
@@ -33,7 +33,7 @@ class LogItem extends Component {
|
|
|
|
|
|
render() {
|
|
|
const { data = {} } = this.props;
|
|
|
- const { total = [], detail = [] } = data;
|
|
|
+ const { total = [], type } = data;
|
|
|
const { open } = this.state;
|
|
|
return (
|
|
|
<div className="log-item">
|
|
@@ -47,20 +47,38 @@ class LogItem extends Component {
|
|
|
<div className="open">
|
|
|
<GIcon name={open ? 'small-up' : 'small-down'} onClick={() => this.setState({ open: !open })} />
|
|
|
</div>
|
|
|
- <div hidden={!open} className="table">
|
|
|
- <UserTable size="small" columns={this.columns} data={detail} />
|
|
|
- <div className="t-r">
|
|
|
- <Link to="">继续练习></Link>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ {type === 'exercise' && this.renderExercise()}
|
|
|
+ {type === 'examination' && this.renderExamination()}
|
|
|
+ {type === 'course' && this.renderCourse()}
|
|
|
</div>
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+ renderExercise() {
|
|
|
+ const { data = {} } = this.props;
|
|
|
+ const { detail = [] } = data;
|
|
|
+ const { open } = this.state;
|
|
|
+ return <div hidden={!open} className="table">
|
|
|
+ <UserTable size="small" columns={this.columns} data={detail} />
|
|
|
+ <div className="t-r">
|
|
|
+ <Link to="/exercise">继续练习></Link>
|
|
|
+ </div>
|
|
|
+ </div>;
|
|
|
+ }
|
|
|
+
|
|
|
+ renderExamination() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ renderCourse() {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export default class extends Page {
|
|
|
initState() {
|
|
|
return {
|
|
|
+ day: 'today',
|
|
|
showExamination: false,
|
|
|
timeList: [
|
|
|
{ title: '长难句', time: '3h60min', ratio: 10, color: '#3C39CC' },
|
|
@@ -142,6 +160,7 @@ export default class extends Page {
|
|
|
.then(result => {
|
|
|
this.setState({ messages: result.list });
|
|
|
});
|
|
|
+ this.refreshDay(this.state.day);
|
|
|
}
|
|
|
|
|
|
readAllMessage() {
|
|
@@ -152,7 +171,44 @@ export default class extends Page {
|
|
|
}
|
|
|
|
|
|
refreshDay(value) {
|
|
|
- console.log(value);
|
|
|
+ let time = '';
|
|
|
+ switch (value) {
|
|
|
+ case 'today':
|
|
|
+ time = moment().format('YYYY-MM-DD');
|
|
|
+ break;
|
|
|
+ case 'yesterday':
|
|
|
+ time = moment().add(-1, 'days').format('YYYY-MM-DD');
|
|
|
+ break;
|
|
|
+ case 'before':
|
|
|
+ time = moment().add(-2, 'days').format('YYYY-MM-DD');
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ time = value.format('YYYY-MM-DD');
|
|
|
+ value = 'other';
|
|
|
+ }
|
|
|
+ My.getStudy(time).then(result => {
|
|
|
+ const study = [];
|
|
|
+ const exerciseMap = {};
|
|
|
+ result.exerciseList.forEach(row => {
|
|
|
+ exerciseMap[row.title] = row;
|
|
|
+ });
|
|
|
+ study.push({
|
|
|
+ type: 'exercise',
|
|
|
+ total: [
|
|
|
+ { title: '<span>练习和订正</span>', width: 130 },
|
|
|
+ { title: result.exerciseTime ? formatSeconds(result.exerciseTime).replace(/([0-9]+)(m|min|h|hour|s)/g, '<b>$1</b>$2') : '<b>-</b>', width: 90 },
|
|
|
+ { title: `<b>${result.exerciseQuestion || '-'}</b>题`, width: 80 },
|
|
|
+ { title: `超过了<b>${result.exerciseExceed ? formatPercent(result.exerciseExceed.rank, result.exerciseExceed.total) : '-%'}</b>的用户` },
|
|
|
+ ],
|
|
|
+ detail: [
|
|
|
+ { title: '做题数', sc: exerciseMap.sc ? exerciseMap.sc.number : '-', cr: exerciseMap.cr ? exerciseMap.cr.number : '-', rc: exerciseMap.rc ? exerciseMap.rc.number : '-' },
|
|
|
+ { title: '平均正确率', sc: exerciseMap.sc ? formatPercent(exerciseMap.sc.correct, exerciseMap.sc.number) : '-%', cr: exerciseMap.cr ? formatPercent(exerciseMap.cr.correct, exerciseMap.cr.number) : '-%', rc: exerciseMap.rc ? formatPercent(exerciseMap.rc.correct, exerciseMap.rc.number) : '-%' },
|
|
|
+ { title: '平均用时', sc: exerciseMap.sc ? exerciseMap.sc.time / exerciseMap.sc.number : '-', cr: exerciseMap.cr ? exerciseMap.cr.time / exerciseMap.cr.number : '-', rc: exerciseMap.rc ? exerciseMap.rc.time / exerciseMap.rc.number : '-' },
|
|
|
+ ],
|
|
|
+ });
|
|
|
+ this.setState({ study });
|
|
|
+ });
|
|
|
+ this.setState({ day: value, time, showCal: false });
|
|
|
}
|
|
|
|
|
|
renderView() {
|
|
@@ -175,8 +231,8 @@ export default class extends Page {
|
|
|
}
|
|
|
|
|
|
renderLog() {
|
|
|
- const { logList = [] } = this.state;
|
|
|
- const { latest = {}, diff = 0, diffPercent = 0, diffLast = 0, diffLastPercent = 0, day, time } = this.state;
|
|
|
+ const { study = [] } = this.state;
|
|
|
+ const { latest = {}, diff = 0, diffPercent = 0, diffLast = 0, diffLastPercent = 0, day, time, showCal } = this.state;
|
|
|
return (
|
|
|
<div className="log-layout">
|
|
|
<div className="header">
|
|
@@ -197,8 +253,7 @@ export default class extends Page {
|
|
|
type="tag"
|
|
|
width={54}
|
|
|
space={5}
|
|
|
-<<<<<<< HEAD
|
|
|
- value={day}
|
|
|
+ active={day}
|
|
|
tabs={[{ title: '今天', key: 'today' }, { title: '昨天', key: 'yesterday' }, { title: '前天', key: 'before' }]}
|
|
|
onChange={(value) => {
|
|
|
this.refreshDay(value);
|
|
@@ -209,15 +264,12 @@ export default class extends Page {
|
|
|
<Assets className="right" name="calendar" onClick={() => {
|
|
|
this.setState({ showCal: true });
|
|
|
}} />
|
|
|
+ {showCal && <Calendar className="cal" fullscreen={false} disabledDate={date => date.unix() <= moment.unix()} onSelect={(date) => {
|
|
|
+ this.refreshDay(date);
|
|
|
+ }} />}
|
|
|
</div>
|
|
|
-=======
|
|
|
- value={'1'}
|
|
|
- tabs={[{ title: '123', key: '1' }, { title: '123', key: '1' }, { title: '123', key: '1' }]}
|
|
|
- />
|
|
|
- <Assets className="right" name="calendar" />
|
|
|
->>>>>>> 56361e65e19d9288d1bd8eda36fef496dccddbcc
|
|
|
</div>
|
|
|
- {logList.map((log, index) => {
|
|
|
+ {study.map((log, index) => {
|
|
|
return <LogItem key={index} data={log} />;
|
|
|
})}
|
|
|
</div>
|