import React, { Component } from 'react'; import { SnackbarHOC } from 'educoder'; import {BrowserRouter as Router,Route,Switch} from 'react-router-dom'; import {Tooltip,Menu,Pagination, Spin} from 'antd'; import Loadable from 'react-loadable'; import Loading from '../../../Loading'; import NoneData from '../../courses/coursesPublic/NoneData' import axios from 'axios'; import {getImageUrl,setImagesUrl} from 'educoder'; import { TPMIndexHOC } from '../../tpm/TPMIndexHOC'; import { CNotificationHOC } from '../../courses/common/CNotificationHOC' import "./usersInfo.css" import Create from './publicCreatNew' class InfosPath extends Component{ constructor(props){ super(props); this.state={ category:undefined, page:1, sort_by:'time', status:undefined, per_page:16, isSpin:false, totalCount:undefined, data:undefined } } componentDidMount=()=>{ this.setState({ isSpin:true }) let{category,status,sort_by,page,per_page}=this.state; this.getCourses(category,status,sort_by,page,per_page); } getCourses=(category,status,sort_by,page,per_page)=>{ let url=`/users/${this.props.match.params.username}/subjects.json`; axios.get((url),{params:{ category, status, sort_by, page, per_page:this.props.is_current && category && page ==1?17:16 }}).then((result)=>{ if(result){ this.setState({ totalCount:result.data.count, data:result.data, isSpin:false }) } }).catch((error)=>{ console.log(error); }) } //切换种类 changeCategory=(cate)=>{ this.setState({ category:cate, status:undefined, page:1, isSpin:true }) let{sort_by}=this.state; this.getCourses(cate,undefined,sort_by,1); } // 切换状态 changeStatus=(status)=>{ let{category,sort_by}=this.state; this.setState({ status, page:1, isSpin:true }) this.getCourses(category,status,sort_by,1); } //切换页数 changePage=(page)=>{ this.setState({ page, isSpin:true }) let{category,sort_by,status}=this.state; this.getCourses(category,status,sort_by,page); } // 进入课堂 turnToCourses=(url)=>{ this.props.history.push(url); } // 切换排序方式 changeOrder= (sort)=>{ this.setState({ sort_by:sort, isSpin:true }) let{category,status,page}=this.state; this.getCourses(category,status,sort,page); } render(){ let{ category, status, sort_by, page, data, totalCount, isSpin } = this.state; let isStudent = this.props.isStudent(); let is_current=this.props.is_current; return(
  • this.changeCategory()}>全部
  • this.changeCategory("manage")}>{is_current ? "我":"TA"}管理的
  • this.changeCategory("study")}>{is_current ? "我":"TA"}学习的
  • { category && category == "manage" && is_current &&
  • this.changeStatus()}>全部
  • this.changeStatus("editing")}>编辑中
  • this.changeStatus("applying")}>待审核
  • this.changeStatus("published")}>已发布
  • } { category && category == "study" && is_current &&
  • this.changeStatus()}>全部
  • this.changeStatus("unfinished")}>未完成
  • this.changeStatus("finished")}>已完成
  • }
    共参与{totalCount}个{category?category=="manage"?"发布":"学习":"实践课程"} 时间最新
    { page == 1 && is_current && !category && this.props.current_user && this.props.current_user.user_identity != "学生" ? :"" } { (!data || data.subjects.length==0) && (!is_current || (this.props.current_user && this.props.current_user.user_identity === "学生" )) && } { data && data.subjects && data.subjects.map((item,key)=>{ return(
    this.turnToCourses(`/paths/${item.id}`)}> { item.tag &&
    {item.tag} {/**/}
    } Subject12

    {item.name}

    ) }) }
    { totalCount > 15 &&
    }
    ) } } export default InfosPath;