import React,{ Component } from "react"; import { Modal,Radio,Input,Tooltip, Menu, Dropdown, Icon,Breadcrumb } from "antd"; import { BrowserRouter as Router, Route, Link } from "react-router-dom"; import SendPanel from "./sendPanel.js"; import { getImageUrl } from 'educoder'; import axios from 'axios'; import Modals from '../../modals/Modals'; import AccountProfile from"../../user/AccountProfile"; import OpenCourse from './OpenCourse'; import Jointheclass from '../../modals/Jointheclass'; import './DetailTop.css'; const Search = Input.Search; const RadioGroup = Radio.Group; class DetailTop extends Component{ constructor(props){ super(props) this.state={ cardsModalcancel:this.cardsModalcancel, cardsModalsave:this.cardsModalsave, Modalstype:false, Modalstopval:"", Modalsbottomval:'', loadtype:false, deletepathtype:false, cardsModalsavetype:false, MenuItemskey:1, courseslist:[], Pathcourseid:undefined, OpenCourseTypes:false, putappointmenttype:false, getappointmenttype:false } } componentDidMount(){ this.getdatalist(); } getdatalist=()=>{ let courseslist=[]; let keys=1; let listtype=false; if(this.props.courses!=undefined&&this.props.courses.length!=0){ if(this.props.detailInfoList.has_start===true){ this.props.courses.map((item,key)=>{ if(item.course_status.status===1){ keys=key+1 return( courseslist.push(item) ) } }) }else{ let type=undefined; this.props.courses.map((item,key)=>{ let arr=[] keys=key+1 if(item.course_status.status===2) { type=key+1 arr.push(item) } courseslist=arr; }) this.props.courses.map((item,key)=>{ let arr=[] if(listtype===false){ keys=key+1 if(item.course_status.status===0) { listtype=true // courseslist.push(item) arr.push(item) courseslist=arr } } }) console.log(courseslist) } if(courseslist.length!=0){ this.props.getMenuItemsindex(keys,courseslist[0].course_status.status) } } this.setState({ courseslist:courseslist, MenuItemskey:keys, }) } componentDidUpdate=(prevProps)=> { if(prevProps.courses!=this.props.courses){ this.getdatalist(); } } allow_deletepath=()=>{ this.setState({ Modalstype:true, Modalstopval:"是否删除路径?", deletepathtype:true }) } applyissuePath=()=>{ this.setState({ Modalstype:true, Modalstopval:"发布申请已提交,请等待管理员的审核", Modalsbottomval:"• 我们将在1-2个工作日内完成审核", loadtype:true }) } cancelissuePath=()=>{ let pathId=this.props.match.params.pathId; let url ="/paths/"+pathId+"/cancel_publish.json"; axios.get(url).then((result)=>{ if(result.status===200){ if(result.data.status===0){ }else if(result.data.status===1){ window.location.href = "/paths/" + result.data.subject_id } } }).catch((error)=>{ console.log(error); }) } reovkissuePath=()=>{ this.setState({ Modalstype:true, Modalstopval:"是否确认撤销发布", Modalsbottomval:"确认后,回退到编辑状态", cardsModalsavetype:true, }) } reovkissuePaths=()=>{ let pathId=this.props.match.params.pathId; let url ="/paths/"+pathId+"/cancel_has_publish.json"; axios.get(url).then((result)=>{ if(result.status===200){ if(result.data.status===0){ }else if(result.data.status===1){ this.setState({ cardsModalsavetype:false, loadtype:false, deletepathtype:false }) window.location.href = "/paths/" + result.data.subject_id } } }).catch((error)=>{ console.log(error); }) } cardsModalcancel=()=>{ this.setState({ Modalstype:false, Modalsbottomval:'', loadtype:false, deletepathtype:false, putappointmenttype:false }) } cardsModalsave=()=>{ let {loadtype,deletepathtype}=this.state; //删除路径 if(deletepathtype===true){ let pathid=this.props.match.params.pathId; const deleteUrl = `/paths/`+pathid+`.json`; axios.delete(deleteUrl).then((response) => { const status = response.data.status if (status === 1) { window.location.href = "/paths"; } }).catch((error) => { console.log(error) }) } //申请发布 if(loadtype===true){ let pathid=this.props.match.params.pathId; let url ="/paths/"+pathid+"/publish.json"; axios.get(url).then((result)=>{ if(result.status===200){ if(result.data.status===0){ this.setState({ Modalstype:true, Modalstopval: result.data.message, }) }else if(result.data.status===1){ window.location.reload(); } } }).catch((error)=>{ console.log(error); }) } this.setState({ Modalstype:false, Modalsbottomval:'' }) } onVisibleChanges=(type)=>{ this.setState({ onVisibleChangestype:type }) } MenuItems=(keys)=>{ let courseslist=[] this.props.courses.map((item,key)=>{ if(keys===key+1){ return( courseslist.push(item) ) } }) this.props.getMenuItemsindex(keys,courseslist[0].course_status.status) this.setState({ MenuItemskey:keys, courseslist:courseslist, onVisibleChangestype:!this.state.onVisibleChangestype }) } JoinnowCourse=(id,typeid)=>{ if(this.props.checkIfLogin()===false){ this.props.showLoginDialog() return } if(this.props.current_user&&this.props.current_user.profile_completed===false){ this.props.showProfileCompleteDialog() return } this.setState({ yslJointhe:true, Pathcourseid:id, pathcousestypeid:typeid }) } putappointment=()=>{ if(this.props.checkIfLogin()===false){ this.props.showLoginDialog() return } if(this.props.current_user&&this.props.current_user.profile_completed===false){ this.setState({ AccountProfiletype:true }) return } this.setState({ Modalstype:true, Modalstopval:"是否确认立即预约?", Modalsbottomval:"", cardsModalcancel:()=>this.cardsModalcancel(), putappointmenttype:true, loadtype:false }) } ysljoinmodalCancel=()=>{ this.setState({ yslJointhe:false }) }; ysljoinmodalCanceltwo=(key)=>{ this.setState({ yslJointhe:false }) this.props.getdatasindex(key) }; OpenCoursefun=()=>{ this.setState({ OpenCourseTypes:true }) } OpenCourseCancel=()=>{ this.setState({ OpenCourseTypes:false }) } getappointment=()=>{ let pathid=this.props.match.params.pathId; let url=`/paths/${pathid}/appointment.json` axios.post(url).then((response) => { if (response.status === 200) { if(response.data.status===0){ this.setState({ getappointmenttype:true }) this.cardsModalcancel() // this.props.getlistdatas() this.props.showNotification(response.data.message) }else{ this.props.showNotification(response.data.message) } } }).catch((error) => { console.log(error) this.cardsModalcancel() }) } hideAccountProfile=()=>{ this.setState({ AccountProfiletype:false }) } render(){ let{detailInfoList}=this.props; let{Modalstype,Modalstopval,cardsModalcancel,putappointmenttype,Modalsbottomval,cardsModalsavetype,loadtype,getappointmenttype,AccountProfiletype}=this.state; const radioStyle = { display: 'block', height: '30px', lineHeight: '30px', }; let menu = ( {this.props.courses===undefined||this.props.courses.length===0?"":this.props.courses.map((item,key)=>{ return( this.MenuItems(key+1)}> 第{key+1}次开课 ) })} ); let applypath=this.props.detailInfoList&&this.props.detailInfoList.participant_count!=undefined&&this.props.detailInfoList&&this.props.detailInfoList.allow_statistics===false; let coursestypes=this.props.courses!=undefined&&this.props.courses.length===0; let isadminallow_statistics=this.props.courses&&this.props.courses.length===0&&this.props.detailInfoList&&this.props.detailInfoList.allow_statistics===true; return(
40?"subhead mb100":"subhead mb70":this.state.MenuItemskey===this.props.courses.length?"subhead mb120":detailInfoList.name.length>40?"subhead mb100":"subhead mb80"}> {AccountProfiletype===true?this.hideAccountProfile()} {...this.props} {...this.state} />:""} this.reovkissuePaths():putappointmenttype===true?()=>this.getappointment():()=>this.cardsModalsave()} loadtype={loadtype} > {this.state.yslJointhe===true?this.ysljoinmodalCancel()} ysljoinmodalCanceltwo={()=>this.ysljoinmodalCanceltwo(this.state.MenuItemskey)}>:""} {this.state.OpenCourseTypes===true?this.OpenCourseCancel()}/>:""} { detailInfoList &&
{/*27?detailInfoList.name:""}>*/} {/**/} {detailInfoList.name} {detailInfoList===undefined?"":detailInfoList.excellent === false ? "" :
开放课程
}
{ detailInfoList &&
    { detailInfoList.stages_count!=0 ?
  • 章节{detailInfoList.stages_count}
  • : ""} { detailInfoList.shixuns_count!=0 ?
  • 实训{ detailInfoList.shixuns_count}
  • : ""} { detailInfoList.challenge_choose_count!=0 ?
  • 选择题任务{detailInfoList.challenge_choose_count}
  • : ""} { detailInfoList.challenges_count!=0 ?
  • 实践任务{detailInfoList.challenges_count}
  • : ""} { detailInfoList.subject_score!=0 ?
  • 经验值{detailInfoList.subject_score}
  • : ""} { detailInfoList.member_count!=0 ?
  • 学习人数{detailInfoList.member_count}
  • : ""}
}
{detailInfoList===undefined?"":detailInfoList.allow_statistics===true? 学习统计 :"" } { detailInfoList.allow_send === true?this.props.courses===undefined? :"":"" } {this.props.courses===undefined?"":detailInfoList.is_creator===true?this.OpenCoursefun()}>开课:""} { detailInfoList.publish_status===2 && detailInfoList.allow_statistics===true? 撤销发布:"" } { detailInfoList.publish_status===1 && detailInfoList.allow_statistics===true? 撤销申请:"" } { detailInfoList.publish_status===0&&detailInfoList.allow_add_member===true? 申请发布:"" } {detailInfoList===undefined?"":detailInfoList.allow_delete===true?删除:""} {detailInfoList===undefined?"":detailInfoList.allow_statistics===true? 编辑 :"" }
{this.props.courses===undefined||isadminallow_statistics===true?"":
{this.props.courses===undefined||this.props.courses.length===0?"":
  • {this.state.courseslist.map((item,key)=>{ if(item.course_identity<4){ return( )}}) } {this.state.MenuItemskey} 次开课
  • } {this.props.courses===undefined||this.props.courses.length===0?"":
  • {this.state.courseslist.map((item,key)=>{ return(
    开课时间:
    {item.start_date}
    结课时间:
    {item.end_date}
    报名人数:
    {item.student_count} 人
    ) }) }
  • } {this.props.courses===undefined||this.props.courses.length===0?"":
  • {/* height: 158px; }*/} {this.state.courseslist.map((item,key)=>{ return(
    {applypath===false?"":this.state.MenuItemskey===this.props.courses.length||coursestypes===true? this.props.detailInfoList&&this.props.detailInfoList.has_participate===false? getappointmenttype===true?预约报名成功:this.putappointment()}>期待开课并预约报名: 预约报名成功:""} {/*{item.course_status.status===0?
    即将开课
    :""}*/} {item.course_status.status===1?
    {item.course_status.time}
    :""} {item.course_status.status===2&&item.course_identity<6?
    已结束
    :""} {/*
    已结束
    */} {item.course_status.status===0? item.course_identity<5? 进入课堂 :item.course_identity<6?
    报名成功
    :this.JoinnowCourse(item.course_id)}>立即报名:""} {item.course_status.status===1? item.course_identity<5? 进入课堂 :item.course_identity<6? 立即学习 :this.JoinnowCourse(item.course_id,item.course_status.status)}>立即加入:""} {item.course_status.status===2? item.course_identity<6? 进入课堂 :
    已结束
    :""}
    )})}
  • } {applypath===false?"":this.state.MenuItemskey===this.props.courses.length?
    :""} {applypath===false?"":this.props.courses.length===0?"":this.state.MenuItemskey===this.props.courses.length||coursestypes===true? 当前预约报名人数:{getappointmenttype===true?this.props.detailInfoList&&this.props.detailInfoList.participant_count+1:this.props.detailInfoList&&this.props.detailInfoList.participant_count} 当预约报名人数达到 {this.props.detailInfoList&&this.props.detailInfoList.student_count} 人时即将开课 {/*{this.props.detailInfoList&&this.props.detailInfoList.has_participate===false?*/} {/*getappointmenttype===true?预约报名成功:this.putappointment()}>期待开课并预约报名:*/} {/*预约报名成功}*/} :""} {applypath===true&&this.props.courses.length===0?this.state.MenuItemskey===this.props.courses.length||coursestypes===true? 当前预约报名人数:{getappointmenttype===true?this.props.detailInfoList&&this.props.detailInfoList.participant_count+1:this.props.detailInfoList&&this.props.detailInfoList.participant_count} 当预约报名人数达到 {this.props.detailInfoList&&this.props.detailInfoList.student_count} 人时即将开课 {this.props.detailInfoList&&this.props.detailInfoList.has_participate===false? getappointmenttype===true?预约报名成功:this.putappointment()}>期待开课并预约报名: 预约报名成功} :"":""}
    }
    }
    ) } } export default DetailTop;