import React, { Component } from 'react'; import { Breadcrumb,Layout,Table, Divider, Tag,Badge,Row, Col,Button, Menu, Icon} from 'antd'; import { Link } from 'react-router-dom'; import axios from 'axios'; import {markdownToHTML,getImageUrl} from 'educoder'; import CompetitionContents from './CompetitionContents'; import CompetitionContentsChart from './CompetitionContentsChart'; import NoneData from "../../courses/shixunHomework/shixunHomework"; import './CompetitionCommon.css'; const { Header, Footer, Sider, Content } = Layout; class CompetitionCommon extends Component{ constructor(props) { super(props) this.state={ data:undefined, bannerdata:undefined, module_type:undefined, mdContentdata:undefined } } componentDidMount(){ window.document.title = '竞赛'; if(this.props.match.params.identifier!=null){ this.getbannerdata(); let url=`/competitions/${this.props.match.params.identifier}.json`; axios.get(url).then((response) => { if(response.status===200){ this.setState({ bannerdata:response.data }) } }).catch((error) => { console.log(error) }) } } getbannerdata=()=>{ let url=`/competitions/${this.props.match.params.identifier}/common_header.json`; axios.get(url).then((response) => { if(response.status===200){ this.setState({ data:response.data, }) this.getrightdata( response.data.competition_modules[0].id, response.data.competition_modules[0].module_type, response.data.competition_modules[0].module_url, response.data.competition_modules[0].has_url ) } }).catch((error) => { console.log(error) }) } getrightdata=(id,typeid,module_url,has_url)=>{ console.log(id,typeid,module_url,has_url) this.setState({ module_id:id, module_type:typeid }) if(has_url===false){ let url=`${module_url}`; axios.get(url).then((response) => { if(response.status===200){ this.setState({ mdContentdata:response.data }) } }).catch((error) => { console.log(error) }) } } render() { let {data,bannerdata,module_type,module_id,mdContentdata}=this.state; console.log(module_type) return ( data===undefined?"":