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(