page.js 26 KB

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