page.js 25 KB

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