page.js 25 KB

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