import React, { Component } from 'react'; import './index.less'; import { Icon } from 'antd'; import { getMap, formatDate } from '@src/services/Tools'; import { SpecialRadioGroup } from '../Radio'; import Modal from '../Modal'; import Button from '../Button'; import TotalSort from '../TotalSort'; import Date from '../Date'; import Ratio from '../Ratio'; import { My } from '../../stores/my'; import { PrepareStatus, PrepareExaminationTime } from '../../../Constant'; const PrepareStatusMap = getMap(PrepareStatus, 'value', 'short'); const PrepareExaminationTimeMap = getMap(PrepareExaminationTime, 'value', 'label'); export default class extends Component { constructor(props) { super(props); this.stepProp = { 0: { title: '我的身份', }, 1: { title: '下次考试时间', }, 2: { title: '目标成绩', }, 3: { title: '最晚出分时间(选填)', }, 4: { title: '备考信息', onConfirm: props.onConfirm, onCancel: props.onCancel, confirmText: '关闭', cancelText: '修改', }, }; this.state = { step: 0, data: {} }; My.getPrepare() .then(result => { this.setState({ data: result, first: !result.prepareStatus }); }); } onChange(type, key) { const { data, step } = this.state; data[type] = key; this.setState({ data, step: step + 1 }); } onPrev() { const { step } = this.state; this.setState({ step: step - 1 }); } onNext() { const { step } = this.state; this.setState({ step: step + 1 }); } submitPrepare() { const { data } = this.state; My.editPrepare(data) .then(result => { this.setState({ result }); this.onNext(); }); } render() { const { step } = this.state; const { show, onClose } = this.props; return ( onClose && onClose()} >
{this[`renderStep${step}`]()}
); } renderStep0() { const { data } = this.state; const { prepareStatus } = data; return (
this.onChange('prepareStatus', key)} />
this.onNext()}> 下一题
); } renderStep1() { const { data } = this.state; const { prepareExaminationTime } = data; return (
this.onChange('prepareExaminationTime', key)} />
this.onPrev()}> 上一题
this.onNext()}> 下一题
); } renderStep2() { return (
this.onPrev()}> 上一题
this.onNext()}> 下一题
); } renderStep3() { return (
this.onPrev()}> 上一题
); } renderStep4() { const { first, data } = this.state; return (
{first &&
7天VIP权限已赠送至您的账户。
}
); } }