1
0

page.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863
  1. import React from 'react';
  2. import './index.less';
  3. import { Icon } from 'antd';
  4. import Page from '@src/containers/Page';
  5. import Assets from '@src/components/Assets';
  6. import { asyncSMessage } from '@src/services/AsyncTools';
  7. import { formatDate, getMap } from '@src/services/Tools';
  8. import UserLayout from '../../../layouts/User';
  9. import UserAction from '../../../components/UserAction';
  10. import menu from '../index';
  11. import Tabs from '../../../components/Tabs';
  12. import More from '../../../components/More';
  13. import Button from '../../../components/Button';
  14. import Switch from '../../../components/Switch';
  15. import TotalSort from '../../../components/TotalSort';
  16. import { RealAuth } from '../../../components/OtherModal';
  17. import Examination from '../../../components/Examination';
  18. import VipRenew from '../../../components/VipRenew';
  19. import Modal from '../../../components/Modal';
  20. import UserTable from '../../../components/UserTable';
  21. import UserPagination from '../../../components/UserPagination';
  22. import { My } from '../../../stores/my';
  23. import { User } from '../../../stores/user';
  24. import { Order } from '../../../stores/order';
  25. import { Textbook } from '../../../stores/textbook';
  26. import { DataType, ServiceKey, RecordSource, TextbookFeedbackTarget } from '../../../../Constant';
  27. import { Main } from '../../../stores/main';
  28. import { Question } from '../../../stores/question';
  29. import Select from '../../../components/Select';
  30. const ServiceKeyMap = getMap(ServiceKey, 'value', 'label');
  31. const RecordSourceMap = getMap(RecordSource, 'value', 'label');
  32. const TextbookFeedbackTargetMap = getMap(TextbookFeedbackTarget, 'value', 'tips');
  33. const dataHistoryColumns = [
  34. { title: '更新时间', key: 'time', width: 120 },
  35. { title: '位置', key: 'position', width: 120 },
  36. { title: '原内容', key: 'originContent', width: 120 },
  37. { title: '更改为', key: 'content', width: 120 },
  38. { title: '更新至', key: 'version', width: 90 },
  39. ];
  40. const textbookHistoryColumns = [
  41. {
  42. title: '更新时间',
  43. key: 'createTime',
  44. width: 120,
  45. render: (text) => {
  46. return <div className="sub">
  47. <div className="t-2 t-s-12">{text.split(' ')[0]}</div>
  48. <div className="t-6 t-s-12">{text.split(' ')[1]}</div>
  49. </div>;
  50. },
  51. },
  52. { title: '版本', key: 'version', width: 120 },
  53. { title: '更新内容', key: 'content', width: 330 },
  54. ];
  55. const openColumns = [
  56. { title: '商品名称', key: 'title', width: 240 },
  57. { title: '获取方式', key: 'source', width: 240 },
  58. { title: '开通期限', key: 'endTime', width: 240 },
  59. { title: '操作', key: 'handler', width: 90 },
  60. ];
  61. export default class extends Page {
  62. constructor(props) {
  63. props.size = 10;
  64. super(props);
  65. }
  66. initState() {
  67. return {
  68. tab: 'data',
  69. sortMap: {},
  70. filterMap: {},
  71. feedbackError: { position: ['', '', ''] },
  72. };
  73. }
  74. initData() {
  75. const data = Object.assign(this.state, this.state.search);
  76. if (data.order) {
  77. data.sortMap = { [data.order]: data.direction };
  78. }
  79. data.filterMap = this.state.search;
  80. this.setState(data);
  81. const { tab } = this.state;
  82. switch (tab) {
  83. case 'textbook':
  84. this.refreshTextbook();
  85. break;
  86. case 'examination':
  87. this.refreshExamination();
  88. break;
  89. case 'vip':
  90. this.refreshVip();
  91. break;
  92. case 'cal':
  93. break;
  94. case 'data':
  95. default:
  96. this.refreshData();
  97. break;
  98. }
  99. }
  100. refreshTextbook() {
  101. Main.getService('textbook').then(result => {
  102. this.setState({ service: result });
  103. });
  104. Textbook.getInfo().then(result => {
  105. const { latest } = result;
  106. result.day = parseInt((new Date().getTime() - new Date(result.latest.startDate).getTime()) / 86400000, 10);
  107. result.expireDay =
  108. result.expireTime && parseInt((new Date(result.expireTime).getTime() - new Date().getTime()) / 86400000, 10);
  109. const list = [];
  110. list.push({ subject: 'quant', number: latest.quantNumber, time: latest.quantTime, version: latest.quantVersion });
  111. list.push({ subject: 'rc', number: latest.rcNumber, time: latest.rcTime, version: latest.rcVersion });
  112. list.push({ subject: 'ir', number: latest.irNumber, time: latest.irTime, version: latest.irVersion });
  113. this.setState({ data: result, list });
  114. });
  115. }
  116. textbookHistory({ page, size, subject }) {
  117. Textbook.allHistory(subject).then(result => {
  118. this.setState({
  119. showUpdate: true,
  120. updateList: result.map(row => {
  121. row.version = row[`${subject}Version`];
  122. row.content = row[`${subject}Content`];
  123. row.createTime = formatDate(row.createTime, 'YYYY-MM-DD HH:mm:ss');
  124. return row;
  125. }),
  126. // 不显示分页
  127. updateTotal: 0,
  128. maxHeight: 730,
  129. updatePage: page,
  130. updateData: { page, size, subject, columns: textbookHistoryColumns, type: 'textbook' },
  131. });
  132. });
  133. }
  134. refreshExamination() {
  135. Main.getService('qx_cat').then(result => {
  136. this.setState({ service: result });
  137. });
  138. Question.getExaminationInfo(result => {
  139. result.expireDay =
  140. result.expireTime && parseInt((new Date().getTime() - new Date(result.expireTime).getTime()) / 86400000, 10);
  141. this.setState({ data: result });
  142. });
  143. }
  144. refreshVip() {
  145. Main.getService('vip').then(result => {
  146. this.setState({ service: result });
  147. });
  148. My.getVipInfo().then(result => {
  149. this.setState({ data: result });
  150. });
  151. }
  152. recordList({ page, size, service, isUse, isExpire }) {
  153. Order.listRecord({ page, size, productType: 'service', service, isUse, isExpire }).then(result => {
  154. this.setState({
  155. showUpdate: true,
  156. updateList: result.list.map(row => {
  157. row.title = ServiceKeyMap[service];
  158. row.source = RecordSourceMap[row.source];
  159. row.handler = (
  160. <a
  161. onClick={() => {
  162. this.open(row.id);
  163. }}
  164. >
  165. 立即开通
  166. </a>
  167. );
  168. row.endTime = `${formatDate(row.endTime, 'YYYY-MM-DD')} 前`;
  169. return row;
  170. }),
  171. updateTotal: result.list.length,
  172. updatePage: page,
  173. updateData: { page, size, service, isUse, columns: isUse ? [] : openColumns, type: 'record' },
  174. });
  175. });
  176. }
  177. refreshData() {
  178. const dataTypeSelect = DataType.map(row => {
  179. row.title = row.label;
  180. row.key = row.value;
  181. return row;
  182. });
  183. dataTypeSelect.unshift({
  184. title: '全部',
  185. key: '',
  186. });
  187. this.setState({ dataTypeSelect });
  188. Main.dataStruct().then(result => {
  189. const structs = result
  190. .filter(row => row.level === 1)
  191. .map(row => {
  192. row.title = `${row.titleZh}${row.titleEn}`;
  193. row.key = `${row.id}`;
  194. return row;
  195. });
  196. structs.unshift({
  197. title: '全部',
  198. key: '',
  199. });
  200. this.setState({
  201. structs,
  202. });
  203. });
  204. My.listData(Object.assign({}, this.state.search)).then(result => {
  205. // result = {
  206. // list: [
  207. // {
  208. // title: '123123',
  209. // latestTime: '',
  210. // id: 1,
  211. // number: 10,
  212. // version: '1231',
  213. // },
  214. // ],
  215. // };
  216. this.setState({
  217. list: result.list.map(row => {
  218. row.time = formatDate(row.time, 'YYYY-MM-DD HH:mm:ss');
  219. return row;
  220. }),
  221. total: result.total,
  222. page: this.state.search.page,
  223. });
  224. });
  225. }
  226. dataHistory({ dataId, page, size }) {
  227. My.listDataHistory({ page, size: 10000, dataId }).then(result => {
  228. result.list = result.list.map(row => {
  229. row.time = formatDate(row.time, 'YYYY-MM-DD\nHH:mm:ss');
  230. return row;
  231. });
  232. this.setState({
  233. showUpdate: true,
  234. // 不显示分页
  235. updateTotal: 0,
  236. maxHeight: 730,
  237. updateList: result.list,
  238. updatePage: page,
  239. updateData: { page, size, dataId, columns: dataHistoryColumns, type: 'data' },
  240. });
  241. });
  242. }
  243. onFilter(value) {
  244. this.search(value);
  245. }
  246. onSort(value) {
  247. const { sortMap } = this.state;
  248. const keys = Object.keys(value);
  249. const index = keys.length > 1 && sortMap[keys[0]] ? 1 : 0;
  250. this.search({ order: keys.length ? keys[index] : null, direction: keys.length ? value[keys[index]] : null });
  251. }
  252. onTabChange(tab) {
  253. const data = { tab };
  254. this.refreshQuery(data);
  255. }
  256. submitComment() {
  257. const { comment } = this.state;
  258. if (!comment.content) return;
  259. My.addComment(comment.channel, comment.position, comment.content).then(() => {
  260. this.setState({ showComment: false, showFinish: true, comment: {} });
  261. });
  262. }
  263. submitFeedbackError() {
  264. const { feedbackError } = this.state;
  265. if (!feedbackError.content || !feedbackError.originContent) return;
  266. My.addFeedbackErrorData(
  267. feedbackError.dataId,
  268. feedbackError.title,
  269. feedbackError.position.join(','),
  270. feedbackError.originContent,
  271. feedbackError.content,
  272. ).then(() => {
  273. this.setState({ showFinish: true, showFeedbackError: false, feedbackError: { position: ['', '', ''] } });
  274. });
  275. }
  276. submitFeedback() {
  277. const { feedback } = this.state;
  278. if (!feedback.content) return;
  279. if (feedback.target !== 'new' && !feedback.no) return;
  280. My.addTextbookFeedback(feedback.questionSubject, feedback.target, feedback.no, feedback.content).then(() => {
  281. this.setState({ showFinish: true, showFeedback: false, feedback: {} });
  282. });
  283. }
  284. subscribe(value) {
  285. My.subscribeData(value)
  286. .then(() => {
  287. const { info } = this.props.user;
  288. info.dataEmailSubscribe = value;
  289. User.infoHandle(info);
  290. })
  291. .catch(err => {
  292. asyncSMessage(err.message, 'warn');
  293. });
  294. }
  295. open(recordId) {
  296. Order.useRecord(recordId).then(() => {
  297. asyncSMessage('开通成功');
  298. this.refresh();
  299. });
  300. }
  301. renderView() {
  302. const { config } = this.props;
  303. return <UserLayout active={config.key} menu={menu} center={this.renderDetail()} />;
  304. }
  305. renderDetail() {
  306. const {
  307. tab,
  308. comment = {},
  309. feedback = {},
  310. feedbackError = {},
  311. showComment,
  312. showFinish,
  313. showUpdate,
  314. showFeedback,
  315. showFeedbackError,
  316. updateList,
  317. updateTotal,
  318. maxHeight,
  319. updateData = {},
  320. showExamination,
  321. showReal,
  322. showVip,
  323. } = this.state;
  324. const { info } = this.props.user;
  325. return (
  326. <div className="table-layout">
  327. <Tabs
  328. border
  329. type="division"
  330. theme="theme"
  331. size="small"
  332. space={2.5}
  333. width={100}
  334. active={tab}
  335. tabs={[
  336. { key: 'data', title: '资料' },
  337. { key: 'textbook', title: '机经' },
  338. { key: 'examination', title: '模考' },
  339. { key: 'vip', title: 'VIP' },
  340. { key: 'cal', title: '考分计算器' },
  341. ]}
  342. onChange={key => this.onTabChange(key)}
  343. />
  344. {this[`renderTab${tab}`]()}
  345. <Modal
  346. show={showUpdate}
  347. maskClosable
  348. close={false}
  349. body={false}
  350. width={630}
  351. onClose={() => this.setState({ showUpdate: false, updateList: [] })}
  352. >
  353. <UserTable
  354. size="small"
  355. theme="top"
  356. columns={updateData.columns}
  357. data={updateList}
  358. current={updateData.page}
  359. pageSize={updateData.size}
  360. onChange={page => {
  361. updateData.page = page;
  362. if (updateData.type === 'data') {
  363. this.dataHistory(updateData);
  364. } else if (updateData.type === 'textbook') {
  365. this.textbookHistory(updateData);
  366. } else if (updateData.type === 'record') {
  367. this.recordList(updateData);
  368. }
  369. }}
  370. total={updateTotal}
  371. maxHeight={maxHeight}
  372. />
  373. </Modal>
  374. <Modal
  375. show={showComment}
  376. title="评价"
  377. onConfirm={() => comment.content && this.submitComment()}
  378. onCancel={() => this.setState({ showComment: false, comment: {} })}
  379. >
  380. <textarea
  381. value={comment.content}
  382. className="b-c-1 w-10 p-10"
  383. rows={6}
  384. placeholder="您的看法对我们来说很重要!"
  385. onChange={e => {
  386. comment.content = e.target.value;
  387. this.setState({ comment });
  388. }}
  389. />
  390. <div className="b-b m-t-2" />
  391. </Modal>
  392. <Modal
  393. show={showFinish}
  394. title="提交成功"
  395. confirmText="好的,知道了"
  396. btnAlign="center"
  397. onConfirm={() => this.setState({ showFinish: false })}
  398. >
  399. <div className="t-2 t-s-18">
  400. <Icon type="check" className="t-5 m-r-5" />
  401. 您的每一次反馈都是千行进步的动力。
  402. </div>
  403. </Modal>
  404. <Modal
  405. show={showFeedbackError}
  406. title="纠错"
  407. btnType="link"
  408. width={630}
  409. onConfirm={() => this.submitFeedbackError()}
  410. onCancel={() => this.setState({ showFeedbackError: false })}
  411. >
  412. <div className="t-2 m-b-1 t-s-16">
  413. 定位:
  414. <input value={feedbackError.position[0]} className="t-c b-c-1 m-r-5" style={{ width: 56 }} onChange={e => {
  415. feedbackError.position[0] = e.target.value;
  416. this.setState({ feedbackError });
  417. }} />
  418. <span className="require">页</span>
  419. <input value={feedbackError.position[1]} className="t-c b-c-1 m-r-5" style={{ width: 56 }} onChange={e => {
  420. feedbackError.position[1] = e.target.value;
  421. this.setState({ feedbackError });
  422. }} />
  423. <span className="require">行</span> , 题号
  424. <input value={feedbackError.position[2]} className="t-c b-c-1" style={{ width: 56 }} onChange={e => {
  425. feedbackError.position[2] = e.target.value;
  426. this.setState({ feedbackError });
  427. }} />
  428. </div>
  429. <div className="t-2 t-s-16">错误内容是:</div>
  430. <textarea
  431. value={feedbackError.originContent}
  432. className="b-c-1 w-10 p-10"
  433. rows={10}
  434. placeholder={'可简单描述您发现的问题'}
  435. onChange={e => {
  436. feedbackError.originContent = e.target.value;
  437. this.setState({ feedbackError });
  438. }}
  439. />
  440. <div className="t-2 t-s-16">应该更改为:</div>
  441. <textarea
  442. value={feedbackError.content}
  443. className="b-c-1 w-10 p-10"
  444. rows={10}
  445. placeholder={'提供您认为正确的内容即可'}
  446. onChange={e => {
  447. feedbackError.content = e.target.value;
  448. this.setState({ feedbackError });
  449. }}
  450. />
  451. <div className="b-b m-t-2" />
  452. </Modal>
  453. <Modal
  454. show={showFeedback}
  455. title="反馈"
  456. width={630}
  457. onConfirm={() => this.submitFeedback()}
  458. onCancel={() => this.setState({ showFeedback: false })}
  459. >
  460. <div className="t-2 t-s-16 m-b-1">
  461. 机经类别:
  462. <Select
  463. value={feedback.questionSubject}
  464. theme="white"
  465. list={[{ title: '数学机经', key: 'quant' }, { title: '逻辑机经', key: 'rc' }, { title: '阅读机经', key: 'ir' }]}
  466. onChange={(value) => {
  467. feedback.questionSubject = value;
  468. this.setState({ feedback });
  469. }}
  470. />
  471. 反馈类型:
  472. <Select
  473. value={feedback.target}
  474. theme="white"
  475. list={TextbookFeedbackTarget}
  476. onChange={(value) => {
  477. feedback.target = value;
  478. this.setState({ feedback });
  479. }}
  480. />
  481. <span hidden={feedback.target === 'new'}>
  482. 题号是
  483. <input value={feedback.no} style={{ width: 80 }} className="m-l-1 b-c-1 t-c" onChange={e => {
  484. feedback.no = e.target.value;
  485. this.setState({ feedback });
  486. }} />
  487. </span>
  488. </div>
  489. <div className="t-2 t-s-16">{TextbookFeedbackTargetMap[feedback.target]}:</div>
  490. <textarea
  491. value={feedback.content}
  492. className="b-c-1 w-10 p-10"
  493. rows={10}
  494. placeholder={TextbookFeedbackTargetMap[feedback.target]}
  495. onChange={e => {
  496. feedback.content = e.target.value;
  497. this.setState({ feedback });
  498. }}
  499. />
  500. <div className="b-b m-t-2" />
  501. </Modal>
  502. <Examination
  503. show={showExamination}
  504. data={info}
  505. onConfirm={() => this.setState({ showExamination: false })}
  506. onCancel={() => this.setState({ showExamination: false })}
  507. onClose={() => this.setState({ showExamination: false })}
  508. />
  509. <RealAuth show={showReal} data={info} onConfirm={() => this.setState({ showReal: false })} />
  510. <VipRenew
  511. show={showVip}
  512. data={info}
  513. onReal={() => this.setState({ showVip: false, showReal: true })}
  514. onPrepare={() => this.setState({ showVip: false, showExamination: true })}
  515. onClose={() => this.setState({ showVip: false })}
  516. />
  517. </div>
  518. );
  519. }
  520. renderTabdata() {
  521. const { list = [], filterMap = {}, sortMap = {}, structs, dataTypeSelect, total, page } = this.state;
  522. const { info } = this.props.user;
  523. return (
  524. <div className="tab-1-layout">
  525. <UserAction
  526. selectList={[
  527. {
  528. label: '学科',
  529. key: 'structId',
  530. select: structs,
  531. },
  532. {
  533. label: '资料形式',
  534. key: 'dataType',
  535. select: dataTypeSelect,
  536. },
  537. ]}
  538. sortList={[
  539. { right: true, label: '销量', key: 'sale_number' },
  540. { right: true, label: '更新时间', key: 'latest_time' },
  541. ]}
  542. sortMap={sortMap}
  543. filterMap={filterMap}
  544. onFilter={value => this.onFilter(value)}
  545. onSort={value => this.onSort(value)}
  546. right={
  547. <div className="email">
  548. 邮箱订阅{' '}
  549. <Switch
  550. checked={info.dataEmailSubscribe}
  551. onChange={() => {
  552. this.subscribe(!info.dataEmailSubscribe);
  553. }}
  554. />
  555. </div>
  556. }
  557. />
  558. <div className="data-layout">
  559. {list.map(item => {
  560. return (
  561. <div className="data-item">
  562. <Assets name="sun_blue" src={item.cover} />
  563. <div className="fixed">
  564. <div className="btns">
  565. <Button
  566. size="small"
  567. radius
  568. onClick={() => {
  569. openLink(item.resource);
  570. }}
  571. >
  572. 阅读
  573. </Button>
  574. <div
  575. className="white"
  576. onClick={() => {
  577. openLink(item.resource);
  578. }}
  579. >
  580. 下载
  581. </div>
  582. </div>
  583. </div>
  584. <div className="title">
  585. <span>版本{item.version}</span>
  586. {item.title}
  587. </div>
  588. <div className="date">{formatDate(item.latestTime, 'YYYY-MM-DD HH:mm:ss')}</div>
  589. <More
  590. menu={[
  591. { label: '纠错', key: 'feedback' },
  592. { label: '评价', key: 'comment' },
  593. { label: '更新', key: 'update' },
  594. ]}
  595. onClick={value => {
  596. const { key } = value;
  597. if (key === 'comment') {
  598. this.setState({ showComment: true, comment: { channel: 'course_data', position: item.id } });
  599. } else if (key === 'update') {
  600. this.dataHistory({ dataId: item.id, page: 1, size: 10 });
  601. } else if (key === 'feedback') {
  602. this.setState({ showFeedbackError: true, feedbackError: { dataId: item.id, title: item.title, position: ['', '', ''] } });
  603. }
  604. }}
  605. />
  606. </div>
  607. );
  608. })}
  609. </div>
  610. {total > 0 && list.length > 0 && (
  611. <UserPagination total={total} current={page} pageSize={this.state.search.size} onChange={p => this.onChangePage(p)} />
  612. )}
  613. </div>
  614. );
  615. }
  616. renderTabtextbook() {
  617. const { data = {}, list = [], service } = this.state;
  618. const { latest = {}, day } = data;
  619. return (
  620. <div className="tab-2-layout">
  621. <UserAction
  622. left={
  623. <div className="total-log">
  624. <span>最新换库</span>
  625. <span>{latest.startDate ? formatDate(latest.startDate, 'YYYY-MM-DD') : ''}</span>
  626. <span>
  627. 已换库<b>{day}</b>天
  628. </span>
  629. </div>
  630. }
  631. right={
  632. !data.hasService &&
  633. data.unUseRecord && (
  634. <div className="email" >
  635. <span onClick={() => {
  636. this.recordList({ page: 1, size: 10, service: 'textbook', isUse: false, isExpire: false });
  637. }} >待开通</span>
  638. </div>
  639. )
  640. }
  641. />
  642. {data.hasService && (
  643. <div className="data-layout">
  644. {list.map(item => {
  645. return (
  646. <div className="data-item">
  647. <Assets name="sun_blue" />
  648. <div className="title">
  649. 已更新至<b>{item.num}</b>题
  650. </div>
  651. <div className="date">{item.date}</div>
  652. <More
  653. menu={[
  654. { label: '更新', key: 'update' },
  655. { label: '反馈', key: 'feedback' },
  656. { label: '评价', key: 'comment' },
  657. ]}
  658. onClick={value => {
  659. const { key } = value;
  660. if (key === 'comment') {
  661. this.setState({ showComment: true, comment: { channel: 'library' } });
  662. } else if (key === 'update') {
  663. this.textbookHistory({ page: 1, size: 100, subject: item.subject });
  664. } else if (key === 'feedback') {
  665. this.setState({ showFeedback: true, feedback: { questionSubject: item.subject, target: TextbookFeedbackTarget[0].value } });
  666. }
  667. }}
  668. />
  669. </div>
  670. );
  671. })}
  672. </div>
  673. )}
  674. {!data.hasService && !data.unUseRecord && (
  675. <div className="tip-layout">
  676. <div className="t1">还未购买本月机经</div>
  677. <div className="desc">¥ {service && service.package && service.package[0].price}</div>
  678. <Button radius size="lager" width={150} onClick={() => {
  679. this.buyTextbook();
  680. }}>
  681. 立即购买
  682. </Button>
  683. </div>
  684. )}
  685. {/* {data.hasService && (
  686. <div className="tip-layout">
  687. <div className="t1">使用中</div>
  688. <div className="t2">距离到期还有 {data.expireDay} 天</div>
  689. </div>
  690. )} */}
  691. {!data.hasService && data.unUseRecord && (
  692. <div className="tip-layout">
  693. <div className="t2">请于{formatDate(data.unUseRecord.endTime, 'YYYY-MM-DD')}前开通</div>
  694. <Button
  695. radius
  696. size="lager"
  697. width={150}
  698. onClick={() => {
  699. this.open(data.unUseRecord.id);
  700. }}
  701. >
  702. 立即开通
  703. </Button>
  704. </div>
  705. )}
  706. </div>
  707. );
  708. }
  709. renderTabexamination() {
  710. const { data = {}, service } = this.state;
  711. return (
  712. <div className="tab-3-layout">
  713. <UserAction
  714. right={
  715. !data.hasService &&
  716. data.unUseRecord && (
  717. <div
  718. className="email"
  719. onClick={() => {
  720. this.recordList({ page: 1, size: 10, service: 'qx_cat', isUse: false, isExpire: false });
  721. }}
  722. >
  723. 待开通
  724. </div>
  725. )
  726. }
  727. />
  728. {!data.hasService && !data.unUseRecord && !data.expireTime && (
  729. <div className="tip-layout">
  730. <div className="t1">未购买</div>
  731. <div className="desc">¥ {service && service.package && service.package[0].price}</div>
  732. <Button radius size="lager" width={150} onClick={() => {
  733. this.buyExamination();
  734. }}>
  735. 立即购买
  736. </Button>
  737. </div>
  738. )}
  739. {!data.hasService && data.unUseRecord && (
  740. <div className="tip-layout">
  741. <div className="t2">请于{formatDate(data.unUseRecord.endTime, 'YYYY-MM-DD')}前开通</div>
  742. <Button
  743. radius
  744. size="lager"
  745. width={150}
  746. onClick={() => {
  747. this.open(data.unUseRecord.id);
  748. }}
  749. >
  750. 立即开通
  751. </Button>
  752. </div>
  753. )}
  754. {data.hasService && (
  755. <div className="tip-layout">
  756. <div className="t1">使用中</div>
  757. <div className="t2">距离到期还有 {data.expireDay} 天</div>
  758. </div>
  759. )}
  760. {!data.hasService && !data.unUseRecord && data.expireTime && (
  761. <div className="tip-layout">
  762. <div className="t3">已过期</div>
  763. <div className="date">
  764. {formatDate(data.startTime, 'YYYY-MM-DD')} ~ {formatDate(data.expireTime, 'YYYY-MM-DD')}
  765. </div>
  766. <div className="desc">¥ {service && service.package && service.package[0].price}</div>
  767. <Button radius size="lager" width={150}>
  768. 立即购买
  769. </Button>
  770. </div>
  771. )}
  772. </div>
  773. );
  774. }
  775. renderTabvip() {
  776. const { data } = this.state;
  777. return (
  778. <div className="tab-4-layout">
  779. {!data.hasService && !data.unUseRecord && !data.expireTime && (
  780. <div className="tip-layout">
  781. <div className="t2">未购买</div>
  782. <Button radius size="lager" width={150} onClick={() => {
  783. this.setState({ showVip: true });
  784. }}>
  785. 立即购买
  786. </Button>
  787. </div>
  788. )}
  789. {data.hasService && (
  790. <div className="tip-layout">
  791. <div className="t1">使用中</div>
  792. <div className="desc">{formatDate(data.expireTime, 'YYYY-MM-DD')} 到期</div>
  793. <Button radius size="lager" width={150} onClick={() => {
  794. this.setState({ showVip: true });
  795. }}>
  796. 续费
  797. </Button>
  798. </div>
  799. )}
  800. {!data.hasService && !data.unUseRecord && data.expireTime && (
  801. <div className="tip-layout">
  802. <div className="t1">已过期</div>
  803. <div className="desc">
  804. {formatDate(data.startTime, 'YYYY-MM-DD')} ~ {formatDate(data.expireTime, 'YYYY-MM-DD')}
  805. </div>
  806. <Button radius size="lager" width={150} onClick={() => {
  807. this.setState({ showVip: true });
  808. }}>
  809. 立即购买
  810. </Button>
  811. </div>
  812. )}
  813. </div>
  814. );
  815. }
  816. renderTabcal() {
  817. const { data = {} } = this.state;
  818. return (
  819. <div className="tab-5-layout">
  820. <TotalSort
  821. value={data.value || 650}
  822. onChange={value => {
  823. data.value = value;
  824. this.setState({ data });
  825. }}
  826. />
  827. </div>
  828. );
  829. }
  830. }