|
|
|
@ -15,27 +15,28 @@ class SearchPage extends Component{
|
|
|
|
|
this.state={
|
|
|
|
|
tab:"0",
|
|
|
|
|
count:0,
|
|
|
|
|
keywords:"",
|
|
|
|
|
type:"",
|
|
|
|
|
keywords:undefined,
|
|
|
|
|
type:"shixun",
|
|
|
|
|
page:1,
|
|
|
|
|
perpages:20,
|
|
|
|
|
data:[],
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//切换tab
|
|
|
|
|
changeTab=(e)=>{
|
|
|
|
|
console.log(e.key);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let types ="";
|
|
|
|
|
if(parseInt(e.key)===0){
|
|
|
|
|
types="course";
|
|
|
|
|
types="shixun";
|
|
|
|
|
}
|
|
|
|
|
if(parseInt(e.key)===1){
|
|
|
|
|
types="shixun";
|
|
|
|
|
types="subject";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(parseInt(e.key)===2){
|
|
|
|
|
types="subject";
|
|
|
|
|
types="course";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(parseInt(e.key)===3){
|
|
|
|
@ -59,16 +60,27 @@ class SearchPage extends Component{
|
|
|
|
|
// this.setState({
|
|
|
|
|
// tab:sum,
|
|
|
|
|
// })
|
|
|
|
|
let courstype=this.props.match.url;
|
|
|
|
|
let courstype=decodeURI(decodeURI(this.props.location.search));
|
|
|
|
|
courstype = courstype.split('?value=');
|
|
|
|
|
console.log(courstype);
|
|
|
|
|
this.getdata(this.state.page,this.state.type,this.state.keywords);
|
|
|
|
|
|
|
|
|
|
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) => {
|
|
|
|
@ -92,21 +104,22 @@ class SearchPage extends Component{
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
console.log("63");
|
|
|
|
|
console.log(response.data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
count:response.data.count,
|
|
|
|
|
data:response.data.results,
|
|
|
|
|
})
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
console.log("56");
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
|
let {tab,count,data,page,perpages}=this.state;
|
|
|
|
|
console.log(tab);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return(
|
|
|
|
|
<div className="newMain clearfix">
|
|
|
|
|
<div className="headersear" >
|
|
|
|
@ -114,7 +127,9 @@ class SearchPage extends Component{
|
|
|
|
|
<Search
|
|
|
|
|
style={{ width: "800px", marginTop:"53px"}}
|
|
|
|
|
className="packinput"
|
|
|
|
|
value={this.state.keywords}
|
|
|
|
|
enterButton={<span><Icon type="search" className="mr5"/> 搜索</span>}
|
|
|
|
|
onInput={(e)=>this.setdatafunsval(e)}
|
|
|
|
|
onSearch={ (value)=>this.setdatafuns(value)} />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
@ -146,11 +161,19 @@ class SearchPage extends Component{
|
|
|
|
|
<p className="counttittext">共找到相关结果<span className="counttittexts">{count}</span>个</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div className="mainx">
|
|
|
|
|
|
|
|
|
|
<div className="educontent project-packages-list mb30">
|
|
|
|
|
{data === undefined ? "" : data.map((item, key) => {
|
|
|
|
|
return (
|
|
|
|
|
<a key={key}
|
|
|
|
|
href={
|
|
|
|
|
item.type==="shixun"?`/shixuns/${item.identifier}/challenges`:item.type==="course"?`/courses/${item.id}/students`:item.type==="subject"?`/courses/${item.id}/students`:item.type==="memo"?`/forums/${item.id}`:""
|
|
|
|
|
}
|
|
|
|
|
target="_blank"
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
<div className="project-package-item">
|
|
|
|
|
|
|
|
|
|
<div className={"font-16 color-dark fl "} >
|
|
|
|
@ -208,6 +231,8 @@ class SearchPage extends Component{
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</a>
|
|
|
|
|
)
|
|
|
|
|
})}
|
|
|
|
|
|
|
|
|
|