1
0

page.js 26 KB

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