From 7bf8bb9a75d24d08ec1783efd9c07d6b0ac81082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Tue, 5 Nov 2019 11:33:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Competitioncommon/CompetitionCommon.js | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js index e9733b079..bde5895e1 100755 --- a/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js +++ b/public/react/src/modules/competitions/Competitioncommon/CompetitionCommon.js @@ -30,8 +30,6 @@ class CompetitionCommon extends Component{ componentDidMount(){ window.document.title = '竞赛'; - console.log("CompetitionCommon"); - console.log(this.props); if(this.props.match.params.identifier!=null){ this.getbannerdata(); // this.setState({ @@ -50,9 +48,30 @@ class CompetitionCommon extends Component{ } } + componentDidUpdate = (prevProps) => { + if (prevProps.user != this.props.user) { + + console.log("componentDidUpdatess"); + console.log(this.props.user); + 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) { + if (result.data) { + this.setState({ + signupdata: result.data + }) + } + } + }).catch((error) => { + //console.log(error); + }) + } + } + + } //获取头部信息 getbannerdata=()=>{ - debugger let menuid=this.props.location.search.replace('?menu=', ''); let url=`/competitions/${this.props.match.params.identifier}/common_header.json`; axios.get(url).then((response) => { @@ -86,8 +105,9 @@ class CompetitionCommon extends Component{ }).catch((error) => { console.log(error) }) - console.log("CompetitionCommonCompetitionCommon"); - console.log(this.props.user); + + //this.props.user 有可能为空 + if (this.props.user && this.props.user.login != "") { const zul = `/competitions/${this.props.match.params.identifier}/competition_staff.json`; axios.get((zul)).then((result) => {