import React,{ Component } from "react"; import { Input , Spin , Pagination } from "antd"; import './css/moopCases.css' import '../courses/css/Courses.css' import { ActionBtn , LinkAfterLogin } from 'educoder'; import axios from 'axios' import NoneData from '../courses/coursesPublic/NoneData' import mainImg from '../../images/moop_cases/teach_ex.jpg' import CaseItem from './CaseItem' const Search = Input.Search; class CaseList extends Component{ constructor(props){ super(props); this.state={ type:0, search:undefined, page:1, pageSize:20, libraries:undefined, totalCount:undefined, isSpin:false } } componentDidMount = () =>{ let { type , search , page , pageSize } = this.state; this.InitList(type,search,page,pageSize); } // 列表 InitList = (type,search,page,pageSize) =>{ let url = `/libraries.json`; axios.get(url,{params:{ type:type == 0 ? undefined : "mine", keyword:search, page, per_page:pageSize }}).then((result)=>{ if(result){ this.setState({ libraries:result.data.libraries, totalCount:result.data.count, isSpin:false }) } }).catch((error)=>{ console.log(error); }) } // tab切换 changeType = (type) =>{ this.setState({ type, page:1 }) let { search , page , pageSize } = this.state; this.InitList(type,search,page,pageSize); } // 输入搜索内容 inputStudent=(e)=>{ this.setState({ search:e.target.value }) } // 搜索 searchInfo = () =>{ this.setState({ isSpin:true }) let { type , search , pageSize } = this.state; this.InitList( type , search , 1 , pageSize ); } // 切换分页 onChangePage =(pageNumber)=>{ this.setState({ page:pageNumber }) let { type , search , pageSize } = this.state; this.InitList( type , search , pageNumber , pageSize ); } render(){ let { type , search ,libraries , totalCount ,pageSize ,page } = this.state; let { checkIfLogin } = this.props; return(

教学案例 发布案例 {/* 发布案例 */}

  • this.changeType(0)}> 全部
  • { checkIfLogin() &&
  • this.changeType(1)}> 我的
  • }
{ libraries && libraries.length > 0 && } { libraries && libraries.length == 0 &&
} { totalCount && totalCount > pageSize &&
}
) } } export default CaseList