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.isFrozen === 0 && } {data.isFrozen === 1 && }

个人资料

{data.id} {data.nickname} {data.mobile} {data.wechatUnionid ? '已绑定' : '未绑定'} {data.email ? '已绑定' : '未绑定'} {data.createTime && formatDate(data.createTime, 'YYYY-MM-DD HH:mm:ss')}

实名认证{}

{data.realStatus > 0 && {data.realIdentity} {data.realName} {data.realAddress} }

备考信息

{data.prepareTime && {PrepareStatusMap[data.prepareStatus]} {PrepareExaminationTimeMap[data.prepareExaminationTime]} {data.prepareScoreTime ? formatDate(data.prepareScoreTime, 'YYYY-MM-DD HH:mm:ss') : ''} {data.prepareGoal} }
; } renderService() { const { data = {} } = this.state; return

服务开通

累计消费金额

{data.totalMoney}

已开通服务

{(data.services || []).map(service => { return

{ServiceKeyMap[service.service]}: {formatDate(service.startTime, 'YYYY-MM-DD HH:mm:ss')} - {formatDate(service.expireTime, 'YYYY-MM-DD HH:mm:ss')}

; })}

消费记录

this.refreshService(pagination.current, pagination.pageSize)} />
; } renderStudy() { const { data = {} } = this.state; return

学习统计

累计学习时间

{formatSeconds(data.totalTime)}

学习数据

; } renderView() { const { real, realEmpty = {} } = this.state; return
{this.renderBase()} {this.renderService()} {this.renderStudy()} {real && { this.close(false, 'real'); }} onOk={() => { this.submitReal(); }}>
{ this.changeInfo('realIdentity', e.target.value); }} /> { this.changeInfo('realName', e.target.value); }} /> { this.changeInfo('realAddress', e.target.value); }} /> System.uploadImage(file).then((result) => { this.changeInfo('realPhotoFront', result.url); return Promise.reject(); })} > System.uploadImage(file).then((result) => { this.changeInfo('realPhotoBack', result.url); return Promise.reject(); })} >
}
; } }