import React, { Component } from 'react'; import './index.less'; import { Link } from 'react-router-dom'; import { Checkbox } from 'antd'; import Assets from '@src/components/Assets'; import { formatDate } from '@src/services/Tools'; import Module from '../Module'; import Progress from '../Progress'; import IconButton from '../IconButton'; import Button from '../Button'; export default class Card extends Component { getBuyBody() { const { data } = this.props; return (
); } getOpenBody() { return (
请开通预习作业
我已阅读并同意《千行 GMAT - Sentence Corretion 课程协议》
); } getIngBody() { const { process, previewAction } = this.props; return (
近期待完成
{process.previews.length === 0 ? (
好棒!
近期的作业都完成啦
) : (
{process.previews.map(item => { return (
{item.time}
{!item.repport.id && ( previewAction && previewAction('start', item)} /> )} {item.repport.id && ( previewAction && previewAction('continue', item)} tip="Continue" /> )} {item.repport.id && ( previewAction && previewAction('restart', item)} tip="Restart" /> )}
); })}
)}
); } getBody() { const { process = {} } = this.props; if (!process.payed && !process.startTime) return this.getBuyBody(); if (process.payed) return this.getOpenBody(); if (process.startTime) return this.getIngBody(); return
; } render() { const { style, data = {}, process = {} } = this.props; return (
{`${data.titleZh} ${data.titleEn}`} {!process.payed && !process.startTime && 未购买} {(process.payed || process.startTime) && 已购买}
{this.getBody()}
); } } export class Card1 extends Component { getEndBody() { const { data, onPreview } = this.props; const { useStartTime, useEndTime } = data; return (
课程已经结束啦
有效期: {useStartTime && formatDate(useStartTime, 'YYYY-MM-DD')}至{useEndTime && formatDate(useEndTime, 'YYYY-MM-DD')} onPreview && onPreview()}>全部作业>
); } getStopBody() { return (
停课中
您可至「我的-课程」恢复学习
); } getOpenBody() { const { checked } = this.state; const { data, onOpen, contract } = this.props; const { teacher, endTime, courseModule } = data; switch (courseModule) { case 'video': return
请于{endTime && formatDate(endTime, 'YYYY-MM-DD')}前开通课程
; case 'online': return
{ this.setState({ checked: !checked }); }} /> 我已阅读并同意{contract.title}
; case 'vs': return
请尽快与老师预约上课时间
请于 {endTime && formatDate(endTime, 'YYYY-MM-DD')} 前开通课程
{teacher && }
; default: return
; } } getIngBody() { const { data, list = [], previewAction, onPreview } = this.props; const { useStartTime, useEndTime } = data; return (
{list.length > 0 &&
近期待完成
} {list.length === 0 ? (
好棒!
近期的作业都完成啦
) : (
{list.map(item => { return (
{item.title}
{item.progress === 0 && ( previewAction && previewAction('start', item)} /> )} {item.progress > 0 && ( previewAction && previewAction('continue', item)} tip="Continue" /> )} {item.progress > 0 && ( previewAction && previewAction('restart', item)} tip="Restart" /> )}
); })}
)}
有效期: {useStartTime && formatDate(useStartTime, 'YYYY-MM-DD')}至{useEndTime && formatDate(useEndTime, 'YYYY-MM-DD')} onPreview && onPreview()}>全部作业>
); } getBody() { const { status } = this.props; if (status === 'end') return this.getEndBody(); if (status === 'stop') return this.getStopBody(); if (status === 'open') return this.getOpenBody(); if (status === 'ing') return this.getIngBody(); return
; } render() { const { style, title, tag, status } = this.props; return (
{tag &&
{tag}
} {title}
{this.getBody()}
); } }