import React from 'react';
import { Form, Row, Col, Avatar, Button, Modal, Input, Upload } from 'antd';
import './index.less';
import Page from '@src/containers/Page';
import Block from '@src/components/Block';
import TableLayout from '@src/layouts/TableLayout';
import ShowImage from '@src/components/ShowImage';
import { formatDate, getMap, formatMoney, formatSeconds } from '@src/services/Tools';
import { asyncSMessage, asyncForm, asyncDelConfirm } from '@src/services/AsyncTools';
import { PcUrl, PrepareStatus, PrepareExaminationTime, ServiceKey } from '../../../../Constant';
import { User } from '../../../stores/user';
import { System } from '../../../stores/system';
import { Exercise } from '../../../stores/exercise';
const PrepareStatusMap = getMap(PrepareStatus, 'value', 'label');
const PrepareExaminationTimeMap = getMap(PrepareExaminationTime, 'value', 'label');
const ServiceKeyMap = getMap(ServiceKey, 'value', 'label');
export default class extends Page {
init() {
this.categoryMap = {};
this.moneyList = [{
key: 'id',
type: 'hidden',
}, {
key: 'money',
type: 'number',
name: '增加金额',
min: 0,
}];
this.columns = [{
title: '订单时间',
dataIndex: 'createTime',
render: (text) => {
return formatDate(text, 'YYYY-MM-DD HH:mm:ss');
},
}, {
title: '购买',
dataIndex: 'service',
render: (text, record) => {
return `${ServiceKeyMap[text]} ${record.isUse ? '已使用' : ''}`;
},
}, {
title: '消费金额',
dataIndex: 'money',
render: (text) => {
return formatMoney(text);
},
}];
Exercise.allStruct().then(result => {
this.categoryMap = getMap(result.filter(row => row.level === 2).map(row => { row.title = `${row.titleZh}/${row.titleEn}`; row.value = row.id; return row; }), 'id', 'title');
this.setState({ exercise: result });
});
}
initData() {
const { id } = this.params;
let handler;
if (id) {
handler = User.get({ id });
} else {
handler = Promise.resolve();
}
handler
.then(result => {
this.setState({ data: result });
this.refreshService(this.state.search.page, this.state.search.size);
});
}
realAction() {
this.open({ id: this.state.data.id }, 'real');
}
changeInfo(field, value) {
const { real = {}, realEmpty = {} } = this.state;
real[field] = value;
if (value) realEmpty[field] = !value;
this.setState({ real, realEmpty });
}
submitReal() {
const { real = {}, realEmpty = {} } = this.state;
if (!real.realIdentity || !real.realName) {
realEmpty.realIdentity = !real.realIdentity;
realEmpty.realName = !real.realName;
this.setState({ realEmpty });
return;
}
User.real(real).then(() => {
this.close(true, 'real');
});
}
addMoneyAction() {
asyncForm('增加金额', this.moneyList, { id: this.state.data.id }, data => {
return User.addMoney(data).then(() => {
asyncSMessage('添加成功!');
this.refresh();
});
});
}
frozenAction() {
asyncDelConfirm('操作确认', '是否要封禁账户?封禁后账户无法使用网站', () => {
return User.frozen({ id: this.state.data.id })
.then(() => {
asyncSMessage('操作成功!');
this.refresh();
});
});
}
noFrozenAction() {
asyncDelConfirm('操作确认', '是否要取消封禁账户?取消后账户可以使用网站', () => {
return User.noFrozen({ id: this.state.data.id })
.then(() => {
asyncSMessage('操作成功!');
this.refresh();
});
});
}
refreshService(p, size) {
const { id } = this.params;
const { page } = this.state;
page.current = p || 1;
page.pageSize = size || 20;
this.setState({ page });
User.listService({ userId: id, page: page.current, size: page.pageSize, order: 'createTime', direction: 'desc' })
.then(result => {
this.setTableData(result.list, result.total);
});
}
renderBase() {
const { data = {} } = this.state;
return {data.totalMoney} {ServiceKeyMap[service.service]}: {formatDate(service.startTime, 'YYYY-MM-DD HH:mm:ss')} - {formatDate(service.expireTime, 'YYYY-MM-DD HH:mm:ss')} {formatSeconds(data.totalTime)}用户基本信息{data.isFrozen === 0 && }
{data.isFrozen === 1 && }
服务开通
累计消费金额
已开通服务
{(data.services || []).map(service => {
return 消费记录
学习统计
累计学习时间
学习数据