page.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. import React from 'react';
  2. import './index.less';
  3. import Page from '@src/containers/Page';
  4. import Assets from '@src/components/Assets';
  5. import { asyncSMessage } from '@src/services/AsyncTools';
  6. import { formatDate, getMap } from '@src/services/Tools';
  7. import UserLayout from '../../../layouts/User';
  8. import UserAction from '../../../components/UserAction';
  9. import menu from '../index';
  10. import Tabs from '../../../components/Tabs';
  11. import More from '../../../components/More';
  12. import Button from '../../../components/Button';
  13. import Switch from '../../../components/Switch';
  14. import TotalSort from '../../../components/TotalSort';
  15. import { RealAuth, TextbookFeedbackModal, FinishModal, CommentModal, FeedbackErrorDataModal } from '../../../components/OtherModal';
  16. import Examination from '../../../components/Examination';
  17. import VipRenew from '../../../components/VipRenew';
  18. import Modal from '../../../components/Modal';
  19. import UserTable from '../../../components/UserTable';
  20. import UserPagination from '../../../components/UserPagination';
  21. import { My } from '../../../stores/my';
  22. import { User } from '../../../stores/user';
  23. import { Order } from '../../../stores/order';
  24. import { Textbook } from '../../../stores/textbook';
  25. import { DataType, ServiceKey, RecordSource, TextbookFeedbackTarget } from '../../../../Constant';
  26. import { Main } from '../../../stores/main';
  27. import { Question } from '../../../stores/question';
  28. const ServiceKeyMap = getMap(ServiceKey, 'value', 'label');
  29. const RecordSourceMap = getMap(RecordSource, 'value', 'label');
  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. {
  39. title: '更新时间',
  40. key: 'createTime',
  41. width: 120,
  42. render: (text) => {
  43. return <div className="sub">
  44. <div className="t-2 t-s-12">{text.split(' ')[0]}</div>
  45. <div className="t-6 t-s-12">{text.split(' ')[1]}</div>
  46. </div>;
  47. },
  48. },
  49. { title: '版本', key: 'version', width: 120 },
  50. { title: '更新内容', key: 'content', width: 330 },
  51. ];
  52. const openColumns = [
  53. { title: '商品名称', key: 'title', width: 240 },
  54. { title: '获取方式', key: 'source', width: 240 },
  55. { title: '开通期限', key: 'endTime', width: 240 },
  56. { title: '操作', key: 'handler', width: 90 },
  57. ];
  58. export default class extends Page {
  59. constructor(props) {
  60. props.size = 10;
  61. super(props);
  62. }
  63. initState() {
  64. return {
  65. tab: 'data',
  66. sortMap: {},
  67. filterMap: {},
  68. feedbackError: { position: ['', '', ''] },
  69. };
  70. }
  71. initData() {
  72. const data = Object.assign(this.state, this.state.search);
  73. if (data.order) {
  74. data.sortMap = { [data.order]: data.direction };
  75. }
  76. data.filterMap = this.state.search;
  77. this.setState(data);
  78. const { tab } = this.state;
  79. switch (tab) {
  80. case 'textbook':
  81. this.refreshTextbook();
  82. break;
  83. case 'examination':
  84. this.refreshExamination();
  85. break;
  86. case 'vip':
  87. this.refreshVip();
  88. break;
  89. case 'cal':
  90. break;
  91. case 'data':
  92. default:
  93. this.refreshData();
  94. break;
  95. }
  96. }
  97. refreshTextbook() {
  98. Main.getService('textbook').then(result => {
  99. this.setState({ service: result });
  100. });
  101. Textbook.getInfo().then(result => {
  102. const { latest } = result;
  103. result.day = parseInt((new Date().getTime() - new Date(result.latest.startDate).getTime()) / 86400000, 10);
  104. result.expireDay =
  105. result.expireTime && parseInt((new Date(result.expireTime).getTime() - new Date().getTime()) / 86400000, 10);
  106. const list = [];
  107. list.push({ subject: 'quant', number: latest.quantNumber, time: latest.quantTime, version: latest.quantVersion });
  108. list.push({ subject: 'rc', number: latest.rcNumber, time: latest.rcTime, version: latest.rcVersion });
  109. list.push({ subject: 'ir', number: latest.irNumber, time: latest.irTime, version: latest.irVersion });
  110. this.setState({ data: result, list });
  111. });
  112. }
  113. textbookHistory({ page, size, subject }) {
  114. Textbook.allHistory(subject).then(result => {
  115. this.setState({
  116. showUpdate: true,
  117. updateList: result.map(row => {
  118. row.version = row[`${subject}Version`];
  119. row.content = row[`${subject}Content`];
  120. row.createTime = formatDate(row.createTime, 'YYYY-MM-DD HH:mm:ss');
  121. return row;
  122. }),
  123. // 不显示分页
  124. updateTotal: 0,
  125. maxHeight: 730,
  126. updatePage: page,
  127. updateData: { page, size, subject, columns: textbookHistoryColumns, type: 'textbook' },
  128. });
  129. });
  130. }
  131. refreshExamination() {
  132. Main.getService('qx_cat').then(result => {
  133. this.setState({ service: result });
  134. });
  135. Question.getExaminationInfo().then(result => {
  136. result.expireDay =
  137. result.expireTime && parseInt((new Date(result.expireTime).getTime() - new Date().getTime()) / 86400000, 10);
  138. this.setState({ data: result });
  139. });
  140. }
  141. refreshVip() {
  142. Main.getService('vip').then(result => {
  143. this.setState({ service: result });
  144. });
  145. My.getVipInfo().then(result => {
  146. this.setState({ data: result });
  147. });
  148. }
  149. recordList({ page, size, service, isUse, isExpire }) {
  150. Order.listRecord({ page, size, productType: 'service', service, isUse, isExpire }).then(result => {
  151. this.setState({
  152. showUpdate: true,
  153. updateList: result.list.map(row => {
  154. row.title = ServiceKeyMap[service];
  155. row.source = RecordSourceMap[row.source];
  156. row.handler = (
  157. <a
  158. onClick={() => {
  159. this.open(row.id);
  160. }}
  161. >
  162. 立即开通
  163. </a>
  164. );
  165. row.endTime = `${formatDate(row.endTime, 'YYYY-MM-DD')} 前`;
  166. return row;
  167. }),
  168. updateTotal: result.list.length,
  169. updatePage: page,
  170. updateData: { page, size, service, isUse, columns: isUse ? [] : openColumns, type: 'record' },
  171. });
  172. });
  173. }
  174. refreshData() {
  175. const dataTypeSelect = DataType.map(row => {
  176. row.title = row.label;
  177. row.key = row.value;
  178. return row;
  179. });
  180. dataTypeSelect.unshift({
  181. title: '全部',
  182. key: '',
  183. });
  184. this.setState({ dataTypeSelect });
  185. Main.dataStruct().then(result => {
  186. const structs = result
  187. .filter(row => row.level === 1)
  188. .map(row => {
  189. row.title = `${row.titleZh}${row.titleEn}`;
  190. row.key = `${row.id}`;
  191. return row;
  192. });
  193. structs.unshift({
  194. title: '全部',
  195. key: '',
  196. });
  197. this.setState({
  198. structs,
  199. });
  200. });
  201. My.listData(Object.assign({}, this.state.search)).then(result => {
  202. // result = {
  203. // list: [
  204. // {
  205. // title: '123123',
  206. // latestTime: '',
  207. // id: 1,
  208. // number: 10,
  209. // version: '1231',
  210. // },
  211. // ],
  212. // };
  213. this.setState({
  214. list: result.list.map(row => {
  215. row.time = formatDate(row.time, 'YYYY-MM-DD HH:mm:ss');
  216. return row;
  217. }),
  218. total: result.total,
  219. page: this.state.search.page,
  220. });
  221. });
  222. }
  223. dataHistory({ dataId, page, size }) {
  224. My.listDataHistory({ page, size: 10000, dataId }).then(result => {
  225. result.list = result.list.map(row => {
  226. row.time = formatDate(row.time, 'YYYY-MM-DD\nHH:mm:ss');
  227. return row;
  228. });
  229. this.setState({
  230. showUpdate: true,
  231. // 不显示分页
  232. updateTotal: 0,
  233. maxHeight: 730,
  234. updateList: result.list,
  235. updatePage: page,
  236. updateData: { page, size, dataId, columns: dataHistoryColumns, type: 'data' },
  237. });
  238. });
  239. }
  240. onFilter(value) {
  241. this.search(value);
  242. }
  243. onSort(value) {
  244. const { sortMap } = this.state;
  245. const keys = Object.keys(value);
  246. const index = keys.length > 1 && sortMap[keys[0]] ? 1 : 0;
  247. this.search({ order: keys.length && value[keys[index]] ? keys[index] : null, direction: keys.length ? value[keys[index]] : null });
  248. }
  249. onTabChange(tab) {
  250. const data = { tab };
  251. this.refreshQuery(data);
  252. }
  253. subscribeDataEmail(value) {
  254. My.subscribeDataEmail(value)
  255. .then(() => {
  256. const { info } = this.props.user;
  257. info.dataEmailSubscribe = value;
  258. User.infoHandle(info);
  259. })
  260. .catch(err => {
  261. asyncSMessage(err.message, 'warn');
  262. });
  263. }
  264. cancelSubscribe(dataId) {
  265. My.subscribeData(dataId, false)
  266. .then(() => {
  267. this.refresh();
  268. });
  269. }
  270. open(recordId) {
  271. Order.useRecord(recordId).then(() => {
  272. this.refresh();
  273. });
  274. }
  275. buyTextbook() {
  276. User.needLogin()
  277. .then(() => {
  278. return Order.speedPay({ productType: 'service', service: 'textbook' });
  279. })
  280. .then((order) => {
  281. return User.needPay(order);
  282. })
  283. .then(() => {
  284. this.refresh();
  285. });
  286. }
  287. buyQxCat() {
  288. User.needLogin()
  289. .then(() => {
  290. return Order.speedPay({ productType: 'service', service: 'qx_cat' });
  291. })
  292. .then((order) => {
  293. return User.needPay(order);
  294. })
  295. .then(() => {
  296. this.refresh();
  297. });
  298. }
  299. renderView() {
  300. const { config } = this.props;
  301. console.log('view');
  302. return <UserLayout active={config.key} menu={menu} center={this.renderDetail()} />;
  303. }
  304. renderDetail() {
  305. const {
  306. tab,
  307. comment = {},
  308. feedback = {},
  309. feedbackError = {},
  310. showComment,
  311. showFinish,
  312. showUpdate,
  313. showFeedback,
  314. showFeedbackError,
  315. updateList,
  316. updateTotal,
  317. maxHeight,
  318. updateData = {},
  319. showExamination,
  320. showReal,
  321. showVip,
  322. } = this.state;
  323. const { info } = this.props.user;
  324. console.log('detail');
  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. <CommentModal
  375. show={showComment}
  376. defaultData={comment}
  377. onConfirm={() => this.setState({ showComment: false, comment: {}, showFinish: true })}
  378. onCancel={() => this.setState({ showComment: false, comment: {} })}
  379. onClose={() => this.setState({ showComment: false, comment: {} })}
  380. />
  381. <FeedbackErrorDataModal
  382. show={showFeedbackError}
  383. defaultData={feedbackError}
  384. onConfirm={() => this.setState({ showFeedbackError: false, feedbackError: {}, showFinish: true })}
  385. onCancel={() => this.setState({ showFeedbackError: false, feedbackError: {} })}
  386. onClose={() => this.setState({ showFeedbackError: false, feedbackError: {} })}
  387. />
  388. <TextbookFeedbackModal
  389. show={showFeedback}
  390. defaultData={feedback}
  391. onConfirm={() => this.setState({ showFeedback: false, feedback: {}, showFinish: true })}
  392. onCancel={() => this.setState({ showFeedback: false, feedback: {} })}
  393. onClose={() => this.setState({ showFeedback: false, feedback: {} })}
  394. />
  395. <FinishModal
  396. show={showFinish}
  397. onConfirm={() => this.setState({ showFinish: false })}
  398. />
  399. <Examination
  400. show={showExamination}
  401. data={info}
  402. onConfirm={() => this.setState({ showExamination: false })}
  403. onCancel={() => this.setState({ showExamination: false })}
  404. onClose={() => this.setState({ showExamination: false })}
  405. />
  406. <RealAuth show={showReal} data={info} onConfirm={() => this.setState({ showReal: false })} />
  407. <VipRenew
  408. show={showVip}
  409. data={info}
  410. onReal={() => this.setState({ showVip: false, showReal: true })}
  411. onPrepare={() => this.setState({ showVip: false, showExamination: true })}
  412. onClose={(result) => {
  413. if (result) {
  414. this.refresh();
  415. } else {
  416. this.setState({ showVip: false });
  417. }
  418. }}
  419. />
  420. </div>
  421. );
  422. }
  423. renderTabdata() {
  424. const { list = [], filterMap = {}, sortMap = {}, structs, dataTypeSelect, total, page } = this.state;
  425. const { info } = this.props.user;
  426. return (
  427. <div className="tab-1-layout">
  428. <UserAction
  429. selectList={[
  430. {
  431. label: '学科',
  432. key: 'structId',
  433. select: structs,
  434. },
  435. {
  436. label: '资料形式',
  437. key: 'dataType',
  438. select: dataTypeSelect,
  439. },
  440. ]}
  441. sortList={[
  442. { right: true, label: '销量', key: 'sale_number' },
  443. { right: true, label: '更新时间', key: 'latest_time' },
  444. ]}
  445. sortMap={sortMap}
  446. filterMap={filterMap}
  447. onFilter={value => this.onFilter(value)}
  448. onSort={value => this.onSort(value)}
  449. right={
  450. <div className="email">
  451. 邮箱订阅{' '}
  452. <Switch
  453. checked={info.dataEmailSubscribe}
  454. onChange={() => {
  455. this.subscribeDataEmail(!info.dataEmailSubscribe);
  456. }}
  457. />
  458. </div>
  459. }
  460. />
  461. <div className="data-layout">
  462. {list.map(item => {
  463. return (
  464. <div className="data-item">
  465. <Assets name="sun_blue" src={item.cover} />
  466. <div className="fixed">
  467. <div className="btns">
  468. {<Button
  469. size="small"
  470. radius
  471. onClick={() => {
  472. openLink(item.resource);
  473. }}
  474. >
  475. {item.have ? '阅读' : '预览'}
  476. </Button>}
  477. <div
  478. hidden={item.resource === item.trailResource}
  479. className="white"
  480. onClick={() => {
  481. openLink(`${item.resource}&download=true`);
  482. }}
  483. >
  484. 下载
  485. </div>
  486. </div>
  487. </div>
  488. <div className="title">
  489. <span>版本{item.version}</span>
  490. {item.title}
  491. </div>
  492. <div className="date">最新更新: {formatDate(item.latestTime, 'YYYY-MM-DD HH:mm:ss')}</div>
  493. <More
  494. menu={[
  495. { label: '纠错', key: 'feedback' },
  496. { label: '评价', key: 'comment' },
  497. { label: '更新', key: 'update' },
  498. { label: '移除', key: 'remove' },
  499. ]}
  500. onClick={value => {
  501. const { key } = value;
  502. if (key === 'comment') {
  503. this.setState({ showComment: true, comment: { channel: 'course_data', position: item.id } });
  504. } else if (key === 'update') {
  505. this.dataHistory({ dataId: item.id, page: 1, size: 10 });
  506. } else if (key === 'feedback') {
  507. this.setState({ showFeedbackError: true, feedbackError: { dataId: item.id, title: item.title, position: ['', '', ''] } });
  508. } else if (key === 'remove') {
  509. this.cancelSubscribe(item.id);
  510. }
  511. }}
  512. />
  513. </div>
  514. );
  515. })}
  516. </div>
  517. {total > 0 && list.length > 0 && (
  518. <UserPagination total={total} current={page} pageSize={this.state.search.size} onChange={p => this.onChangePage(p)} />
  519. )}
  520. </div>
  521. );
  522. }
  523. renderTabtextbook() {
  524. const { data = {}, list = [], service } = this.state;
  525. const { latest = {}, day } = data;
  526. return (
  527. <div className="tab-2-layout">
  528. <UserAction
  529. left={
  530. <div className="total-log">
  531. <span>最新换库</span>
  532. <span>{latest.startDate ? formatDate(latest.startDate, 'YYYY-MM-DD') : ''}</span>
  533. <span>
  534. 已换库<b>{day}</b>天
  535. </span>
  536. </div>
  537. }
  538. right={
  539. data.unUseRecord && (
  540. <div className="email c-p" >
  541. <span onClick={() => {
  542. this.recordList({ page: 1, size: 10, service: 'textbook', isUse: false, isExpire: false });
  543. }} >待开通</span>
  544. </div>
  545. )
  546. }
  547. />
  548. {data.hasService && (
  549. <div className="data-layout">
  550. {list.map(item => {
  551. return (
  552. <div className="data-item">
  553. <Assets name="sun_blue" onClick={() => linkTo(`/textbook/topic/list/${item.subject}`)} />
  554. <div className="title">
  555. 已更新至<b>{item.number || 0}</b>题
  556. </div>
  557. <div className="date">{item.date}</div>
  558. <More
  559. menu={[
  560. { label: '更新日志', key: 'update' },
  561. { label: '反馈', key: 'feedback' },
  562. { label: '评价', key: 'comment' },
  563. ]}
  564. onClick={value => {
  565. const { key } = value;
  566. if (key === 'comment') {
  567. this.setState({ showComment: true, comment: { channel: 'library' } });
  568. } else if (key === 'update') {
  569. this.textbookHistory({ page: 1, size: 100, subject: item.subject });
  570. } else if (key === 'feedback') {
  571. this.setState({ showFeedback: true, feedback: { textbookSubject: item.subject, target: TextbookFeedbackTarget[0].value, no: '' } });
  572. }
  573. }}
  574. />
  575. </div>
  576. );
  577. })}
  578. </div>
  579. )}
  580. {!data.hasService && !data.unUseRecord && (
  581. <div className="tip-layout">
  582. <div className="t1">还未购买本月机经</div>
  583. <div className="desc">¥ {service && service.package && service.package[0].price}</div>
  584. <Button radius size="lager" width={150} onClick={() => {
  585. this.buyTextbook();
  586. }}>
  587. 立即购买
  588. </Button>
  589. </div>
  590. )}
  591. {/* {data.hasService && (
  592. <div className="tip-layout">
  593. <div className="t1">使用中</div>
  594. <div className="t2">距离到期还有 {data.expireDay} 天</div>
  595. </div>
  596. )} */}
  597. {!data.hasService && data.unUseRecord && (
  598. <div className="tip-layout">
  599. <div className="t2">请于{formatDate(data.unUseRecord.endTime, 'YYYY-MM-DD')}前开通</div>
  600. <Button
  601. radius
  602. size="lager"
  603. width={150}
  604. onClick={() => {
  605. this.open(data.unUseRecord.id);
  606. }}
  607. >
  608. 立即开通
  609. </Button>
  610. </div>
  611. )}
  612. </div>
  613. );
  614. }
  615. renderTabexamination() {
  616. const { data = {}, service } = this.state;
  617. return (
  618. <div className="tab-3-layout">
  619. <UserAction
  620. right={
  621. data.unUseRecord && (
  622. <div
  623. className="email c-p"
  624. onClick={() => {
  625. this.recordList({ page: 1, size: 10, service: 'qx_cat', isUse: false, isExpire: false });
  626. }}
  627. >
  628. 待开通
  629. </div>
  630. )
  631. }
  632. />
  633. {!data.hasService && !data.unUseRecord && !data.expireTime && (
  634. <div className="tip-layout">
  635. <div className="t1">未购买</div>
  636. <div className="desc">¥ {service && service.package && service.package[0].price}</div>
  637. <Button radius size="lager" width={150} onClick={() => {
  638. this.buyQxCat();
  639. }}>
  640. 立即购买
  641. </Button>
  642. </div>
  643. )}
  644. {!data.hasService && data.unUseRecord && (
  645. <div className="tip-layout">
  646. <div className="t2">请于{formatDate(data.unUseRecord.endTime, 'YYYY-MM-DD')}前开通</div>
  647. <Button
  648. radius
  649. size="lager"
  650. width={150}
  651. onClick={() => {
  652. this.open(data.unUseRecord.id);
  653. }}
  654. >
  655. 立即开通
  656. </Button>
  657. </div>
  658. )}
  659. {data.hasService && (
  660. <div className="tip-layout">
  661. <div className="t1">使用中</div>
  662. <div className="t2">距离到期还有 {data.expireDay} 天</div>
  663. </div>
  664. )}
  665. {!data.hasService && !data.unUseRecord && data.expireTime && (
  666. <div className="tip-layout">
  667. <div className="t3">已过期</div>
  668. <div className="date">
  669. {formatDate(data.startTime, 'YYYY-MM-DD')} ~ {formatDate(data.expireTime, 'YYYY-MM-DD')}
  670. </div>
  671. <div className="desc">¥ {service && service.package && service.package[0].price}</div>
  672. <Button radius size="lager" width={150} onClick={() => {
  673. this.buyQxCat();
  674. }}>
  675. 立即购买
  676. </Button>
  677. </div>
  678. )}
  679. </div>
  680. );
  681. }
  682. renderTabvip() {
  683. const { data } = this.state;
  684. return (
  685. <div className="tab-4-layout">
  686. {!data.hasService && !data.unUseRecord && !data.expireTime && (
  687. <div className="tip-layout">
  688. <div className="t2">未购买</div>
  689. <Button radius size="lager" width={150} onClick={() => {
  690. this.setState({ showVip: true });
  691. }}>
  692. 立即购买
  693. </Button>
  694. </div>
  695. )}
  696. {data.hasService && (
  697. <div className="tip-layout">
  698. <div className="t1">使用中</div>
  699. <div className="desc">{formatDate(data.expireTime, 'YYYY-MM-DD')} 到期</div>
  700. <Button radius size="lager" width={150} onClick={() => {
  701. this.setState({ showVip: true });
  702. }}>
  703. 续费
  704. </Button>
  705. </div>
  706. )}
  707. {!data.hasService && !data.unUseRecord && data.expireTime && (
  708. <div className="tip-layout">
  709. <div className="t1">已过期</div>
  710. <div className="desc">
  711. {formatDate(data.startTime, 'YYYY-MM-DD')} ~ {formatDate(data.expireTime, 'YYYY-MM-DD')}
  712. </div>
  713. <Button radius size="lager" width={150} onClick={() => {
  714. this.setState({ showVip: true });
  715. }}>
  716. 立即购买
  717. </Button>
  718. </div>
  719. )}
  720. </div>
  721. );
  722. }
  723. renderTabcal() {
  724. const { data = {} } = this.state;
  725. return (
  726. <div className="tab-5-layout">
  727. <TotalSort
  728. value={data.value || 700}
  729. onChange={value => {
  730. data.value = value;
  731. this.setState({ data });
  732. }}
  733. />
  734. </div>
  735. );
  736. }
  737. }