1
0

page.js 25 KB

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