From ed27ace015406b5b6b266a6eba0fa5f2b94c8cb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 25 Oct 2019 15:27:12 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Competitioncommon/CompetitionCommon.js | 36 +-- .../CompetitionContentsChart.js | 241 ++++++++++-------- 2 files changed, 151 insertions(+), 126 deletions(-) diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js index 3c4c59b88..b34eee4ea 100644 --- a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js @@ -21,7 +21,8 @@ class CompetitionCommon extends Component{ module_type:undefined, mdContentdata:undefined, chart_rules:undefined, - Competitionedittype:false + Competitionedittype:false, + chartdata:undefined } } @@ -40,7 +41,6 @@ class CompetitionCommon extends Component{ console.log(error) }) } - } getbannerdata=()=>{ @@ -61,9 +61,8 @@ class CompetitionCommon extends Component{ }).catch((error) => { console.log(error) }) - //console.log(this.props) - if(this.props.user&&this.props.user.login!= ""){ + if(this.props.user&&this.props.user.login!= ""){ const zul = `/competitions/${this.props.match.params.identifier}/competition_staff.json`; axios.get((zul)).then((result) => { if (result) { @@ -99,7 +98,6 @@ class CompetitionCommon extends Component{ } getnewchartdata=(typeid,tabkey)=>{ - if(typeid==="chart"){ let url=`/competitions/${this.props.match.params.identifier}/chart_rules.json`; axios.get(url) @@ -117,9 +115,8 @@ class CompetitionCommon extends Component{ }) } } - getrightdata=(id,typeid,module_url,has_url,listkey)=>{ - + getrightdata=(id,typeid,module_url,has_url,listkey)=>{ if(typeid==="enroll"){ this.props.history.replace(`/newcompetitions/${this.props.match.params.identifier}/enroll`); return @@ -131,9 +128,17 @@ class CompetitionCommon extends Component{ let url=`${module_url}`; axios.get(url).then((response) => { if(response.status===200){ - this.setState({ - mdContentdata:response.data - }) + + if(typeid==="chart"){ + this.setState({ + chartdata:response.data + }) + }else{ + this.setState({ + mdContentdata:response.data + }) + } + } }).catch((error) => { console.log(error) @@ -147,14 +152,13 @@ class CompetitionCommon extends Component{ module_id:id, module_type:typeid }) + } Competitionedit=()=>{ - this.setState({ Competitionedittype:true }) - } hideCompetitionedit=()=>{ @@ -175,7 +179,6 @@ class CompetitionCommon extends Component{ } if(url===undefined){ let {data,signupdata}=this.state; - if(signupdata.enrolled===true){ this.props.history.replace(`/courses/${data.course_id}`); }else{ @@ -194,19 +197,18 @@ class CompetitionCommon extends Component{ } }) } - } }else{ this.props.history.replace(url); } - } - Competitioncallback=(key)=>{ + Competitioncallback=(key)=>{ this.setState({ tabkey:key }) } + render() { let {data,bannerdata,module_type,Competitionedittype,mdContentdata}=this.state; @@ -300,7 +302,6 @@ class CompetitionCommon extends Component{ this.getrightdatas(e)}> - {data&&data.competition_modules.map((item,key)=>{ return( @@ -314,7 +315,6 @@ class CompetitionCommon extends Component{ ) })} - diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionContentsChart.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionContentsChart.js index bd706d649..1a43c89cb 100644 --- a/public/react/src/modules/competitions/Competitioncommon/CompetitionContentsChart.js +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionContentsChart.js @@ -19,9 +19,14 @@ class CompetitionContents extends Component{ window.document.title = '竞赛'; } - render() { - const operations = ; + const operations = +
+ + +
const columns = [ { title: 'usersum', @@ -61,143 +66,163 @@ class CompetitionContents extends Component{ }, ]; - const data = [ - { - usersum: '1', - userimg: 'John Brown', - username: "小头鹰", - school: '吉首大学', - spendtime: '15:00:00', - score:123123 + const data = []; + let {chart_rules,chartdata}=this.props; + chartdata===undefined?"":chartdata.teams.length===0?"":chartdata.teams.map((item,key)=>{ + if(key>3){ + let list={ + usersum:key, + userimg:item.user_image, + username:item.record_user_name, + school:item.school_name, + spendtime:item.spend_time, + score:item.score, + user_login:item.user_login + } + data.push(list) } - ]; + }) - let {chart_rules,tabkey}=this.props; + console.log(this.props.chartdata&&this.props.chartdata.user_ranks) return (
{chart_rules===undefined?"":this.props.Competitioncallback(e)} activeKey={this.props.tabkey} tabBarExtraContent={this.props.current_user&&this.props.current_user.admin===true||this.props.current_user&&this.props.current_user.business===true?this.props.Competitionedittype===false?operations:"":""}> - {chart_rules.stages.map((item,key)=>{ return( {chart_rules.rule_contents.map((items,keys)=>{ if(item.id===items.competition_stage_id){ return( - - + ) }else if(item.id===null&&items.competition_stage_id===0){ return( - - + ) } })} ) })} - } - - 总排名 - + 总排名 - - -
  • - -
    - - -

    蒙睿

    -
    + {chartdata===undefined?"":chartdata.teams.length===0?"":chartdata.teams.map((item,key)=>{ + + if(key===1){ + return( + + +
  • + + +
  • +
    + } + > + +
    {item.school_name}
    +
    {item.spend_time}
    + } + description={ +
    {item.score}分
    + } + + /> + + + + ) + } + + if(key===2){ + return( + + +
  • + +
    + + +

    {item.record_user_name}

    +
    +
    +
  • + + } + > + +
    {item.school_name}
    +
    {item.spend_time}
    + } + description={ +
    {item.score}分
    + } + + /> +
    + + ) + } + + if(key===3){ + return( + + +
  • + +
    + + +

    {item.user_name}

    +
    +
    +
  • - - - } - > - -
    吉首大学
    -
    78:01:02
    - } - description={ -
    3423.45分
    - } - /> -
    - - - -
  • - -
    - - -

    李羿锟

    -
    -
    -
  • - - } - > - -
    吉首大学
    -
    78:01:02
    - } - description={ -
    3423.45分
    - } - - /> -
    - - - - -
  • - -
    - - -

    陈翊

    -
    -
    -
  • - - } - > - -
    吉首大学
    -
    78:01:02
    - } - description={ -
    3423.45分
    - } - - /> -
    - + } + > + +
    {item.school_name}
    +
    {item.spend_time}
    + } + description={ +
    {item.score}分
    + } + /> + + + + ) + } + + })} + - + {chartdata===undefined?"":chartdata.teams.length===0?"":
    }