import React,{ Component } from "react"; import {Checkbox,Input,Table, Pagination,Menu,Icon} from "antd"; import {TPMIndexHOC} from "../modules/tpm/TPMIndexHOC"; import {Link,NavLink} from 'react-router-dom'; import { WordsBtn ,ActionBtn,SnackbarHOC,markdownToHTML,getImageUrl} from 'educoder'; import axios from 'axios'; import './searchc.css' const Search = Input.Search; class SearchPage extends Component{ constructor(props) { super(props); this.state={ tab:"1", count:0, keywords:undefined, type:"subject", page:1, perpages:20, data:[], } } //切换tab changeTab=(e)=>{ // course 课堂, shixun 开发社区 subject 实践课程 memo 交流问答 let types =""; if(parseInt(e.key)===0){ types="shixun"; } if(parseInt(e.key)===1){ types="subject"; } if(parseInt(e.key)===2){ types="course"; } if(parseInt(e.key)===3){ types="memo"; } this.setState({ tab:e.key, type:types, page:1, }) this.getdata(1,types,this.state.keywords); } componentDidMount(){ let courstype=decodeURI(decodeURI(this.props.location.search)); courstype = courstype.split('?value='); this.setState({ keywords:courstype[1] }) this.getdata(this.state.page,this.state.type,courstype[1]); } componentDidUpdate(prevProps) { if(prevProps.location.search!=this.props.location.search){ let courstype=decodeURI(decodeURI(this.props.location.search)); courstype = courstype.split('?value='); this.setState({ keywords:courstype[1] }) this.getdata(this.state.page,this.state.type,courstype[1]); } } setdatafunsval=(e)=>{ this.setState({ keywords:e.target.value }) } setdatafuns =(value)=>{ this.setState({ keywords:value }) this.props.history.replace(`/search?value=${value}`) this.getdata(this.state.page,this.state.type,value); } paginationonChanges = (pageNumber) => { this.setState({ page: pageNumber, loadingstate: true, }) this.getdata(pageNumber,this.state.type,this.state.keywords); } //获取数据 getdata=(pages,type,keywords)=>{ let url = "/search.json"; this.setState({ loading: true }) axios.get(url,{params:{ keyword:keywords, type:type, page:pages, per_page:this.state.perpages, } }).then((response) => { this.setState({ loading: false }) if(response === undefined){ return } this.setState({ count:response.data.count, data:response.data.results, }) }).catch((error) => { }); } render(){ let {tab,count,data,page,perpages, type }=this.state; return(
暂时还没有相关数据哦!