搜索调整

dev_forum
杨树明 5 years ago
parent 0c2043d20e
commit 8ec3869815

@ -333,7 +333,13 @@ class App extends Component {
{/*实训课程(原实训路径)*/}
<Route path="/paths" component={ShixunPaths}></Route>
<Route path="/search" component={SearchPage} ></Route>
<Route path="/search"
render={
(props)=>(<SearchPage {...this.props} {...props} {...this.state}></SearchPage>)
}
></Route>
{/*课堂*/}
<Route path="/courses" component={CoursesIndex} {...this.props}></Route>

@ -384,7 +384,7 @@ class NewHeader extends Component {
}
onKeywordSearchKeyDown = (e) => {
window.location.href ="/search"+"?value="+e.target.value;
window.location.href ="/search?value="+e.target.value;
// let code = e.keyCode;
// if(code == 13) {
@ -709,6 +709,7 @@ submittojoinclass=(value)=>{
<Search
placeholder="搜索"
// onSearch={value => console.log(value)}
onPressEnter={this.onKeywordSearchKeyDown}
style={{ width: 258 }}
/>
@ -791,6 +792,8 @@ submittojoinclass=(value)=>{
<div className="edu-menu-list" style={{top: '60px',width:"240px"}}>
<div className="overPart"></div>
<ul className="fl with50 edu-txt-center pr ul-leftline">
{console.log(this.props)}
{console.log(this.state)}
<li><Link to={"/courses/new"}>新建课堂</Link></li>
<li><a href="/shixuns/new">新建实训</a></li>
<li><a href={this.props.Headertop===undefined?"":"/paths/new"}>新建实践课程</a></li>

@ -502,6 +502,8 @@ class Newshixuns extends Component {
}
sendsure_apply = () => {
let {languagewrite,systemenvironment,testcoderunmode} = this.state;
debugger
// console.log("点击确定")
// console.log("languagewrite"+languagewrite);
// console.log("systemenvironment"+systemenvironment);
@ -987,14 +989,14 @@ class Newshixuns extends Component {
{
deleteisnot=== true?
<Upload {...uploadProps} >
<Icon type="upload" className="fl mt5" > </Icon>
<Icon type="upload" className="fl mt3" > </Icon>
<span className="color-blue fl">上传附件</span>
<span className="color-grey-c fl ml10 ">(单个文件50M以内)</span>
</Upload>
:
<Upload {...uploadProps} disabled={true} >
<Icon type="upload" className="fl mt5" > </Icon>
<Icon type="upload" className="fl mt3" > </Icon>
<span className="color-grey-c fl">上传附件</span>
<span className="color-grey-c fl ml10 ">(单个文件50M以内)</span>

@ -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>
)
})}

Loading…
Cancel
Save