import React from 'react'; import './index.less'; import { Icon } from 'antd'; import Page from '@src/containers/Page'; import Assets from '@src/components/Assets'; import Footer from '../../../components/Footer'; import { Contact, Comment, Consultation, AnswerCarousel } from '../../../components/Other'; import Tabs from '../../../components/Tabs'; import Button from '../../../components/Button'; import { Main } from '../../../stores/main'; import { Order } from '../../../stores/order'; import { User } from '../../../stores/user'; import { Course } from '../../../stores/course'; import { CourseVsType } from '../../../../Constant'; export default class extends Page { initState() { return { info: '1', number: 0, }; } init() { this.courseVsMap = {}; this.faqMap = {}; this.faqs = []; this.commentMap = {}; this.comments = []; this.promote = []; this.teacherMap = {}; Main.getPromote().then(result => { this.promote = result.vs_list || []; this.setState({ promote: result }); }); Main.getBase().then(result => { this.setState({ base: result }); }); } initData() { Course.allVs().then(result => { result.forEach(row => { this.courseVsMap[row.vsType] = row; }); this.onChangeItem(CourseVsType[0].value); }); } onChangeTab(info) { this.setState({ info }); } onChangeItem(key) { const item = this.courseVsMap[key]; if (!this.faqs) { Main.listFaq({ page: 1, size: 100, channel: 'course-vs_index' }).then(result => { this.faqs = result.list; this.setState({ faqs: result.list }); }); } if (!this.commentMap[key]) { Main.listComment({ page: 1, size: 100, channel: 'course-vs', position: item.id }).then(result => { this.commentMap[key] = result.list; this.setState({ comments: result.list }); }); } if (!this.teacherMap[key]) { Course.allTeacher(item.id).then(result => { this.teacherMap[key] = result.list; this.setState({ teachers: result.list }); }); } this.setState({ key, data: item, faqs: this.faqs, comments: this.commentMap[key], teachers: this.teacherMap[key] }); this.changeNumber(item.minNumber || 1); } changeNumber(number) { const { data } = this.state; let price = data.price * number; let max = 0; let maxIndex = -1; this.promote.forEach((row, i) => { if (row.number <= number) { if (row.number > max) { max = number; maxIndex = i; } } }); if (maxIndex >= 0) { price *= this.promote[maxIndex].percent / 100; } this.setState({ number, price }); } buy() { const { data } = this.props; Order.speedPay({ productType: 'course', productId: data.id }).then(result => { User.needPay(result).then(() => { linkTo('/my/course'); }); }); } add() { const { data } = this.props; Order.addCheckout({ productType: 'course', productId: data.id }).then(() => { this.setState({ add: true }); }); } renderView() { const { number } = this.props.order; const { promote = {}, base = {} } = this.state; return (
{(promote.vs || {}).text ? `优惠活动:${promote.vs.text}` : ''} linkTo('/cart')} /> ( {number || 0} )
{this.renderDetail()}
); } renderDetail() { const { info, key, data, number, price } = this.state; return [
{CourseVsType.map(t => { const course = this.courseVsMap[t.value] || {}; return (
this.onChangeItem(t.value)}>
{course.title}
{course.comment}
); })}
适合人群
课时数
授课流程
课程有效期
{data.expirePreDays}天/10课时
购买课时
number < data.maxNumber && this.setState({ number: number + 1 })} /> number !== 1 && number > data.minNumber && this.setState({ number: number - 1 })} />
课程总价
¥ {price}
,
this.onChangeTab(tab)} /> {this[`renderTab${info}`]()}
, ]; } renderTab1() { return (
李奕都(DUKB24)
针对 0G20 的集中训练针对 0G20 的集中训练针对 0G20 的集中训练针对 0G20 的集中训练。针对 0G20 的集中训练针对 0G20 的集中训练针对 0G20 的集,中训练针对 0G20 的集中训练针对 0G20 的集中训练针对。 针对 0G20 的集中训。练针对 0G20 的集中训练针对 0G20 的集中训练针对 0G20 的集中训练。 针对 0G20 的集中训练针对 0G20 的集中训练针对 0G。
); } renderTab2() { return (
); } renderTab3() { return (
); } renderTab4() { return (
); } }