import React, { Component } from 'react'; import {getImageUrl} from 'educoder'; import { Tooltip,Modal,Icon,Spin,message} from 'antd'; import '../../paths/ShixunPaths.css'; import axios from 'axios'; import { BrowserRouter as Router, Route, Link } from "react-router-dom"; import DetailCardsEditAndEdit from '../../paths/PathDetail/DetailCardsEditAndEdit'; import DetailCardsEditAndAdd from "../../paths/PathDetail/DetailCardsEditAndAdd"; import Modals from "../../modals/Modals"; import NoneData from "../coursesPublic/NoneData"; class YslDetailCards extends Component{ constructor(props){ super(props) this.state={ showparagraph:false, showparagraphkey:"", showparagraphindex:"", shixunsreplace:false, hidestartshixunsreplacevalue:"", shixunsmessage:"", startshixunCombattype:false, isSpin:false, idsum:undefined, pathCardsedittype:false, pathid:undefined, editbuttomtype:false, editbuttomtypeadd:false, pathlistedit:undefined, delecttype:false, Modalstype:false, Modalstopval:'', Modalsbottomval:'', } //idsum 是否点击这个 //pathCardsedittype 是否是在编辑模式 //editbuttomtypeadd 是否已经是编辑模式 //pathid课堂id //pathlistedit 编辑返回的数据 } showparagraph =(key,index)=>{ this.setState({ showparagraph:true, showparagraphkey:key, showparagraphindex:index }) }; hideparagraph=()=>{ this.setState({ showparagraph:false, showparagraphkey:null, showparagraphindex:null }) }; startgameid=(id)=>{ // 上面传过来的方法是用来没登入弹出弹框的 try { let {userlogin} = this.props; if (userlogin === undefined) { this.props.Tojoinclass(); return } if (userlogin === "") { this.props.Tojoinclass(); return; } }catch (e) { } try { if(this.props.isNotMember()===true){ //这个是外部传过来的 this.props.Startlearningtwo(); return } }catch (e) { } let url = "/shixuns/" + id + "/shixun_exec.json"; axios.get(url).then((response) => { if (response.data.status === -2) { this.setState({ shixunsreplace:true, hidestartshixunsreplacevalue:response.data.message+".json" }) } else if (response.data.status === -1) { console.log(response) }else if(response.data.status===-3){ this.setState({ shixunsmessage:response.data.message, startshixunCombattype:true, }) } else { // console.log("开始学习了"); window.open("/tasks/" + response.data.game_identifier,'_blank'); //这个是传过来 调用刷新 this.props.getPathCardsList(); // window.location.href = path // let path="/tasks/"+response.data.game_identifier; // this.props.history.push(path); } }).catch((error) => { }); }; componentDidMount(){ // console.log("YslDetailCards start"); let pathid=this.props.match.params.coursesId; this.setState({ pathid:pathid }) } Pathlisteditundefined=()=>{ this.setState({ pathlistedit:undefined }) }; hidestartshixunsreplace=(url)=>{ this.setState({ isSpin: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({ shixunsreplace:false, isSpin:false, startbtn:false, }) // message.success('重置成功,正在进入实训!'); // this.startshixunCombat(); }} ).catch((error) => { this.setState({ isSpin:false, shixunsreplace:false, }) }); } hidestartshixunCombattype=()=>{ this.setState({ startshixunCombattype:false }) }; // 关卡的上移下移操作 operations = (url) => { let newurl = url+".json" axios.get(newurl).then((response) => { if(response.data.status===1){ this.props.getPathCardsList(); } }).catch((error) => { console.log(error); }) }; //章节下移 chapterdown=(id)=>{ let url=`/course_stages/${id}/down_position.json`; axios.post(url).then((response) => { if(response){ if(response.data){ if(response.data.status===0){ this.props.showNotification(`下移成功`); this.props.getPathCardsList(); }else{ this.props.showNotification(`下移失败`); } }else{ this.props.showNotification(`下移失败`); } }else { this.props.showNotification(`下移失败`); } }).catch((error) => { console.log(error) }); }; //章节上移 chapterup=(id)=>{ let url=`/course_stages/${id}/up_position.json`; axios.post(url).then((response) => { if(response){ if(response.data){ if(response.data.status===0){ this.props.showNotification(`上移成功`); this.props.getPathCardsList(); }else{ this.props.showNotification(`上移失败`); } }else{ this.props.showNotification(`上移失败`); } }else{ this.props.showNotification(`上移失败`); } }).catch((error) => { console.log(error) }); }; //确认的 updatapathCardsedit=()=>{ this.setState({ idsum:undefined, pathCardsedittype:false, editbuttomtype:false, editbuttomtypeadd:false }) this.props.getPathCardsList(); this.props.myupdataleftNavs(); // this.props.updatadetailInfoLists(); }; //取消的 editeditbuttomtypecanle=()=>{ this.setState({ editbuttomtype:true, editbuttomtypeadd:false }) } //编辑用 pathCardsedit=(key,pathid)=>{ let url=`/course_stages/${pathid}/edit.json`; axios.get(url).then((result)=>{ if(result){ if(result.status===200){ this.setState({ idsum:key, pathCardsedittype:true, pathlistedit:result.data, editbuttomtype:true, editbuttomtypeadd:true }) } } }).catch((error)=>{ console.log(error); }) }; //删除用的 delectpathCardsedit=(id)=>{ this.setState({ Modalstype:true, Modalstopval:'是否删除该章节?', Modalsbottomval:'', editdelectid:id, delecttype:true, }) } cardsModalcancel=()=>{ this.setState({ Modalstype:false, Modalstopval:'', Modalsbottomval:'', editdelectid:undefined }) } cardsModalsave=()=>{ debugger this.setState({ Modalstype:false, Modalstopval:'', Modalsbottomval:'', editdelectid:undefined }) } delectpathCardseditfun=()=>{ let {delecttype,editdelectid}=this.state; let id=editdelectid; if(delecttype===true){ let url =`/course_stages/${id}.json` axios.delete(url).then((response) => { if(response){ if(response.data){ if(response.data.status===0){ this.setState({ idsum:undefined, pathCardsedittype:false, Modalstype:false, Modalstopval:'', Modalsbottomval:'', delecttype:false, editdelectid:undefined }) this.updatapathCardsedit() this.props.showNotification(`删除成功`); this.props.myupdataleftNavs(); }else { this.props.showNotification(`删除失败`); } }else{ this.props.showNotification(`删除失败`); } }else { this.props.showNotification(`删除失败`); } }).catch((error) => { console.log(error) }) } } render(){ let{showparagraph,showparagraphkey,showparagraphindex,hidestartshixunsreplacevalue,idsum,pathCardsedittype,pathid,Modalstype,Modalstopval,Modalsbottomval,delecttype,pathlistedit,editbuttomtypeadd,editbuttomtype} =this.state; let { stages ,subject_id}=this.props; const antIcon = ; // console.log("pathCardsedittype"); // console.log(pathCardsedittype); // console.log(editbuttomtype); // console.log("this.props.isAdmin"); // console.log(this.props.isAdmin()); // console.log(this.state.delecttype); return(
{ stages===undefined||stages===JSON.stringify("[]")||stages.length===0? "" :

目前该实训项目尚在内测中,将于{this.state.shixunsmessage}之后开放,谢谢!

{/*取消*/} 知道了
{/*

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

*/}

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

{ this.props.isStudent()===true&&(stages===undefined||stages===JSON.stringify("[]")||stages.length===0)? : "" } { stages && stages.map((item,key)=>{ return(

{item.stage_name} { idsum===key&&pathCardsedittype===true?'': this.props.isAdmin()==true? { editbuttomtype===true?'': this.pathCardsedit(key, item.stage_id)}> } { stages.length=== key+1?"":this.chapterdown(item.stage_id)}> } {key===0?"": this.chapterup(item.stage_id)}> } :"" } { idsum === key && pathCardsedittype === true ? this.props.isAdmin()===true? this.delectpathCardsedit(item.stage_id)}> :"" : '' }

{ idsum===key&&pathCardsedittype===true?'':

{item.stage_description}

{ item.shixuns_list && item.shixuns_list.map((line,index)=>{ return(
this.showparagraph(key,index)} onMouseLeave={this.hideparagraph}>
  • { line.complete_status === 1 ? : } {key+1}-{index+1}  {line.shixun_name}
  • { line.allow_visit===false&&line.shixun_status==="暂未公开"?
  • 暂未公开
  • :
  • { showparagraphkey===key&&showparagraphindex===index?:"" }
  • } {line.allow_visit===false&&line.shixun_status==="暂未公开"?"":
  • { showparagraphkey === key && showparagraphindex === index ? "" : 实验任务 {line.challenges_count} }
  • }
    ) }) }
    } { this.props.isAdmin()===true? :"" }
    ) }) }
    } { editbuttomtypeadd===true?'':this.props.isAdmin()===true? :"" }
    ) } } export default YslDetailCards; // detailInfoList以前实训课堂做权限判断的作用 this.props.subject_id