import React from 'react'; import { Link } from 'react-router-dom'; import './index.less'; import Assets from '@src/components/Assets'; import Page from '@src/containers/Page'; import { getMap, formatMoney } from '@src/services/Tools'; import Button from '../../../components/Button'; import { SingleItem } from '../../../components/Item'; import Footer from '../../../components/Footer'; import { Contact } from '../../../components/Other'; import { Main } from '../../../stores/main'; import { Course } from '../../../stores/course'; import { User } from '../../../stores/user'; import { Order } from '../../../stores/order'; import { ServiceKey, ServiceParamMap } from '../../../../Constant'; const serviceIconMap = { textbook: 'mokao', vip: 'VIP_1', qx_cat: 'jijing', }; export default class extends Page { constructor(props) { props.size = 10; super(props); } init() { Main.getBase() .then(result => { this.setState({ base: result }); }); } initData() { const { id } = this.params; Course.getPackage(id) .then(result => { this.setState({ data: result }); }); } buy() { const { data } = this.state; User.needLogin().then(() => { Order.speedPay({ productType: 'course_package', productId: data.id }).then(result => { User.needPay(result).then(() => { linkTo('/my/course'); }); }); }); } add() { const { data } = this.state; User.needLogin().then(() => { Order.addCheckout({ productType: 'course_package', productId: data.id }).then(() => { this.setState({ add: true }); }); }); } renderView() { const { data = {}, base = {}, add } = this.state; const hasGift = data.gift && Object.keys(data.gift).length > 0; return (
千行课堂 > 全部套餐 > {data.title} > 套餐详情
{data.title}
套餐价: ¥ {formatMoney(data.price)}
{data.description}
包含课程
{(data.courses || []).map(item => { return ; })}
配套服务
{hasGift &&
赠送服务
} {hasGift &&
{ServiceKey.map(row => { if (!data.gift[row.value]) return null; const list = ServiceParamMap[row.value]; const map = getMap(list || [], 'value', 'label'); return
{row.label}
{list ? map[data.gift[row.value]] : data.gift[row.value]}
; })}
}
); } }