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(result => {
  136. result.expireDay =
  137. result.expireTime && parseInt((new Date().getTime() - new Date(result.expireTime).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. return <UserLayout active={config.key} menu={menu} center={this.renderDetail()} />;
  302. }
  303. renderDetail() {
  304. const {
  305. tab,
  306. comment = {},
  307. feedback = {},
  308. feedbackError = {},
  309. showComment,
  310. showFinish,
  311. showUpdate,
  312. showFeedback,
  313. showFeedbackError,
  314. updateList,
  315. updateTotal,
  316. maxHeight,
  317. updateData = {},
  318. showExamination,
  319. showReal,
  320. showVip,
  321. } = this.state;
  322. const { info } = this.props.user;
  323. return (
  324. <div className="table-layout">
  325. <Tabs
  326. border
  327. type="division"
  328. theme="theme"
  329. size="small"
  330. space={2.5}
  331. width={100}
  332. active={tab}
  333. tabs={[
  334. { key: 'data', title: '资料' },
  335. { key: 'textbook', title: '机经' },
  336. { key: 'examination', title: '模考' },
  337. { key: 'vip', title: 'VIP' },
  338. { key: 'cal', title: '考分计算器' },
  339. ]}
  340. onChange={key => this.onTabChange(key)}
  341. />
  342. {this[`renderTab${tab}`]()}
  343. <Modal
  344. show={showUpdate}
  345. maskClosable
  346. close={false}
  347. body={false}
  348. width={630}
  349. onClose={() => this.setState({ showUpdate: false, updateList: [] })}
  350. >
  351. <UserTable
  352. size="small"
  353. theme="top"
  354. columns={updateData.columns}
  355. data={updateList}
  356. current={updateData.page}
  357. pageSize={updateData.size}
  358. onChange={page => {
  359. updateData.page = page;
  360. if (updateData.type === 'data') {
  361. this.dataHistory(updateData);
  362. } else if (updateData.type === 'textbook') {
  363. this.textbookHistory(updateData);
  364. } else if (updateData.type === 'record') {
  365. this.recordList(updateData);
  366. }
  367. }}
  368. total={updateTotal}
  369. maxHeight={maxHeight}
  370. />
  371. </Modal>
  372. <CommentModal
  373. show={showComment}
  374. defaultData={comment}
  375. onConfirm={() => this.setState({ showComment: false, comment: {}, showFinish: true })}
  376. onCancel={() => this.setState({ showComment: false, comment: {} })}
  377. onClose={() => this.setState({ showComment: false, comment: {} })}
  378. />
  379. <FeedbackErrorDataModal
  380. show={showFeedbackError}
  381. defaultData={feedbackError}
  382. onConfirm={() => this.setState({ showFeedbackError: false, feedbackError: {}, showFinish: true })}
  383. onCancel={() => this.setState({ showFeedbackError: false, feedbackError: {} })}
  384. onClose={() => this.setState({ showFeedbackError: false, feedbackError: {} })}
  385. />
  386. <TextbookFeedbackModal
  387. show={showFeedback}
  388. defaultData={feedback}
  389. onConfirm={() => this.setState({ showFeedback: false, feedback: {}, showFinish: true })}
  390. onCancel={() => this.setState({ showFeedback: false, feedback: {} })}
  391. onClose={() => this.setState({ showFeedback: false, feedback: {} })}
  392. />
  393. <FinishModal
  394. show={showFinish}
  395. onConfirm={() => this.setState({ showFinish: false })}
  396. />
  397. <Examination
  398. show={showExamination}
  399. data={info}
  400. onConfirm={() => this.setState({ showExamination: false })}
  401. onCancel={() => this.setState({ showExamination: false })}
  402. onClose={() => this.setState({ showExamination: false })}
  403. />
  404. <RealAuth show={showReal} data={info} onConfirm={() => this.setState({ showReal: false })} />
  405. <VipRenew
  406. show={showVip}
  407. data={info}
  408. onReal={() => this.setState({ showVip: false, showReal: true })}
  409. onPrepare={() => this.setState({ showVip: false, showExamination: true })}
  410. onClose={(result) => {
  411. if (result) {
  412. this.refresh();
  413. } else {
  414. this.setState({ showVip: false });
  415. }
  416. }}
  417. />
  418. </div>
  419. );
  420. }
  421. renderTabdata() {
  422. const { list = [], filterMap = {}, sortMap = {}, structs, dataTypeSelect, total, page } = this.state;
  423. const { info } = this.props.user;
  424. return (
  425. <div className="tab-1-layout">
  426. <UserAction
  427. selectList={[
  428. {
  429. label: '学科',
  430. key: 'structId',
  431. select: structs,
  432. },
  433. {
  434. label: '资料形式',
  435. key: 'dataType',
  436. select: dataTypeSelect,
  437. },
  438. ]}
  439. sortList={[
  440. { right: true, label: '销量', key: 'sale_number' },
  441. { right: true, label: '更新时间', key: 'latest_time' },
  442. ]}
  443. sortMap={sortMap}
  444. filterMap={filterMap}
  445. onFilter={value => this.onFilter(value)}
  446. onSort={value => this.onSort(value)}
  447. right={
  448. <div className="email">
  449. 邮箱订阅{' '}
  450. <Switch
  451. checked={info.dataEmailSubscribe}
  452. onChange={() => {
  453. this.subscribeDataEmail(!info.dataEmailSubscribe);
  454. }}
  455. />
  456. </div>
  457. }
  458. />
  459. <div className="data-layout">
  460. {list.map(item => {
  461. return (
  462. <div className="data-item">
  463. <Assets name="sun_blue" src={item.cover} />
  464. <div className="fixed">
  465. <div className="btns">
  466. {<Button
  467. size="small"
  468. radius
  469. onClick={() => {
  470. openLink(item.resource);
  471. }}
  472. >
  473. {item.have ? '阅读' : '预览'}
  474. </Button>}
  475. <div
  476. hidden={item.resource === item.trailResource}
  477. className="white"
  478. onClick={() => {
  479. openLink(`${item.resource}&download=true`);
  480. }}
  481. >
  482. 下载
  483. </div>
  484. </div>
  485. </div>
  486. <div className="title">
  487. <span>版本{item.version}</span>
  488. {item.title}
  489. </div>
  490. <div className="date">最新更新: {formatDate(item.latestTime, 'YYYY-MM-DD HH:mm:ss')}</div>
  491. <More
  492. menu={[
  493. { label: '纠错', key: 'feedback' },
  494. { label: '评价', key: 'comment' },
  495. { label: '更新', key: 'update' },
  496. { label: '移除', key: 'remove' },
  497. ]}
  498. onClick={value => {
  499. const { key } = value;
  500. if (key === 'comment') {
  501. this.setState({ showComment: true, comment: { channel: 'course_data', position: item.id } });
  502. } else if (key === 'update') {
  503. this.dataHistory({ dataId: item.id, page: 1, size: 10 });
  504. } else if (key === 'feedback') {
  505. this.setState({ showFeedbackError: true, feedbackError: { dataId: item.id, title: item.title, position: ['', '', ''] } });
  506. } else if (key === 'remove') {
  507. this.cancelSubscribe(item.id);
  508. }
  509. }}
  510. />
  511. </div>
  512. );
  513. })}
  514. </div>
  515. {total > 0 && list.length > 0 && (
  516. <UserPagination total={total} current={page} pageSize={this.state.search.size} onChange={p => this.onChangePage(p)} />
  517. )}
  518. </div>
  519. );
  520. }
  521. renderTabtextbook() {
  522. const { data = {}, list = [], service } = this.state;
  523. const { latest = {}, day } = data;
  524. return (
  525. <div className="tab-2-layout">
  526. <UserAction
  527. left={
  528. <div className="total-log">
  529. <span>最新换库</span>
  530. <span>{latest.startDate ? formatDate(latest.startDate, 'YYYY-MM-DD') : ''}</span>
  531. <span>
  532. 已换库<b>{day}</b>天
  533. </span>
  534. </div>
  535. }
  536. right={
  537. !data.hasService &&
  538. data.unUseRecord && (
  539. <div className="email" >
  540. <span onClick={() => {
  541. this.recordList({ page: 1, size: 10, service: 'textbook', isUse: false, isExpire: false });
  542. }} >待开通</span>
  543. </div>
  544. )
  545. }
  546. />
  547. {data.hasService && (
  548. <div className="data-layout">
  549. {list.map(item => {
  550. return (
  551. <div className="data-item">
  552. <Assets name="sun_blue" onClick={() => linkTo(`/textbook/topic/list/${item.subject}`)} />
  553. <div className="title">
  554. 已更新至<b>{item.num}</b>题
  555. </div>
  556. <div className="date">{item.date}</div>
  557. <More
  558. menu={[
  559. { label: '更新', key: 'update' },
  560. { label: '反馈', key: 'feedback' },
  561. { label: '评价', key: 'comment' },
  562. ]}
  563. onClick={value => {
  564. const { key } = value;
  565. if (key === 'comment') {
  566. this.setState({ showComment: true, comment: { channel: 'library' } });
  567. } else if (key === 'update') {
  568. this.textbookHistory({ page: 1, size: 100, subject: item.subject });
  569. } else if (key === 'feedback') {
  570. this.setState({ showFeedback: true, feedback: { questionSubject: item.subject, target: TextbookFeedbackTarget[0].value } });
  571. }
  572. }}
  573. />
  574. </div>
  575. );
  576. })}
  577. </div>
  578. )}
  579. {!data.hasService && !data.unUseRecord && (
  580. <div className="tip-layout">
  581. <div className="t1">还未购买本月机经</div>
  582. <div className="desc">¥ {service && service.package && service.package[0].price}</div>
  583. <Button radius size="lager" width={150} onClick={() => {
  584. this.buyTextbook();
  585. }}>
  586. 立即购买
  587. </Button>
  588. </div>
  589. )}
  590. {/* {data.hasService && (
  591. <div className="tip-layout">
  592. <div className="t1">使用中</div>
  593. <div className="t2">距离到期还有 {data.expireDay} 天</div>
  594. </div>
  595. )} */}
  596. {!data.hasService && data.unUseRecord && (
  597. <div className="tip-layout">
  598. <div className="t2">请于{formatDate(data.unUseRecord.endTime, 'YYYY-MM-DD')}前开通</div>
  599. <Button
  600. radius
  601. size="lager"
  602. width={150}
  603. onClick={() => {
  604. this.open(data.unUseRecord.id);
  605. }}
  606. >
  607. 立即开通
  608. </Button>
  609. </div>
  610. )}
  611. </div>
  612. );
  613. }
  614. renderTabexamination() {
  615. const { data = {}, service } = this.state;
  616. return (
  617. <div className="tab-3-layout">
  618. <UserAction
  619. right={
  620. !data.hasService &&
  621. data.unUseRecord && (
  622. <div
  623. className="email"
  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.buyExamination();
  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 || 650}
  729. onChange={value => {
  730. data.value = value;
  731. this.setState({ data });
  732. }}
  733. />
  734. </div>
  735. );
  736. }
  737. }