import React, { Component } from 'react'; import { SnackbarHOC } from 'educoder'; import {BrowserRouter as Router,Route,Switch} from 'react-router-dom'; import {Tooltip, Menu, Pagination, Spin, Dropdown} from 'antd'; import Loadable from 'react-loadable'; import Loading from '../../../Loading'; import axios from 'axios'; import NoneData from '../../courses/coursesPublic/NoneData' import {getImageUrl} from 'educoder'; import { TPMIndexHOC } from '../../tpm/TPMIndexHOC'; import { CNotificationHOC } from '../../courses/common/CNotificationHOC' import "./usersInfo.css" import Create from './publicCreatNew' class InfosCourse extends Component{ constructor(props){ super(props); this.state={ category:undefined, status:undefined, page:1, per_page:16, sort_by: "updated_at", sort_direction: "desc", totalCount:undefined, data:undefined, isSpin:false } } componentDidMount=()=>{ this.setState({ isSpin:true }) let {category, status, page, sort_by, sort_direction} = this.state; this.getCourses(category, status, page, sort_by, sort_direction); } getCourses = (category, status, page, sort_by, sort_direction) => { let url=`/users/${this.props.match.params.username}/courses.json`; axios.get((url),{params:{ category, status, page, sort_by, sort_direction, per_page: this.props.is_current && category && page ==1?17:16 }}).then((result)=>{ if(result){ console.log("请求成功"); this.setState({ totalCount:result.data.count, data:result.data, sort_direction: sort_direction, sort_by: sort_by, isSpin:false }) } }).catch((error)=>{ console.log(error); this.setState({ isSpin: false }) }) } //切换种类 changeCategory=(cate)=>{ this.setState({ category:cate, page:1, isSpin:true }) let {status, sort_by, sort_direction} = this.state; this.getCourses(cate, status, 1, sort_by, sort_direction); } //切换状态 changeStatus=(status)=>{ this.setState({ status:status, page:1, isSpin:true }) let {category, sort_by, sort_direction} = this.state; this.getCourses(category, status, 1, sort_by, sort_direction); } //切换页数 changePage=(page)=>{ this.setState({ page, isSpin:true }) let {category, status, sort_by, sort_direction} = this.state; this.getCourses(category, status, page, sort_by, sort_direction); } // 进入课堂 turnToCourses=(url,flag)=>{ if(flag){ this.props.history.push(url); } } updatedlist(sort_by) { //按照什么样子排序 this.setState({ isSpin: true }); let {category, status, page, sort_direction} = this.state; this.getCourses(category, status, 1, sort_by, "desc"); } updatedlists(sort_directions, i) { // console.log("updatedlistssort_direction"); // console.log(sort_direction); // console.log(i); //是否是倒序 this.setState({ isSpin: true }); let {category, status, page, sort_by, sort_direction} = this.state; let sort_directiony = sort_directions; if (sort_directions === "asc") { if (sort_directions === sort_direction) { sort_directiony = "desc" } } else if (sort_directions === "desc") { if (sort_directions === sort_direction) { sort_directiony = "asc" } } this.getCourses(category, status, page, sort_by, sort_directiony); } render(){ let{ category, status, page, data, totalCount, isSpin, sort_by, sort_direction } = this.state; let is_current=this.props.is_current; // console.log(this.props.current_user&&this.props.current_user.user_identity==="学生") const menu = ( this.updatedlist("updated_at")}> 最新动态 this.updatedlist("created_at")}> 最新创建 ); console.log("InfosCourse"); console.log(status); return(
  • this.changeCategory()} className="font-16 w32">全部
  • this.changeCategory("manage")} className={is_current ? "font-16 w66" : "font-16 w80"}>{is_current ? "我" : "TA"}管理的
  • this.changeCategory("study")} className={is_current ? "font-16 w66" : "font-16 w80"}>{is_current ? "我" : "TA"}学习的
  • { is_current &&
  • this.changeStatus()} className="w32">全部
  • this.changeStatus("processing")} className="w66">正在进行
  • this.changeStatus("end")} className="w66">已结束
  • }

    共参与{totalCount}个{category?category=="manage"?"发布":"学习":"课堂"} this.updatedlists("asc", 1)}> this.updatedlists("desc", 2)}> {sort_by === "updated_at" ? '最新动态' : sort_by === "created_at" ? '最新创建' : ""}

    {/* 289 */} { page == 1 && is_current && !category && this.props.current_user && this.props.current_user.user_identity != "学生" ? : "" } { (!data || (data && data.courses.length === 0)) && (category || (!category && this.props.current_user && this.props.current_user.user_identity == "学生")) && } { data && data.courses && data.courses.map((item,key)=>{ return(
    this.turnToCourses(`${item.first_category_url}`,item.can_visited)} style={{"cursor": "pointer",height:"289px"}}> { item.is_public == 1 &&
    公开
    } { item.can_visited ==false?

    非成员不能访问

    :"" }

    {item.name}

    用户

    {item.teacher && item.teacher.real_name}

    {item.teacher && item.teacher.school_name}

    {item.visits>0? {item.visits} :""} { item.members_count > 0 && {item.members_count} } { item.homework_commons_count > 0 && {item.homework_commons_count} } {/*{*/} {/*item.attachments_count > 0 && */} {/**/} {/**/} {/*{item.attachments_count}*/} {/**/} {/*}*/}
    ) }) }
    { totalCount > 15 &&
    }
    ) } } export default InfosCourse;