import React from 'react'; import './index.less'; import { Tabs } from 'antd-mobile'; import Page from '@src/containers/Page'; import Assets from '@src/components/Assets'; import { formatDate, getMap } from '@src/services/Tools'; import Money from '../../../components/Money'; import Button from '../../../components/Button'; import Tag from '../../../components/Tag'; import { Course } from '../../../stores/course'; import { Order } from '../../../stores/order'; import { DataType } from '../../../../Constant'; import { FAQItem, CommentItem } from '../../../components/Item'; const DataTypeMap = getMap(DataType, 'value', 'label'); export default class extends Page { initState() { return { tab: 'content' }; } initData() { const { id } = this.params; Course.getData(id).then(data => { this.setState({ data }); }); } buy() { Order.speedPay({ productType: 'data', productId: this.params.id }) .then((result) => { linkTo(`/pay/${result.id}`); }); } renderText() { const { tab, data } = this.state; let content; switch (tab) { case 'content': case 'authorContent': case 'methodContent': content =
; break; case 'faq': content = (
{(data.faqs || []).map(row => ( ))}
); break; case 'comment': content = (
{(data.comments || []).map(row => ( ))}
); break; default: break; } return content; } renderView() { const { data = {}, tab } = this.state; return (
{data.title}
{data.isOriginal > 0 && 原创} {data.isNovice > 0 && 适合新手}
页数: {data.pages}页
格式: {DataTypeMap[data.dataType]}
{data.updateTime && formatDate(data.updateTime, 'YYYY-MM-DD HH:mm')} 更新
{ this.setState({ tab: value.key }); }} /> {this.renderText()}
总额:
); } }