import React, { Component } from 'react'; import './index.less'; import { Icon } from 'antd-mobile'; import Assets from '@src/components/Assets'; import { getMap, formatDate } from '@src/services/Tools'; import { CrowdList, ServiceParamMap } from '../../../Constant'; import Tag from '../Tag'; import Money from '../Money'; import Button from '../Button'; const CrowdMap = getMap(CrowdList, 'value', 'label'); const ServiceParamRelation = getMap(Object.keys(ServiceParamMap).map(key => { const list = (ServiceParamMap[key] || []).map((row, index) => { row.index = index; return row; }); return { map: getMap(list, 'value'), key }; }), 'key', 'map'); export class Block extends Component { render() { const { className = '', children, onClick } = this.props; return
onClick && onClick()}>{children}
; } } export class TopBlock extends Component { render() { const { className = '', theme = 'default', children, onClick } = this.props; return
onClick && onClick()}>{children}
; } } export class TagBlock extends Component { render() { const { className = '', theme = 'default', tag, children, onClick } = this.props; return (
onClick && onClick()}>
{tag}
{children}
); } } export class LinkBlock extends Component { render() { const { className = '', theme = 'default', title, sub, onClick } = this.props; return (
onClick && onClick()}>
{title}
{sub}
); } } export class CourseBlock extends Component { render() { const { data } = this.props; const comment = data.comments ? data.comments[0] : {}; return ( { linkTo(`/product/course/detail/${data.id}`); }}>
{data.title}
授课老师{data.teacher}
{comment.content}
{CrowdMap[data.crowd] && 适合{CrowdMap[data.crowd]}}
优质回答{data.askNumber}
); } } export class CoursePackageBlock extends Component { render() { const { theme, data } = this.props; const comment = data.comments ? data.comments[0] : {}; return ( { linkTo(`/product/course/package/${data.id}`); }}>
{data.title}
授课老师{(data.courses || []).map(row => { return {row.teacher}; })}
{CrowdMap[data.crowd] && 适合{CrowdMap[data.crowd]}}
{comment.content}
); } } export class DataBlock extends Component { render() { const { data } = this.props; const comment = data.comments ? data.comments[0] : {}; return ( { linkTo(`/product/data/detail/${data.id}`); }}>
{data.title}
{comment.content}
{data.saleNumber}人已购
); } } export class BuyBlock extends Component { render() { const { theme, data, onBuy, onOpen, onRead } = this.props; const now = new Date().getTime(); let { title, price } = data; if (data.productType === 'course') { ({ title, price } = (data.course || {})); } if (data.productType === 'data') { ({ title, price } = (data.data || {})); } if (data.productType === 'service') { const p = ServiceParamRelation[data.service][data.param]; const index = p ? p.index : 0; ({ title, price } = (data.serviceInfo || {}).package[index]); } const expire = data.useEndTime && new Date(data.useEndTime).getTime() < now.getTime(); return (
{expire && < Tag theme="border" radius size="small"> 已到期 } {!expire && data.productType !== 'data' && data.isUsed && < Tag theme="border" radius size="small"> 已开通 } {!expire && data.productType !== 'data' && !data.isUsed && < Tag theme="border" radius size="small"> 未开通 } {title}
{((data.useEndTime || data.endTime) && data.productType === 'service') &&
有效期:{formatDate(data.useEndTime || data.endTime, 'YYYY-MM-DD')}
} {data.productType === 'data' &&
最新更新:{formatDate(data.data.latestTime, 'YYYY-MM-DD HH:mm:ss')}
} {data.productType === 'course' && !data.isUsed &&
有效期:{formatDate(data.endTime, 'YYYY-MM-DD')}
} {data.productType === 'course' && data.isUsed &&
课程学习时间:{formatDate(data.useStartTime, 'YYYY-MM-DD')}-{formatDate(data.useEndTime, 'YYYY-MM-DD')}
} {data.service !== 'textbook' && !data.isUsed &&
请访问千行 GMAT 官网开通使用
} {data.service === 'textbook' && expire &&
您可至PC端「我的工具」查看往期机经
}
{data.service === 'textbook' && !data.isUsed && } {expire && data.service !== 'vip' && } {data.service === 'vip' && } {data.productType === 'data' && data.data.resource && } {!expire && data.service === 'textbook' && }
{data.service === 'vip' &&
¥{price}/{title}
}
); } }