import React, { Component } from 'react'; import { Redirect } from 'react-router'; import { BrowserRouter as Router, Route} from "react-router-dom"; import { Switch ,Input,Tooltip,Icon} from 'antd'; import PropTypes from 'prop-types'; import classNames from 'classnames' import 'antd/lib/switch/style/index.css' import './shixunCss/ShixunCardList.css'; import GotoQQgroup from '../../../modal/GotoQQgroup' import { on, off } from 'educoder' const $ = window.$; const Search = Input.Search; class ShixunCardList extends Component { constructor(props) { super(props); this.state={ allevent:"desc", mine:0, InputValue: props.keyword || "", typemy:0, hots:0, news:0, shixunid:"", upcircle:false, typekeyid:undefined, goshowqqgtounp:false, } } componentDidUpdate = (prevProps, prevState) => { if (this.props.keyword != prevProps.keyword) { this.setState({ InputValue: this.props.keyword }) } } componentDidMount = () => { on('searchKeywordChange', (event, data) => { // console.log(data) this.Input_search(data) }) } componentWillUnmount = () => { off('searchKeywordChange') } latestHot=(e,key)=>{ let{upcircle,typekeyid}=this.state; let id = e.target.id; $("#"+id).siblings().removeClass("active"); $("#"+id).addClass("active"); let type; // if(id==="all"){ // type="publish_time"; // } if(id==="hot"){ type="hot"; }else if(id==="new"){ type="new"; } if(typekeyid===key){ if(upcircle===true){ this.setState({ upcircle:false, }) this.props.Shixunsupcircles("desc") }else if(upcircle===false){ this.setState({ upcircle:true, }) this.props.Shixunsupcircles("asc") } }else{ this.setState({ typekeyid:key }) } //allevent this.props.ShixunsState(false,type); } onSwitchChange=(e,key)=>{ let id=e.target.id $("#"+id).siblings().removeClass("active"); $("#"+id).addClass("active"); let {typemy,upcircle,typekeyid}=this.state; if(typekeyid===key){ if(upcircle===true){ this.setState({ upcircle:false, }) this.props.Shixunsupcircles("desc") }else if(upcircle===false){ this.setState({ upcircle:true }) this.props.Shixunsupcircles("asc") } }else{ this.setState({ typekeyid:key }) } if(typemy===0){ this.setState({ typemy:1 }) }else{ this.setState({ typemy:0 }) } // allevent this.props.ShixunsSwitch(); } //输入框搜索 Input_search = (value) => { this.setState({ InputValue: value }) this.props.OnSearchInput(value,true); } Input_searchs = (e) => { this.setState({ InputValue: e.target.value }) this.props.OnSearchInput(e.target.value,false); } upcircles=(val)=>{ if(val==="asc"){ this.setState({ upcircle:false, }) this.props.Shixunsupcircles("desc") }else if(val==="desc"){ this.setState({ upcircle:true }) this.props.Shixunsupcircles("asc") } } //头部获取是否已经登录了 getUser=(url,type)=>{ if(this.props.checkIfLogin()===false){ this.props.showLoginDialog() return } if(this.props.checkIfProfileCompleted()===false){ this.props.showProfileCompleteDialog() return } if(this.props&&this.props.current_user&&this.props.current_user.is_shixun_marker===false){ this.setgoshowqqgtounp(true); return; } if(url !== undefined || url!==""){ window.location.href = url; } } // 处理弹框 setgoshowqqgtounp=(bool)=>{ this.setState({ goshowqqgtounp:bool }) } render(){ let {mine,InputValue,upcircle,goshowqqgtounp}=this.state; // console.log("NewHeadermygetHelmetapi123123123123"); let shixuntype=false; if(this.props&&this.props.mygetHelmetapi!=null){ let shixun="/shixuns"; let paths="/paths"; let courses="/courses"; this.props.mygetHelmetapi.navbar.map((item,key)=>{ var reg = RegExp(item.link); if(shixun.match(reg)){ if(item.hidden===true){ shixuntype=true } } }) } return (
{ goshowqqgtounp===true? this.setgoshowqqgtounp(bool)}> : "" } {/*
this.latestHot(e,1)}>全部*/} {/*
*/} {/*
this.onSwitchChange(e,2)}>我的*/} {/*
*/}
this.latestHot(e,4)}>最新
this.latestHot(e,3)}>最热
{shixuntype===true?"":this.getUser("/shixuns/new")}>+新建实训项目} {/*
this.upcircles("asc")}*/} {/*>*/} {/**/} {/**/} {/*/!**!/*/} {/**/} {/*
*/} {/*
this.upcircles("desc")}*/} {/*style={{display:upcircle===true?"none":"block"}}*/} {/*>*/} {/**/} {/**/} {/*/!**!/*/} {/**/} {/*
*/} {/*
*/} {/* this.Input_search(value)}*/} {/*enterButton*/} {/*/>*/} {/* this.Input_search(value)} autoComplete="off" > */} {/*
*/} {/*
*/} {/*{*/} {/*this.props.search_tags === null ? "" : this.props.search_tags*/} {/*}*/} {/*
*/} {/*/!*
*/} {/* *!/*/} {/**/} {/*
*/} {/*隐藏我的*/} {/*
*/} {/**/}
); } } export default ShixunCardList;