import React, { Component } from 'react';
import './index.less';
import { Icon } from 'antd';
import Assets from '@src/components/Assets';
import Page from '@src/containers/Page';
import Modal from '../../../components/Modal';
import UserTable from '../../../components/UserTable';
import IconButton from '../../../components/IconButton';
import { Order } from '../../../stores/order';
import { User } from '../../../stores/user';
import { formatDate, formatMoney } from '../../../../../src/services/Tools';
// import { ServiceKey, ServiceParamMap, OrderInfoMap } from '../../../../Constant';
export default class extends Page {
initData() {
const { id } = this.params;
Order.getOrder(id)
.then(result => {
User.formatOrder(result);
this.setState({ order: result, list: result.checkouts });
});
}
renderView() {
const { order = {}, list = [] } = this.state;
return (
{(list || []).map(item => {
if (item.source === 'gift_course') return null;
return ;
})}
{(order.gift || []).map(item => {
return ;
})}
订单金额
应付金额
¥ {formatMoney(order.originMoney)}
{order.originMoney - order.money > 0 &&
优惠金额
¥ {formatMoney(order.originMoney - order.money)}
}
实付金额
¥ {formatMoney(order.money)}
支付信息
支付方式
{order.payMethod ? : '待确定'}
{/* alipay wechatpay bank */}
付款时间
{order.payTime ? formatDate(order.payTime, 'YYYY-MM-DD HH:mm:ss') : '待确定'}
);
}
}
class GiftItem extends Component {
render() {
const { data } = this.props;
let message = '';
if (data.money) {
message = `实付金额满${data.money}元赠送`;
} else if (data.from === 'vsNumber') {
message = `1VS1课程满${data.number}节赠送`;
}
return (
);
}
}
class OrderItem extends Component {
constructor(props) {
super(props);
this.state = { open: false, showList: false };
this.columns = [{
key: 'label',
title: '服务',
}, {
key: 'expireDays',
title: '开通有效期',
render: (text, checkout) => {
return checkout.expireDays ? `${checkout.expireDays}天` : '付款后立即生效';
},
}, {
key: 'useExpireDays',
title: '使用有效期',
render: (text, checkout) => {
return checkout.useExpireDays ? `${checkout.useExpireDays}天` : '永久';
},
}];
}
render() {
const { data = {} } = this.props;
const { showList } = this.state;
return (
{this.renderInfo()}
{(data.children || data.gift) && this.renderDetail()}
this.setState({ showList: false })}
className="order-modal"
>
);
}
renderInfo() {
const { data } = this.props;
const checkout = data;
return (
{data.title}
{checkout.productType !== 'course_package' && 开通有效期: {checkout.expireDays ? `${checkout.expireDays}天` : '付款后立即生效'}}
{checkout.productType !== 'course_package' && 使用有效期: {checkout.useExpireDays ? `${checkout.useExpireDays}天` : '永久'}}
{
openLink(checkout.data.resource);
}}
/>
{data.number > 0 && 数量}
{data.number > 0 && {data.number}}
¥ {data.money}
);
}
renderDetail() {
const { data = {} } = this.props;
const { children = [], gift } = data;
const { open } = this.state;
return (
包含
this.setState({ open: !open })}
/>
this.setState({ open: !open })}
/>
{(children || []).map(checkout => checkout.title).join(' + ')}
¥ {formatMoney(data.originMoney)}
{(children || []).map(checkout => {
return
{checkout.title}
开通有效期: {checkout.expireDays ? `${checkout.expireDays}天` : '付款后立即生效'}
使用有效期: {checkout.useExpireDays ? `${checkout.useExpireDays}天` : '永久'}
;
})}
{gift &&
赠送服务
{gift.map(row => {
return `${row.label}x${row.param ? row.param.label : row.number}`;
}).join(' ')}
{
this.setState({ showList: true });
}} />
}
);
}
}