diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js index f3177cece..96600534c 100644 --- a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js @@ -16,46 +16,69 @@ class CompetitionCommon extends Component{ super(props) this.state={ data:undefined, - bannerdata:undefined + bannerdata:undefined, + module_type:undefined } } componentDidMount(){ window.document.title = '竞赛'; - this.getbannerdata(); - let url=`/competitions/${this.props.match.params.identifier}.json`; + 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({ - bannerdata:response.data + 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) }) } - getbannerdata=()=>{ - let url=`/competitions/${this.props.match.params.identifier}/common_header.json`; + getrightdata=(id,typeid,module_url,has_url)=>{ + console.log(id,typeid,module_url,has_url) + this.setState({ + module_id:id, + module_type:typeid + }) + let url=`${module_url}.json`; axios.get(url).then((response) => { if(response.status===200){ - this.setState({ - data:response.data - }) + this.setState({ + mdContent:response.data + }) } }).catch((error) => { console.log(error) }) - - } - - getrightdata=(id,typeid)=>{ -debugger } render() { - let {data,bannerdata}=this.state; - // console.log(bannerdata) + let {data,bannerdata,module_type,module_id,mdContent}=this.state; + console.log(module_type) return ( data===undefined?"":