diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js index a83f799fb..40bf83f5e 100644 --- a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js @@ -60,6 +60,22 @@ class CompetitionCommon extends Component{ }).catch((error) => { console.log(error) }) + + // console.log("调用了GetenrollmentAPI"); + const zul = `/competitions/${this.props.match.params.identifier}/competition_staff.json`; + axios.get((zul)).then((result) => { + if (result) { + if (result.data) { + + this.setState({ + signupdata:result.data + }) + + } + } + }).catch((error) => { + //// //////console.log(error); + }) } getrightdatas=(e)=>{ @@ -80,7 +96,7 @@ class CompetitionCommon extends Component{ }) } getrightdata=(id,typeid,module_url,has_url)=>{ - console.log(id,typeid,module_url,has_url) + this.setState({ module_id:id, module_type:typeid @@ -122,10 +138,47 @@ class CompetitionCommon extends Component{ } + gotocourse=(url)=>{ + if(this.props.checkIfLogin()===false){ + this.props.showLoginDialog() + return + } + if(this.props.checkIfProfileCompleted()===false){ + this.props.showProfileCompleteDialog() + return + } + if(url===undefined){ + let {data,signupdata}=this.state; + + if(signupdata.enrolled===true){ + this.props.history.replace(`/courses/${data.course_id}`); + }else{ + if(data.member_of_course===true){ + this.props.history.replace(`/courses/${data.course_id}`); + }else{ + // 以学生身份调用加入课堂 进入课堂首页 + let url="/courses/apply_to_join_course.json" + axios.post(url, { + invite_code:data.invite_code, + student:1 + } + ).then((response) => { + if(response.data.status===0){ + this.props.history.replace(`/courses/${data.course_id}`); + } + }) + } + + } + }else{ + this.props.history.replace(url); + } + + } render() { let {data,bannerdata,module_type,Competitionedittype,mdContentdata}=this.state; - console.log(module_type) + return ( data===undefined?"":