dev_sync_trustie
杨树明 5 years ago
parent d01ba55704
commit 0bab45a6f5

@ -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?"":<div className={"educontent clearfix mt20 "}>
@ -147,7 +170,7 @@ debugger
{data&&data.competition_modules.map((item,key)=>{
return(
<Menu.Item key={item.position}>
{item.has_url===false?<span onClick={()=>this.getrightdata(item.id,item.module_type)}>{item.name}</span>:<a
{item.has_url===false?<span onClick={()=>this.getrightdata(item.id,item.module_type,item.module_url,item.has_url)}>{item.name}</span>:<a
// target="_blank"
href={item.module_url}
// onClick={()=>this.getrightdata(item.id,item.module_type)}
@ -160,8 +183,13 @@ debugger
</Sider>
<Layout className={"teamsLayoutleft"}>
<CompetitionContents/>
<CompetitionContentsChart/>
{this.state.module_type==="chart"?<CompetitionContentsChart
{...this.props}
{...this.state}
/>:<CompetitionContents
{...this.props}
{...this.state}
/>}
</Layout>
</Layout>

@ -21,7 +21,7 @@ class CompetitionContents extends Component{
render() {
let{mdContent}=this.props;
return (
<div className={"fr"}>

Loading…
Cancel
Save