page.js 8.1 KB

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