import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import './index.less';
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 menu from '../index';
import { BindPhone, BindEmail, EditInfo, RealAuth, EditAvatar, InviteModal } from '../../../components/OtherModal';
import VipRenew from '../../../components/VipRenew';
import { My } from '../../../stores/my';
import { Main } from '../../../stores/main';
class LogItem extends Component {
constructor(props) {
super(props);
this.columns = [
{ title: '', key: 'title' },
{ title: '语法SC', key: 'sc' },
{ title: '逻辑CR', key: 'cr' },
{ title: '阅读RC', key: 'rc' },
];
this.state = { open: false };
}
render() {
const { data = {} } = this.props;
const { total = [], type } = data;
const { open } = this.state;
return (
{total.map(item => {
return (
);
})}
this.setState({ open: !open })} />
{type === 'exercise' && this.renderExercise()}
{type === 'examination' && this.renderExamination()}
{type === 'course' && this.renderCourse()}
);
}
renderExercise() {
const { open } = this.state;
return (
);
}
renderExamination() {
const { open } = this.state;
return (
千行-CAT01
2019-05-16 16:21:06
净化版GWD-CAT01
2019-05-16 16:21:06
继续练习>
);
}
renderCourse() {
const { open } = this.state;
return (
);
}
}
export default class extends Page {
initState() {
return {
day: 'today',
showExamination: false,
timeList: [
{ title: '长难句', time: '3h60min', ratio: 10, color: '#3C39CC' },
{ title: '综合推理IR', time: '3h60min', ratio: 10, color: '#9E9CFF' },
{ title: '语法SC', time: '3h60min', ratio: 10, color: '#4292F0' },
{ title: '作文AWA', time: '3h60min', ratio: 10, color: '#4374EC' },
{ title: '阅读RC', time: '3h60min', ratio: 10, color: '#6865FD' },
{ title: '模考', time: '3h60min', ratio: 10, color: '#8D65FD' },
{ title: '逻辑CR', time: '3h60min', ratio: 10, color: '#6BABF6' },
{ title: '自由组卷', time: '3h60min', ratio: 10, color: '#7BBEFF' },
{ title: '数学Quant', time: '3h60min', ratio: 10, color: '#6BABF6' },
],
logList: [
{
total: [
{ title: '练习和订正', width: 130 },
{ title: '60min', width: 90 },
{ title: '30题', width: 80 },
{ title: '超过了30%的用户' },
],
detail: [
{ title: '做题数', sc: '10', cr: '10', rc: '20' },
{ title: '平均正确率', sc: '86%', cr: '86%', rc: '86%' },
{ title: '平均用时', sc: '1min', cr: '1min20s', rc: '1min' },
],
},
{
total: [
{ title: '模考和订正', width: 130 },
{ title: '60min', width: 90 },
{ title: '30套卷', width: 80 },
{ title: '超过了30%的用户' },
],
detail: [
{ title: '做题数', sc: '10', cr: '10', rc: '20' },
{ title: '平均正确率', sc: '86%', cr: '86%', rc: '86%' },
{ title: '平均用时', sc: '1min', cr: '1min20s', rc: '1min' },
],
},
{
total: [
{ title: '课程学习', width: 130 },
{ title: '60min', width: 90 },
{ title: '30课', width: 80 },
{ title: '超过了30%的用户' },
],
detail: [
{ title: '做题数', sc: '10', cr: '10', rc: '20' },
{ title: '平均正确率', sc: '86%', cr: '86%', rc: '86%' },
{ title: '平均用时', sc: '1min', cr: '1min20s', rc: '1min' },
],
},
],
};
}
initData() {
// 获取学习数据
My.getStudyTotal().then(total => {
this.setState({ total });
});
My.getStudyWeek(0).then(latest => {
const diff = latest.time - latest.avgTime;
const diffPercent =
diff > 0
? formatPercent(latest.time - latest.avgTime, latest.avgTime, true)
: formatPercent(latest.avgTime - latest.time, latest.avgTime, true);
this.setState({ latest, diff, diffPercent });
My.getStudyWeek(1).then(last => {
const diffLast = latest.time - last.time;
const diffLastPercent =
diffLast > 0
? formatPercent(latest.time - last.time, last.time, true)
: formatPercent(last.time - latest.time, last.time, true);
this.setState({ last, diffLast, diffLastPercent });
});
});
// 获取广告
Main.getAd('my-self').then(result => {
this.setState({ ads: result });
});
// 获取未读消息
My.message({ page: 1, size: 2, read: 0 }).then(result => {
this.setState({ messages: result.list });
});
this.refreshDay(this.state.day);
}
readAllMessage() {
My.readAllMessage().then(() => {
asyncSMessage('操作成功');
});
}
refreshDay(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: '练习和订正', width: 130 },
{
title: result.exerciseTime
? formatSeconds(result.exerciseTime).replace(/([0-9]+)(m|min|h|hour|s)/g, '$1$2')
: '-',
width: 90,
},
{ title: `${result.exerciseQuestion || '-'}题`, width: 80 },
{
title: `超过了${
result.exerciseExceed ? formatPercent(result.exerciseExceed.rank, result.exerciseExceed.total) : '-%'
}的用户`,
},
],
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() {
const { config } = this.props;
return (
{
return (
);
})}
/>
);
}
renderTop() {
return null; // 1
;
}
renderLog() {
const { study = [{}, { type: 'examination' }, { type: 'course' }] } = this.state;
const {
latest = {},
diff = 0,
diffPercent = 0,
diffLast = 0,
diffLastPercent = 0,
day,
time,
showCal,
} = this.state;
return (
学习记录
$1$2')}`,
}}
/>
同比上周{diffLastPercent}% 0 ? 'up' : 'down'} />
同比全站{diffPercent}% 0 ? 'up' : 'down'} />
{
this.refreshDay(value);
}}
/>
{day === 'other' && formatDate(time, 'YYYY-MM-DD')}
{
this.setState({ showCal: true });
}}
/>
{showCal && (
date.unix() <= moment.unix()}
onSelect={date => {
this.refreshDay(date);
}}
/>
)}
{study.map((log, index) => {
return
;
})}
);
}
renderTime() {
const { timeList = [], total = {} } = this.state;
return (
时间分配
自 {total.createTIme && formatDate(total.createTime, 'YYYY-MM-DD')} ,您已在千行学习{total.days}
天,累计
$1$2'),
}}
/>
{timeList.map(item => {
return (
);
})}
{timeList.map(item => {
return (
);
})}
);
}
renderInfo() {
const { info = {} } = this.props.user;
const { showExamination, showPhone, showEmail, showEdit, showReal, showAvatar, showInvite, showVip } = this.state;
return (
{
this.setState({ showEdit: true });
}}
/>
{
this.setState({ showEdit: true });
}}
>
{info.nickname}{' '}
ID: {info.id}
{
this.setState({ showPhone: true });
}}
/>
{
this.setState({ showReal: true });
}}
/>
{
this.setState({ showEmail: true });
}}
/>
{
this.setState({ showExamination: true });
}}
/>
{
}
this.setState({ showExamination: false })}
onCancel={() => this.setState({ showExamination: false })}
onClose={() => this.setState({ showExamination: false })}
/>
this.setState({ showPhone: false })}
onCancel={() => this.setState({ showPhone: false })}
/>
this.setState({ showEmail: false })}
onCancel={() => this.setState({ showEmail: false })}
/>
this.setState({ showEdit: false, showAvatar: true, avatarImage: file })}
onConfirm={() => this.setState({ showEdit: false, avatarFile: null })}
onCancel={() => this.setState({ showEdit: false, avatarFile: null })}
/>
this.setState({ showReal: false })} />
this.setState({ showAvatar: false, showEdit: true, avatarFile: file, avatarImage: null })}
onCancel={() => this.setState({ showAvatar: false, showEdit: true, avatarImage: null })}
/>
this.setState({ showInvite: false })} />
this.setState({ showVip: false, showReal: true })}
onPrepare={() => this.setState({ showVip: false, showExamination: true })}
onClose={() => this.setState({ showVip: false })}
/>
);
}
renderMessage() {
const { messages = [] } = this.state;
const number = (messages || []).length;
return (
number > 0 && (
{
this.readAllMessage();
}}
/>
全部已读
{(messages || []).map(row => {
return (
老师回答了您的提问
{formatDate(row.createTime, 'YYYY-MM-DD HH:mm:ss')}
{row.link && (
{
openLink(row.link);
}}
/>
)}
);
})}
)
);
}
}