import React from 'react'; import './index.less'; import Page from '@src/containers/Page'; import Assets from '@src/components/Assets'; import { getMap, formatDate } from '@src/services/Tools'; import Checkbox from '../../../components/CheckBox'; import Button from '../../../components/Button'; import Icon from '../../../components/Icon'; import { Order } from '../../../stores/order'; import { ServiceKey } from '../../../../Constant'; const ServiceKeyMap = getMap(ServiceKey, 'value', 'label'); export default class extends Page { initState() { return { state: 'open' }; } initData() { const { id } = this.params; Order.getRecord(id) .then(result => { if (result.isUse) { this.setState({ state: 'finish', data: result }); return; } this.setState(result); }); } submit() { Order.useRecord(this.params.id) .then((result) => { this.setState({ state: 'finish', data: result }); }); } renderView() { const { state } = this.state; switch (state) { case 'finish': return this.renderFinish(); default: return this.renderOpen(); } } renderOpen() { const { productType } = this.state; if (productType === 'service') { return this.renderService(); } return this.renderCourse(); } renderCourse() { const { course = {}, endTime } = this.state; if (!endTime) return null; return (
您正在开通“{course.data}”
有效期至:{formatDate(endTime, 'YYYY-MM-DD')}
{ goBack(); }}>暂不开通
); } renderService() { const { service, endTime } = this.state; if (!endTime) return null; return (
您正在开通“{ServiceKeyMap[service]}”服务
有效期至:{formatDate(endTime, 'YYYY-MM-DD')}
{service === 'textbook' &&
{ this.setState({ checked: !this.state.checked }); }} /> 邮箱订阅机经
}
{ goBack(); }}>暂不开通
); } renderFinish() { const { data } = this.state; return (
开通成功!
生效时间:{formatDate(data.useStartTime, 'YYYY-MM-DD')}
); } }