page.js 25 KB

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