1
0

page.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  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 { formatPercent, formatDate, formatSeconds, getMap } from '@src/services/Tools';
  8. import { asyncSMessage } from '@src/services/AsyncTools';
  9. import moment from 'moment';
  10. import Date from '../../../components/Date';
  11. import UserLayout from '../../../layouts/User';
  12. import Tabs from '../../../components/Tabs';
  13. import Button from '../../../components/Button';
  14. import { Icon as GIcon } from '../../../components/Icon';
  15. import UserTable from '../../../components/UserTable';
  16. import Examination from '../../../components/Examination';
  17. import menu from '../index';
  18. import { BindPhone, BindEmail, EditInfo, RealAuth, EditAvatar, InviteModal } from '../../../components/OtherModal';
  19. import VipRenew from '../../../components/VipRenew';
  20. import { My } from '../../../stores/my';
  21. import { Main } from '../../../stores/main';
  22. import { QuestionType } from '../../../../Constant';
  23. const QuestionTypeMap = getMap(QuestionType, 'value', 'label');
  24. class LogItem extends Component {
  25. constructor(props) {
  26. super(props);
  27. this.columns = [
  28. { title: '', key: 'title' },
  29. { title: '语法SC', key: 'sc' },
  30. { title: '逻辑CR', key: 'cr' },
  31. { title: '阅读RC', key: 'rc' },
  32. ];
  33. this.state = { open: false, showTop: true };
  34. }
  35. render() {
  36. const { data = {} } = this.props;
  37. const { total = [], type } = data;
  38. const { open } = this.state;
  39. return (
  40. <div className="log-item">
  41. <div className="total">
  42. {total.map(item => {
  43. return (
  44. <div className="text" style={{ width: item.width }} dangerouslySetInnerHTML={{ __html: item.title }} />
  45. );
  46. })}
  47. </div>
  48. <div className="open">
  49. <GIcon name={open ? 'small-up' : 'small-down'} onClick={() => this.setState({ open: !open })} />
  50. </div>
  51. {type === 'exercise' && this.renderExercise()}
  52. {type === 'examination' && this.renderExamination()}
  53. {type === 'course' && this.renderCourse()}
  54. </div>
  55. );
  56. }
  57. renderExercise() {
  58. const { data } = this.props;
  59. const { detail = [] } = data;
  60. const { open } = this.state;
  61. return (
  62. <div hidden={!open} className="table">
  63. <UserTable size="small" columns={this.columns} data={detail} />
  64. <div className="t-r">
  65. <Link to="/exercise">继续练习></Link>
  66. </div>
  67. </div>
  68. );
  69. }
  70. renderExamination() {
  71. const { data } = this.props;
  72. const { detail = [] } = data;
  73. const { open } = this.state;
  74. return (
  75. <div hidden={!open} className="table">
  76. {detail.map(row => {
  77. return [
  78. <div className="title p-l-5 m-b-1 t-1 t-s-18 f-w-b">
  79. {row.title}<div className="f-r t-3 t-s-12 f-w-d">{row.time}</div>
  80. </div>,
  81. <UserTable
  82. size="small"
  83. columns={[
  84. { key: '', title: '', render: () => '得分/排名' },
  85. { key: 'total', title: 'Total', render: (text, record) => `${record.totalScore}/${record.totalRank}th` },
  86. { key: 'ir', title: 'IR', render: (text, record) => `${record.irScore}/${record.irRank}th` },
  87. { key: '4', title: 'Verbal', render: (text, record) => `${record.verbalScore}/${record.verbalRank}th` },
  88. { key: '5', title: 'Quant', render: (text, record) => `${record.quantScore}/${record.quantRank}th` },
  89. ]}
  90. data={[row.score]}
  91. />];
  92. })}
  93. <div className="t-r">
  94. <Link to="/examination">继续练习></Link>
  95. </div>
  96. </div>
  97. );
  98. }
  99. renderCourse() {
  100. const { data } = this.props;
  101. const { detail = [] } = data;
  102. const { open } = this.state;
  103. return (
  104. <div hidden={!open} className="table">
  105. <UserTable
  106. header={false}
  107. size="small"
  108. even="odd"
  109. columns={[
  110. { key: 'type', width: 100 },
  111. { key: 'title', width: 310 },
  112. {
  113. key: 'time',
  114. width: 120,
  115. render: (text) => {
  116. return <div className="sub">
  117. <div className="t-2 t-s-12">{text.split(' ')[0]}</div>
  118. <div className="t-6 t-s-12">{text.split(' ')[1]}</div>
  119. </div>;
  120. },
  121. }]}
  122. data={detail}
  123. />
  124. <div className="t-r">
  125. {data.isCourse ? <Link to="/my/course">{'继续学习>'}</Link> : <Link to="/course">{'去购买'}</Link>}
  126. </div>
  127. </div>
  128. );
  129. }
  130. }
  131. export default class extends Page {
  132. constructor(props) {
  133. super(props);
  134. this.colors = ['#3C39CC', '#9E9CFF', '#4292F0', '#4374EC', '#6865FD', '#8D65FD', '#6BABF6', '#7BBEFF', '#6BABF6'];
  135. }
  136. initState() {
  137. return {
  138. day: 'today',
  139. showExamination: false,
  140. timeList: [
  141. { title: '长难句', time: '3h60min', ratio: 10, color: '#3C39CC' },
  142. { title: '综合推理IR', time: '3h60min', ratio: 10, color: '#9E9CFF' },
  143. { title: '语法SC', time: '3h60min', ratio: 10, color: '#4292F0' },
  144. { title: '作文AWA', time: '3h60min', ratio: 10, color: '#4374EC' },
  145. { title: '阅读RC', time: '3h60min', ratio: 10, color: '#6865FD' },
  146. { title: '模考', time: '3h60min', ratio: 10, color: '#8D65FD' },
  147. { title: '逻辑CR', time: '3h60min', ratio: 10, color: '#6BABF6' },
  148. { title: '自由组卷', time: '3h60min', ratio: 10, color: '#7BBEFF' },
  149. { title: '数学Quant', time: '3h60min', ratio: 10, color: '#6BABF6' },
  150. ],
  151. logList: [
  152. {
  153. total: [
  154. { title: '<span>练习和订正</span>', width: 130 },
  155. { title: '<b>60</b>min', width: 90 },
  156. { title: '<b>30</b>题', width: 80 },
  157. { title: '超过了<b>30%</b>的用户' },
  158. ],
  159. detail: [
  160. { title: '做题数', sc: '10', cr: '10', rc: '20' },
  161. { title: '平均正确率', sc: '86%', cr: '86%', rc: '86%' },
  162. { title: '平均用时', sc: '1min', cr: '1min20s', rc: '1min' },
  163. ],
  164. },
  165. {
  166. total: [
  167. { title: '<span>模考和订正</span>', width: 130 },
  168. { title: '<b>60</b>min', width: 90 },
  169. { title: '<b>30</b>套卷', width: 80 },
  170. { title: '超过了<b>30%</b>的用户' },
  171. ],
  172. detail: [
  173. { title: '做题数', sc: '10', cr: '10', rc: '20' },
  174. { title: '平均正确率', sc: '86%', cr: '86%', rc: '86%' },
  175. { title: '平均用时', sc: '1min', cr: '1min20s', rc: '1min' },
  176. ],
  177. },
  178. {
  179. total: [
  180. { title: '<span>课程学习</span>', width: 130 },
  181. { title: '<b>60</b>min', width: 90 },
  182. { title: '<b>30</b>课', width: 80 },
  183. { title: '超过了<b>30%</b>的用户' },
  184. ],
  185. detail: [
  186. { title: '做题数', sc: '10', cr: '10', rc: '20' },
  187. { title: '平均正确率', sc: '86%', cr: '86%', rc: '86%' },
  188. { title: '平均用时', sc: '1min', cr: '1min20s', rc: '1min' },
  189. ],
  190. },
  191. ],
  192. };
  193. }
  194. initData() {
  195. // 获取学习数据
  196. My.getStudyTotal().then((total) => {
  197. total.categorys = total.categorys.map((row, index) => {
  198. row.ratio = (row.time * 100) / total.time;
  199. row.time = formatSeconds(row.time);
  200. row.color = this.colors[index];
  201. return row;
  202. });
  203. this.setState({ total });
  204. });
  205. My.getStudyWeek(0).then(latest => {
  206. const diff = latest.time - latest.avgTime;
  207. const diffPercent =
  208. diff > 0
  209. ? formatPercent(latest.time - latest.avgTime, latest.avgTime, true)
  210. : formatPercent(latest.avgTime - latest.time, latest.avgTime, true);
  211. this.setState({ latest, diff, diffPercent });
  212. My.getStudyWeek(1).then(last => {
  213. const diffLast = latest.time - last.time;
  214. const diffLastPercent =
  215. diffLast > 0
  216. ? formatPercent(latest.time - last.time, last.time, true)
  217. : formatPercent(last.time - latest.time, last.time, true);
  218. this.setState({ last, diffLast, diffLastPercent });
  219. });
  220. });
  221. // 获取广告
  222. Main.getAd('my-self').then(result => {
  223. this.setState({ ads: result });
  224. });
  225. // 获取未读消息
  226. My.message({ page: 1, size: 2, read: 0 }).then(result => {
  227. this.setState({ messages: result.list });
  228. });
  229. this.refreshDay(this.state.day);
  230. }
  231. readAllMessage() {
  232. My.readAllMessage().then(() => {
  233. asyncSMessage('操作成功');
  234. });
  235. }
  236. refreshDay(value) {
  237. let time = '';
  238. switch (value) {
  239. case 'today':
  240. time = moment().format('YYYY-MM-DD');
  241. break;
  242. case 'yesterday':
  243. time = moment()
  244. .add(-1, 'days')
  245. .format('YYYY-MM-DD');
  246. break;
  247. case 'before':
  248. time = moment()
  249. .add(-2, 'days')
  250. .format('YYYY-MM-DD');
  251. break;
  252. default:
  253. time = value.format('YYYY-MM-DD');
  254. value = 'other';
  255. }
  256. My.getStudy(time).then(result => {
  257. const study = [];
  258. const exerciseMap = {};
  259. result.exerciseList.forEach(row => {
  260. exerciseMap[row.title] = row;
  261. });
  262. study.push({
  263. type: 'exercise',
  264. total: [
  265. { title: '<span>练习和订正</span>', width: 130 },
  266. {
  267. title: result.exerciseTime
  268. ? formatSeconds(result.exerciseTime).replace(/([0-9]+)(m|min|h|hour|s)/g, '<b>$1</b>$2')
  269. : '<b>-</b>',
  270. width: 90,
  271. },
  272. { title: `<b>${result.exerciseQuestion || '-'}</b>题`, width: 80 },
  273. {
  274. title: `超过了<b>${result.exerciseExceed ? formatPercent(result.exerciseExceed.rank, result.exerciseExceed.total) : '-%'}</b>的用户`,
  275. },
  276. ],
  277. detail: [
  278. {
  279. title: '做题数',
  280. sc: exerciseMap.sc ? exerciseMap.sc.number : '-',
  281. cr: exerciseMap.cr ? exerciseMap.cr.number : '-',
  282. rc: exerciseMap.rc ? exerciseMap.rc.number : '-',
  283. },
  284. {
  285. title: '平均正确率',
  286. sc: exerciseMap.sc ? formatPercent(exerciseMap.sc.correct, exerciseMap.sc.number) : '-%',
  287. cr: exerciseMap.cr ? formatPercent(exerciseMap.cr.correct, exerciseMap.cr.number) : '-%',
  288. rc: exerciseMap.rc ? formatPercent(exerciseMap.rc.correct, exerciseMap.rc.number) : '-%',
  289. },
  290. {
  291. title: '平均用时',
  292. sc: exerciseMap.sc ? exerciseMap.sc.time / exerciseMap.sc.number : '-',
  293. cr: exerciseMap.cr ? exerciseMap.cr.time / exerciseMap.cr.number : '-',
  294. rc: exerciseMap.rc ? exerciseMap.rc.time / exerciseMap.rc.number : '-',
  295. },
  296. ],
  297. });
  298. study.push({
  299. type: 'examination',
  300. total: [
  301. { title: '<span>模考和订正</span>', width: 130 },
  302. {
  303. title: result.examinationTime
  304. ? formatSeconds(result.examinationTime).replace(/([0-9]+)(m|min|h|hour|s)/g, '<b>$1</b>$2')
  305. : '<b>-</b>',
  306. width: 90,
  307. },
  308. { title: `<b>${result.examinationPaper || '-'}</b>套卷`, width: 80 },
  309. {
  310. title: `超过了<b>${result.examinationExceed ? formatPercent(result.examinationExceed.rank, result.examinationExceed.total) : '-%'}</b>的用户`,
  311. },
  312. ],
  313. detail: result.examinationList.map(row => {
  314. return {
  315. title: row.title,
  316. time: formatDate(row.report.createTime, 'YYYY-MM-DD HH:mm:ss'),
  317. score: row.report.score,
  318. };
  319. }),
  320. });
  321. study.push({
  322. type: 'course',
  323. total: [
  324. { title: '<span>课程学习</span>', width: 130 },
  325. {
  326. title: result.courseTime
  327. ? formatSeconds(result.courseTime).replace(/([0-9]+)(m|min|h|hour|s)/g, '<b>$1</b>$2')
  328. : '<b>-</b>',
  329. width: 90,
  330. },
  331. { title: `<b>${result.courseNumber || '-'}</b>课时`, width: 80 },
  332. {
  333. title: `超过了<b>${result.courseExceed ? formatPercent(result.courseExceed.rank, result.courseExceed.total) : '-%'}</b>的用户`,
  334. },
  335. ],
  336. detail: result.courseList.map(row => {
  337. return {
  338. type: QuestionTypeMap[row.extend],
  339. title: `课时${row.no}: ${row.title}`,
  340. time: formatDate(row.createTime, 'YYYY-MM-DD HH:mm:ss'),
  341. };
  342. }),
  343. });
  344. this.setState({ study });
  345. });
  346. this.setState({ day: value, time, showCal: false });
  347. }
  348. renderView() {
  349. const { config } = this.props;
  350. return (
  351. <UserLayout
  352. active={config.key}
  353. menu={menu}
  354. center={[this.renderTop(), this.renderLog(), this.renderTime()]}
  355. right={[this.renderInfo(), this.renderVip(), this.renderMessage()]}
  356. ads={(this.state.ads || []).map(row => {
  357. return (
  358. <a href={row.link} target="_blank">
  359. <Assets src={row.image} />
  360. </a>
  361. );
  362. })}
  363. />
  364. );
  365. }
  366. renderTop() {
  367. const { info } = this.props.user;
  368. const { showTop } = this.state;
  369. return !info.bindPrepare && showTop && <div className="top-layout">
  370. <Assets name='my_main_banner' onClick={() => this.setState({ showExamination: true })} />
  371. <div className='close' onClick={() => this.setState({ showTop: false })} />
  372. <div className='go' onClick={() => this.setState({ showExamination: true })} />
  373. </div>;
  374. }
  375. renderLog() {
  376. const { study = [{}, { type: 'examination' }, { type: 'course' }] } = this.state;
  377. const {
  378. latest = {},
  379. diff = 0,
  380. diffPercent = 0,
  381. diffLast = 0,
  382. diffLastPercent = 0,
  383. day,
  384. time,
  385. showCal,
  386. } = this.state;
  387. return (
  388. <div className="log-layout">
  389. <div className="header">
  390. <div className="title">学习记录</div>
  391. <div className="right">
  392. <span
  393. dangerouslySetInnerHTML={{
  394. __html: `本周学习时间${formatSeconds(latest.time).replace(/([0-9]+)(m|min|h|hour|s)/g, '<b>$1</b>$2')}`,
  395. }}
  396. />
  397. <span>
  398. 同比上周<b>{diffLastPercent}</b>% <Assets name={diffLast > 0 ? 'up' : 'down'} />
  399. </span>
  400. <span>
  401. 同比全站<b>{diffPercent}</b>% <Assets name={diff > 0 ? 'up' : 'down'} />
  402. </span>
  403. </div>
  404. </div>
  405. <div className="action">
  406. <Tabs
  407. className="d-i-b"
  408. type="tag"
  409. width={54}
  410. space={5}
  411. active={day}
  412. tabs={[
  413. { title: '今天', key: 'today' },
  414. { title: '昨天', key: 'yesterday' },
  415. { title: '前天', key: 'before' },
  416. ]}
  417. onChange={value => {
  418. this.refreshDay(value);
  419. }}
  420. />
  421. <div className="right">
  422. <Assets
  423. className="right"
  424. name="calendar"
  425. onClick={() => {
  426. this.setState({ showCal: true });
  427. }}
  428. />
  429. {day === 'other' && <span className="right">{formatDate(time, 'YYYY-MM-DD')}</span>}
  430. {showCal && (
  431. <Date
  432. show
  433. hideInput
  434. theme="filled"
  435. value={moment(time)}
  436. disabledDate={date => date.unix() <= moment.unix()}
  437. onChange={date => {
  438. this.refreshDay(date);
  439. }}
  440. />
  441. )}
  442. </div>
  443. </div>
  444. {study.map((data, index) => {
  445. return <LogItem key={index} data={data} />;
  446. })}
  447. </div>
  448. );
  449. }
  450. renderTime() {
  451. const { total = {} } = this.state;
  452. return (
  453. <div className="time-layout">
  454. <div className="header">
  455. <div className="title">
  456. 时间分配
  457. <Tooltip overlayClassName="gray" title="包括听课、练习与订正">
  458. <Icon type="question-circle" theme="filled" />
  459. </Tooltip>
  460. </div>
  461. <div className="right">
  462. 自 {total.createTime && formatDate(total.createTime, 'YYYY-MM-DD')} ,您已在千行学习<b>{total.days}</b>
  463. 天,累计
  464. <span
  465. dangerouslySetInnerHTML={{
  466. __html: formatSeconds(total.time).replace(/([0-9]+)(m|min|h|hour|s)/g, '<b>$1</b>$2'),
  467. }}
  468. />
  469. </div>
  470. </div>
  471. <div className="body">
  472. <div className="line">
  473. {(total.categorys || []).map(item => {
  474. return (
  475. <Tooltip overlayClassName="gray" title={`${item.title} ${item.time}`}>
  476. <i style={{ background: item.color, width: `${item.ratio}%` }} />
  477. </Tooltip>
  478. );
  479. })}
  480. </div>
  481. <div className="list">
  482. {(total.categorys || []).map(item => {
  483. return (
  484. <div className="item">
  485. <div className="color" style={{ background: item.color }} />
  486. <div className="title">{item.title}</div>
  487. <div className="date">{item.time}</div>
  488. </div>
  489. );
  490. })}
  491. </div>
  492. </div>
  493. </div>
  494. );
  495. }
  496. renderInfo() {
  497. const { info = {} } = this.props.user;
  498. const { showExamination, showPhone, showEmail, showEdit, showReal, showAvatar, showInvite, showVip } = this.state;
  499. return (
  500. <div className="info-layout">
  501. <div className="body">
  502. <div className="info c-p">
  503. <Assets
  504. name="sun_blue"
  505. src={info.avatar}
  506. onClick={() => {
  507. this.setState({ showEdit: true });
  508. }}
  509. />
  510. <div className="detail">
  511. <div
  512. className="name c-p"
  513. onClick={() => {
  514. this.setState({ showEdit: true });
  515. }}
  516. >
  517. {info.nickname || `qx${info.mobile}`}{' '}
  518. </div>
  519. <div className="id">ID: {info.id} </div>
  520. </div>
  521. </div>
  522. <div className="auth">
  523. <span className="invite">
  524. <Button
  525. radius
  526. size="small"
  527. onClick={() => {
  528. this.setState({ showInvite: true });
  529. }}
  530. >
  531. 邀请
  532. </Button>
  533. </span>
  534. <GIcon name="user-wechat" noHover active={info.bindWechat} />
  535. <GIcon
  536. name="user-phone"
  537. active={info.bindMobile}
  538. onClick={() => {
  539. this.setState({ showPhone: true });
  540. }}
  541. />
  542. <GIcon
  543. name="user-realname"
  544. active={info.bindReal}
  545. onClick={() => {
  546. this.setState({ showReal: true });
  547. }}
  548. />
  549. <GIcon
  550. name="user-email"
  551. active={!!info.email}
  552. onClick={() => {
  553. this.setState({ showEmail: true });
  554. }}
  555. />
  556. <GIcon
  557. name="user-info"
  558. active={info.bindPrepare}
  559. onClick={() => {
  560. this.setState({ showExamination: true });
  561. }}
  562. />
  563. </div>
  564. {!info.bindReal && <div className="t-3 t-s-12 m-t-1">完成实名认证送6个月VIP <a onClick={() => this.setState({ showReal: true })}>去完成</a></div>}
  565. </div>
  566. {info.vip &&
  567. <div className="footer">
  568. <Assets className="m-r-5" name="VIP" />
  569. {info.vip && <span className="date">{formatDate(info.vip, 'YYYY-MM-DD')}到期</span>}
  570. <a
  571. onClick={() => {
  572. this.setState({ showVip: true });
  573. }}
  574. >
  575. 续费
  576. </a>
  577. </div>
  578. }
  579. <Examination
  580. show={showExamination}
  581. data={info}
  582. onConfirm={() => this.setState({ showExamination: false })}
  583. onCancel={() => this.setState({ showExamination: false })}
  584. onClose={() => this.setState({ showExamination: false })}
  585. />
  586. <BindPhone
  587. show={showPhone}
  588. data={info}
  589. onConfirm={() => this.setState({ showPhone: false })}
  590. onCancel={() => this.setState({ showPhone: false })}
  591. />
  592. <BindEmail
  593. show={showEmail}
  594. data={info}
  595. onConfirm={() => this.setState({ showEmail: false })}
  596. onCancel={() => this.setState({ showEmail: false })}
  597. />
  598. <EditInfo
  599. show={showEdit}
  600. data={info}
  601. image={this.state.avatarFile}
  602. onSelectImage={file => this.setState({ showEdit: false, showAvatar: true, avatarImage: file })}
  603. onConfirm={() => this.setState({ showEdit: false, avatarFile: null })}
  604. onCancel={() => this.setState({ showEdit: false, avatarFile: null })}
  605. />
  606. <RealAuth show={showReal} data={info} onConfirm={() => this.setState({ showReal: false })} />
  607. <EditAvatar
  608. show={showAvatar}
  609. data={info}
  610. crop={{ width: 200, height: 200 }}
  611. image={this.state.avatarImage}
  612. onConfirm={file => this.setState({ showAvatar: false, showEdit: true, avatarFile: file, avatarImage: null })}
  613. onCancel={() => this.setState({ showAvatar: false, showEdit: true, avatarImage: null })}
  614. />
  615. <InviteModal show={showInvite} data={info} onClose={() => this.setState({ showInvite: false })} />
  616. <VipRenew
  617. show={showVip}
  618. data={info}
  619. onReal={() => this.setState({ showVip: false, showReal: true })}
  620. onPrepare={() => this.setState({ showVip: false, showExamination: true })}
  621. onClose={() => this.setState({ showVip: false })}
  622. />
  623. </div>
  624. );
  625. }
  626. renderVip() {
  627. const { info } = this.props.user;
  628. return !info.vip && <div className="vip-layout">
  629. <div className="body">
  630. <div className='m-b-1'>
  631. 开通 <Assets className="m-r-5" name="VIP" />解锁海量权限
  632. </div>
  633. <div className='t d-i-b m-r-2 t-1 t-s-12'><Icon className='t-4' type='check' /> 自由组卷</div>
  634. <div className='t d-i-b m-r-2 t-1 t-s-12'><Icon className='t-4' type='check' /> 导出笔记</div>
  635. <div className='t d-i-b m-r-2 t-1 t-s-12'><Icon className='t-4' type='check' /> 专享解析</div>
  636. <div className='t d-i-b m-r-2 t-1 t-s-12'><Icon className='t-4' type='check' /> 换库提醒</div>
  637. <div className='t d-i-b m-r-2 t-1 t-s-12'><Icon className='t-4' type='check' /> 加强版报告</div>
  638. </div>
  639. <div className="footer">
  640. <Button
  641. radius
  642. size="small"
  643. onClick={() => {
  644. this.setState({ showVip: true });
  645. }}
  646. >
  647. 去开通
  648. </Button>
  649. </div>
  650. </div>;
  651. }
  652. renderMessage() {
  653. const { messages = [] } = this.state;
  654. const number = (messages || []).length;
  655. return (
  656. number > 0 && (
  657. <div className="message-layout">
  658. <div className="header c-p">
  659. <Assets
  660. name="all"
  661. onCancel={() => {
  662. this.readAllMessage();
  663. }}
  664. />
  665. 全部已读
  666. </div>
  667. <div className="body">
  668. {(messages || []).map(row => {
  669. return (
  670. <div className="item">
  671. <div className="title dot">{row.title}</div>
  672. <div className="date">{formatDate(row.createTime, 'YYYY-MM-DD HH:mm:ss')}</div>
  673. {row.link && (
  674. <GIcon
  675. name="arrow-right-small"
  676. onClick={() => {
  677. openLink(row.link);
  678. }}
  679. />
  680. )}
  681. </div>
  682. );
  683. })}
  684. </div>
  685. <div className="footer">
  686. <Button
  687. radius
  688. size="small"
  689. onClick={() => {
  690. linkTo('/my/message');
  691. }}
  692. >
  693. 全部消息
  694. </Button>
  695. </div>
  696. </div>
  697. )
  698. );
  699. }
  700. }