import React from 'react'; import './index.less'; import Page from '@src/containers/Page'; import Assets from '@src/components/Assets'; import { getMap, formatDate } from '@src/services/Tools'; import Footer from '../../../components/Footer'; import { Contact, AnswerCarousel, Comment } from '../../../components/Other'; import { FaqModal, CommentModal, FinishModal } from '../../../components/OtherModal'; import Tabs from '../../../components/Tabs'; import Button from '../../../components/Button'; import { User } from '../../../stores/user'; import { Course } from '../../../stores/course'; import { Order } from '../../../stores/order'; import { Main } from '../../../stores/main'; export default class extends Page { initState() { return { tab: '1', }; } init() { Main.dataStruct().then(result => { const dataStructSelect = result.map(row => { return { title: `${row.titleZh}${row.titleEn}`, key: row.id, }; }); const dataStructMap = getMap(dataStructSelect, 'key'); this.setState({ dataStructSelect, dataStructMap }); }); Main.getBase().then(result => { this.setState({ base: result }); }); } initData() { const { id } = this.params; Course.getData(id).then(result => { this.setState({ data: result }); }); this.view(id); Main.listFaq({ page: 1, size: 100, channel: 'course_data', position: id }).then(result => { this.faqs = result.list; this.setState({ faqs: result.list }); }); Main.listComment({ page: 1, size: 100, channel: 'course_data', position: id }).then(result => { this.comments = result.list; this.setState({ comments: result.list }); }); } onChangeTab(tab) { this.setState({ tab }); } view(id) { Course.dataView(id); } buy() { const { data } = this.props; User.needLogin().then(() => { Order.speedPay({ productType: 'data', productId: data.id }).then(result => { User.needPay(result).then(() => { linkTo('/my/tools?tab=data'); }); }); }); } add() { const { data } = this.props; User.needLogin().then(() => { Order.addCheckout({ productType: 'data', productId: data.id }).then(() => { this.setState({ add: true }); }); }); } renderView() { const { base = {}, data = {}, dataStructMap = {}, showComment, showFinish, comment = {}, showFaq, faq = {} } = this.state; return (