page.js 25 KB

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