index.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import React, { Component } from 'react';
  2. import './index.less';
  3. import { Link } from 'react-router-dom';
  4. import { Checkbox } from 'antd';
  5. import Module from '../Module';
  6. import Progress from '../Progress';
  7. import IconButton from '../IconButton';
  8. import Button from '../Button';
  9. export default class Card extends Component {
  10. getBuyBody() {
  11. const { data } = this.props;
  12. return (
  13. <div className="body">
  14. <div className="desc" dangerouslySetInnerHTML={{ __html: data.description }} />
  15. <div className="btn">
  16. <Button size="lager" radius>
  17. 立即购买
  18. </Button>
  19. </div>
  20. </div>
  21. );
  22. }
  23. getOpenBody() {
  24. return (
  25. <div className="body">
  26. <div className="title">请开通预习作业</div>
  27. <div className="text">
  28. <Checkbox />
  29. <span>
  30. 我已阅读并同意<Link to="">《千行 GMAT - Sentence Corretion 课程协议》</Link>
  31. </span>
  32. </div>
  33. <div className="btn">
  34. <Button size="lager" radius>
  35. 立即开通
  36. </Button>
  37. </div>
  38. </div>
  39. );
  40. }
  41. getIngBody() {
  42. const { process, previewAction } = this.props;
  43. return (
  44. <div className="body">
  45. <div className="title">近期待完成</div>
  46. {process.previews.length === 0 ? (
  47. <div className="text">
  48. <div>好棒!</div>
  49. <div>近期的作业都完成啦</div>
  50. </div>
  51. ) : (
  52. <div className="list">
  53. {process.previews.map(item => {
  54. return (
  55. <div className="item">
  56. <div className="top">
  57. <div className="date">{item.time}</div>
  58. <div className="action">
  59. {!item.repport.id && (
  60. <IconButton
  61. type="start"
  62. tip="Start"
  63. onClick={() => previewAction && previewAction('start', item)}
  64. />
  65. )}
  66. {item.repport.id && (
  67. <IconButton
  68. type="continue"
  69. onClick={() => previewAction && previewAction('continue', item)}
  70. tip="Continue"
  71. />
  72. )}
  73. {item.repport.id && (
  74. <IconButton
  75. type="restart"
  76. onClick={() => previewAction && previewAction('restart', item)}
  77. tip="Restart"
  78. />
  79. )}
  80. </div>
  81. </div>
  82. <Progress progress={item.report.id ? item.repport.userNumber / item.report.questionNumber : 0} />
  83. </div>
  84. );
  85. })}
  86. </div>
  87. )}
  88. </div>
  89. );
  90. }
  91. getBody() {
  92. const { process = {} } = this.props;
  93. if (!process.payed && !process.startTime) return this.getBuyBody();
  94. if (process.payed) return this.getOpenBody();
  95. if (process.startTime) return this.getIngBody();
  96. return <div />;
  97. }
  98. render() {
  99. const { style, data = {}, process = {} } = this.props;
  100. return (
  101. <Module style={style} className={`card ${data.status}`}>
  102. <div className="header">
  103. {`${data.titleZh} ${data.titleEn}`}
  104. {!process.payed && !process.startTime && <span className="sub-title">未购买</span>}
  105. {(process.payed || process.startTime) && <span className="sub-title">已购买</span>}
  106. </div>
  107. {this.getBody()}
  108. </Module>
  109. );
  110. }
  111. }