page.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. import React, { Component } from 'react';
  2. import { Link } from 'react-router-dom';
  3. import './index.less';
  4. import { Tooltip, Icon } from 'antd';
  5. import Page from '@src/containers/Page';
  6. import Assets from '@src/components/Assets';
  7. import UserLayout from '../../../layouts/User';
  8. import Button from '../../../components/Button';
  9. import { Icon as GIcon } from '../../../components/Icon';
  10. import UserTable from '../../../components/UserTable';
  11. import Examination from '../../../components/Examination';
  12. import menu from '../index';
  13. import { BindPhone, BindEmail, EditInfo, RealAuth, EditAvatar, InviteModal } from '../../../components/OtherModal';
  14. import VipRenew from '../../../components/VipRenew';
  15. class LogItem extends Component {
  16. constructor(props) {
  17. super(props);
  18. this.columns = [
  19. { title: '', key: 'title' },
  20. { title: '语法SC', key: 'sc' },
  21. { title: '逻辑CR', key: 'cr' },
  22. { title: '阅读RC', key: 'rc' },
  23. ];
  24. this.state = { open: false };
  25. }
  26. render() {
  27. const { data = {} } = this.props;
  28. const { total = [], detail = [] } = data;
  29. const { open } = this.state;
  30. return (
  31. <div className="log-item">
  32. <div className="total">
  33. {total.map(item => {
  34. return (
  35. <div className="text" style={{ width: item.width }} dangerouslySetInnerHTML={{ __html: item.title }} />
  36. );
  37. })}
  38. </div>
  39. <div className="open">
  40. <GIcon name={open ? 'up' : 'down'} onClick={() => this.setState({ open: !open })} />
  41. </div>
  42. <div hidden={!open} className="table">
  43. <UserTable size="small" columns={this.columns} data={detail} />
  44. <div className="t-r">
  45. <Link to="">继续练习></Link>
  46. </div>
  47. </div>
  48. </div>
  49. );
  50. }
  51. }
  52. export default class extends Page {
  53. initState() {
  54. return {
  55. showExamination: false,
  56. timeList: [
  57. { title: '长难句', time: '3h60min', ratio: 10, color: '#3C39CC' },
  58. { title: '综合推理IR', time: '3h60min', ratio: 10, color: '#9E9CFF' },
  59. { title: '语法SC', time: '3h60min', ratio: 10, color: '#4292F0' },
  60. { title: '作文AWA', time: '3h60min', ratio: 10, color: '#4374EC' },
  61. { title: '阅读RC', time: '3h60min', ratio: 10, color: '#6865FD' },
  62. { title: '模考', time: '3h60min', ratio: 10, color: '#8D65FD' },
  63. { title: '逻辑CR', time: '3h60min', ratio: 10, color: '#6BABF6' },
  64. { title: '自由组卷', time: '3h60min', ratio: 10, color: '#7BBEFF' },
  65. { title: '数学Quant', time: '3h60min', ratio: 10, color: '#6BABF6' },
  66. ],
  67. logList: [
  68. {
  69. total: [
  70. { title: '<span>练习和订正</span>', width: 130 },
  71. { title: '<b>60</b>min', width: 90 },
  72. { title: '<b>30</b>题', width: 80 },
  73. { title: '超过了<b>30%</b>的用户' },
  74. ],
  75. detail: [
  76. { title: '做题数', sc: '10', cr: '10', rc: '20' },
  77. { title: '平均正确率', sc: '86%', cr: '86%', rc: '86%' },
  78. { title: '平均用时', sc: '1min', cr: '1min20s', rc: '1min' },
  79. ],
  80. },
  81. {
  82. total: [
  83. { title: '<span>模考和订正</span>', width: 130 },
  84. { title: '<b>60</b>min', width: 90 },
  85. { title: '<b>30</b>套卷', width: 80 },
  86. { title: '超过了<b>30%</b>的用户' },
  87. ],
  88. detail: [
  89. { title: '做题数', sc: '10', cr: '10', rc: '20' },
  90. { title: '平均正确率', sc: '86%', cr: '86%', rc: '86%' },
  91. { title: '平均用时', sc: '1min', cr: '1min20s', rc: '1min' },
  92. ],
  93. },
  94. {
  95. total: [
  96. { title: '<span>课程学习</span>', width: 130 },
  97. { title: '<b>60</b>min', width: 90 },
  98. { title: '<b>30</b>课', width: 80 },
  99. { title: '超过了<b>30%</b>的用户' },
  100. ],
  101. detail: [
  102. { title: '做题数', sc: '10', cr: '10', rc: '20' },
  103. { title: '平均正确率', sc: '86%', cr: '86%', rc: '86%' },
  104. { title: '平均用时', sc: '1min', cr: '1min20s', rc: '1min' },
  105. ],
  106. },
  107. ],
  108. };
  109. }
  110. renderView() {
  111. const { config } = this.props;
  112. return (
  113. <UserLayout
  114. active={config.key}
  115. menu={menu}
  116. center={[this.renderTotal(), this.renderLog(), this.renderTime()]}
  117. right={[this.renderInfo(), this.renderMessage()]}
  118. />
  119. );
  120. }
  121. renderTotal() {
  122. return <div className="total-layout">1</div>;
  123. }
  124. renderLog() {
  125. const { logList = [] } = this.state;
  126. return (
  127. <div className="log-layout">
  128. <div className="header">
  129. <div className="title">学习记录</div>
  130. <div className="right">
  131. <span>
  132. 本周学习时间<b>23</b>Hour
  133. </span>
  134. <span>
  135. 同比上周<b>15</b>%
  136. </span>
  137. <span>
  138. 同比全站<b>15</b>%
  139. </span>
  140. </div>
  141. </div>
  142. <div className="action">
  143. <Button size="small" radius>
  144. 今天
  145. </Button>
  146. <Button size="small" radius>
  147. 昨天
  148. </Button>
  149. <Button size="small" radius>
  150. 前天
  151. </Button>
  152. <Assets className="right" name="calculator_icon" />
  153. </div>
  154. {logList.map((log, index) => {
  155. return <LogItem key={index} data={log} />;
  156. })}
  157. </div>
  158. );
  159. }
  160. renderTime() {
  161. const { timeList = [] } = this.state;
  162. return (
  163. <div className="time-layout">
  164. <div className="header">
  165. <div className="title">
  166. 时间分配
  167. <Tooltip overlayClassName="gray" title="包括听课、练习与订正">
  168. <Icon type="question-circle" theme="filled" />
  169. </Tooltip>
  170. </div>
  171. <div className="right">
  172. 自 2019-05-26 ,您已在千行学习<b>23</b>天,累计 <b>32h</b> 30min
  173. </div>
  174. </div>
  175. <div className="body">
  176. <div className="line">
  177. {timeList.map(item => {
  178. return (
  179. <Tooltip overlayClassName="gray" title={`${item.title} ${item.time}`}>
  180. <i style={{ background: item.color, width: `${item.ratio}%` }} />
  181. </Tooltip>
  182. );
  183. })}
  184. </div>
  185. <div className="list">
  186. {timeList.map(item => {
  187. return (
  188. <div className="item">
  189. <div className="color" style={{ background: item.color }} />
  190. <div className="title">{item.title}</div>
  191. <div className="date">{item.time}</div>
  192. </div>
  193. );
  194. })}
  195. </div>
  196. </div>
  197. </div>
  198. );
  199. }
  200. renderInfo() {
  201. const { showExamination } = this.state;
  202. return (
  203. <div className="info-layout">
  204. <div className="body">
  205. <div className="info">
  206. <Assets name="sun_blue" />
  207. <div className="detail">
  208. <div className="name">怕死的胡萝卜 </div>
  209. <div className="id">ID: 2392401 </div>
  210. </div>
  211. </div>
  212. <div className="auth">
  213. <span className="invite">
  214. <Button radius size="small">
  215. 邀请
  216. </Button>
  217. </span>
  218. </div>
  219. </div>
  220. <div className="footer">
  221. <span className="tag">VIP</span>
  222. <span className="date">2019-10-15到期</span>
  223. <Link to="">续费</Link>
  224. </div>
  225. <Examination
  226. show={showExamination}
  227. onConfirm={() => this.setState({ showExamination: false })}
  228. onCancel={() => this.setState({ showExamination: false })}
  229. onClose={() => this.setState({ showExamination: false })}
  230. />
  231. <BindPhone
  232. onConfirm={() => this.setState({ showPhone: false })}
  233. onCancel={() => this.setState({ showPhone: false })}
  234. />
  235. <BindEmail
  236. onConfirm={() => this.setState({ showEmail: false })}
  237. onCancel={() => this.setState({ showEmail: false })}
  238. />
  239. <EditInfo
  240. onConfirm={() => this.setState({ showEdit: false })}
  241. onCancel={() => this.setState({ showEdit: false })}
  242. />
  243. <RealAuth onConfirm={() => this.setState({ showReal: false })} />
  244. <EditAvatar
  245. onConfirm={() => this.setState({ showAvatar: false })}
  246. onCancel={() => this.setState({ showAvatar: false })}
  247. />
  248. <InviteModal onClose={() => this.setState({ showInvite: false })} />
  249. <VipRenew onClose={() => this.setState({ showVip: false })} />
  250. </div>
  251. );
  252. }
  253. renderMessage() {
  254. return (
  255. <div className="message-layout">
  256. <div className="header">
  257. <Assets name="dot2" />
  258. 全部已读
  259. </div>
  260. <div className="body">
  261. <div className="item">
  262. <div className="title dot">老师回答了您的提问</div>
  263. <div className="date">2019-05-15 16:21:06</div>
  264. <Assets name="right_icon" onClick={() => {}} />
  265. </div>
  266. <div className="item">
  267. <div className="title dot">老师回答了您的提问</div>
  268. <div className="date">2019-05-15 16:21:06</div>
  269. </div>
  270. </div>
  271. <div className="footer">
  272. <Button radius size="small">
  273. 全部消息
  274. </Button>
  275. </div>
  276. </div>
  277. );
  278. }
  279. }