import React,{ Component } from "react"; import { Input,Checkbox,Table, Pagination, Modal,Menu, Tooltip,Spin,Button,Form,Icon,message,Progress,notification} from "antd"; import { WordsBtn,on, off, trigger,markdownToHTML,getImageUrl} from 'educoder'; import './myelearning.css' import axios from 'axios'; import YslDetailCards from "./YslDetailCards.js"; import Jointheclass from '../../modals/Jointheclass'; import LoginDialog from "../../login/LoginDialog"; //在线学习 class Elearning extends Component{ constructor(props){ super(props); this.state={ description:"", //简介 isSpin:true, start_learning:undefined, //是否要开始学习 没开始学习 点击第一个是开始学习 就是学习下面的从第一个开始 learned:0, //学习进度 last_shixun:"", //上次学习的实训 stages:[], //实践课程的章节 yslJointhe:false, shixunsreplace:false, hidestartshixunsreplacevalue:"", shixunsmessage:"", startshixunCombattype:false, isSpins:false, userlogin:"", isRender:false, } } componentDidMount() { // 记得删除退出课堂 console.log("获取到数据"); console.log(this.props); let url = `/courses/${this.props.match.params.coursesId}/online_learning.json`; // // axios.get(url).then((response) => { if(response){ if(response.data){ console.log("获取到到数据"); console.log(response); this.setState({ description: response.data.description, start_learning:response.data.start_learning, learned:response.data.learned, last_shixun:response.data.last_shixun, stages:response.data.stages, }); } } this.setState({ isSpin:false, }) }).catch((error) => { console.log(error); this.setState({ isSpin:false, }) }); try { if(this.props.current_user!==undefined){ this.setState({ userlogin :this.props.current_user.login, }) } }catch (e) { console.log("12312312312") console.log(e); } } componentDidUpdate = (prevProps) => { console.log("componentDidUpdate"); console.log(prevProps); console.log(this.props); if(prevProps.current_user!=this.props.current_user){ if(this.props.current_user!==undefined){ // console.log(this.props.current_user.login); // console.log(prevProps.current_user.login); this.setState({ userlogin :this.props.current_user.login, }) } } } //开始学习 Startlearning=()=>{ let {userlogin} = this.state; console.log("userlogin"); console.log(userlogin); if (userlogin === undefined) { this.setState({ isRender: true }) return } if (userlogin === "") { this.setState({ isRender: true }) return; } if(this.props.isNotMember()===true){ this.setState({ yslJointhe:true }) }else { let {stages}=this.state; if(stages.length>0){ var stagesdatas=[]; for(var i=0;i0){ this.kaishishixun(stagesdatas[0]); }else { notification.open({ message:"提示", description: "实训暂未公开!" }); } console.log("这是"+i); } } }; kaishishixun=(id)=>{ let url = "/shixuns/" + id + "/shixun_exec.json"; axios.get(url).then((response) => { console.log("精品课堂开发学习"); console.log(response); // console.log(JSON.stringify(response)); if (response.data.status === -2) { this.setState({ shixunsreplaces:true, hidestartshixunsreplacevalues:response.data.message+".json" }) } else if (response.data.status === -1) { console.log(response) }else if(response.data.status===-3){ this.setState({ shixunsmessages:response.data.message, startshixunCombattypes:true, }) } else { console.log("开始学习了"); window.open("/tasks/" + response.data.game_identifier,'_blank'); //这个是传过来 调用刷新 this.Myreload(); // window.location.href = path // let path="/tasks/"+response.data.game_identifier; // this.props.history.push(path); } }).catch((error) => { }); } Startlearningtwo=()=>{ this.setState({ yslJointhe:true }) }; ysljoinmodalCancel=()=>{ this.setState({ yslJointhe:false }) }; ysljoinmodalCanceltwo=()=>{ this.setState({ yslJointhe:false }) window.location.reload(); }; Myreload = ()=>{ window.location.reload(); }; hidestartshixunsreplace=(url)=>{ this.setState({ isSpins:true, }) axios.get(url).then((response) => { // debugger if(response.status===200){ // let path="/shixuns/"+response.data.shixun_identifier+"/challenges"; // this.props.history.push(path); message.success('重置成功,正在进入实训!'); this.startgameid(response.data.shixun_identifier); this.setState({ shixunsreplaces:false, isSpins:false, }) // message.success('重置成功,正在进入实训!'); // this.startshixunCombat(); }} ).catch((error) => { this.setState({ isSpins:false, shixunsreplaces:false, }) }); }; startgameid=(id)=>{ if(this.props.isNotMember()===true){ //这个是外部传过来的 this.Startlearningtwo(); return } let url = "/shixuns/" + id + "/shixun_exec.json"; axios.get(url).then((response) => { if (response.data.status === -2) { this.setState({ shixunsreplaces:true, hidestartshixunsreplacevalues:response.data.message+".json" }) } else if (response.data.status === -1) { console.log(response) }else if(response.data.status===-3){ this.setState({ shixunsmessages:response.data.message, startshixunCombattypes:true, }) } else { console.log("开始学习了"); window.open("/tasks/" + response.data.game_identifier,'_blank'); //这个是传过来 调用刷新 this.Myreload(); // window.location.href = path // let path="/tasks/"+response.data.game_identifier; // this.props.history.push(path); } }).catch((error) => { }); }; hidestartshixunCombattype=()=>{ this.setState({ startshixunCombattypes:false }) }; Modifyloginvalue=()=>{ this.setState({ isRender:false, }) }; Tojoinclass=()=> { this.setState({ isRender: true }) }; render(){ let{description,whethertoedit,isSpin,start_learning,hidestartshixunsreplacevalues,learned,last_shixun,stages,isRender} =this.state; const isNotMembers=this.props.isNotMember();//非课堂成员 const antIcon = ; return(
{isRender===true?this.Modifyloginvalue()} {...this.props} {...this.state} />:""} this.ysljoinmodalCancel()} ysljoinmodalCanceltwo={()=>this.ysljoinmodalCanceltwo()}>

本实训的开启时间:{this.state.shixunsmessages}
开启时间之前不能挑战

{/*

*/} {/*知道了*/} {/*

*/}

实训已经更新了,正在为您重置!

{ this.props.isAdmin()===true?"":
{ start_learning===undefined?"":start_learning===false?
还未开始学习
:
已学{learned}%
上次学至{last_shixun}
}
} {/*简介*/}
简介

{ stages===undefined||stages===JSON.stringify("[]")||stages.length===0?

暂时还没有相关数据哦!

:
{/*开始学习*/} this.Startlearningtwo()} Myreload={()=>this.Myreload()} Tojoinclass={()=>this.Tojoinclass()}>
}
) } } const Elearningss = Form.create({ name: 'elearning' })(Elearning); export default Elearningss;