默认显示当期开课

dev_hs
杨树明 6 years ago
parent 8f9db17c91
commit ed78052620

@ -30,39 +30,42 @@ class DetailTop extends Component{
} }
} }
componentDidMount(){ componentDidMount(){
let courseslist=[] this.getdatalist();
}
getdatalist=()=>{
let courseslist=[];
let keys=1;
if(this.props.courses!=undefined&&this.props.courses.length!=0){ if(this.props.courses!=undefined&&this.props.courses.length!=0){
if(this.props.detailInfoList.has_start===true){
this.props.courses.map((item,key)=>{ this.props.courses.map((item,key)=>{
if(this.props.pathtopskey===key+1){ if(item.course_status.status===1){
keys=key+1
return( return(
courseslist.push(item) courseslist.push(item)
) )
} }
}) })
}
this.setState({
courseslist:courseslist
})
}
componentDidUpdate=(prevProps)=> { }else{
if(prevProps.courses!=this.props.courses){
let courseslist=[]
if(this.props.courses!=undefined&&this.props.courses.length!=0){
this.props.courses.map((item,key)=>{ this.props.courses.map((item,key)=>{
if(this.props.pathtopskey===key+1){ if(this.props.pathtopskey===key+1){
keys=key+1
return( return(
courseslist.push(item) courseslist.push(item)
) )
} }
}) })
} }
}
this.setState({ this.setState({
courseslist:courseslist courseslist:courseslist,
MenuItemskey:keys,
}) })
} }
componentDidUpdate=(prevProps)=> {
if(prevProps.courses!=this.props.courses){
this.getdatalist();
}
} }

Loading…
Cancel
Save