import React from 'react'; import './index.less'; import Page from '@src/containers/Page'; import { formatDate, formatMonth, getMap } from '@src/services/Tools'; import { Course } from '../../../stores/course'; import { My } from '../../../stores/my'; import { PrepareStatus, ExperiencePercent } from '../../../../Constant'; const PrepareStatusMap = getMap(PrepareStatus, 'value', 'short'); const ExperiencePercentMap = getMap(ExperiencePercent, 'value', 'label'); export default class extends Page { initState() { return { data: {}, }; } initData() { const { id } = this.params; Course.getExperience(id) .then(result => { this.setState({ data: result }); }); Course.experienceView(id); } onCollect() { const { data } = this.state; const { collect } = this.state; let collectStatus = false; if (collect !== undefined) { collectStatus = collect; } else { collectStatus = data.collect; } if (!collectStatus) { My.addExperienceCollect(data.id) .then(() => { this.setState({ collect: true }); }); } else { My.delExperienceCollect(data.id) .then(() => { this.setState({ collect: false }); }); } } renderView() { const { data = {}, collect } = this.state; let collectStatus = false; if (collect !== undefined) { collectStatus = collect; } else { collectStatus = data.collect; } return (