搜索调整

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="/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> <Route path="/courses" component={CoursesIndex} {...this.props}></Route>

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

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

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

Loading…
Cancel
Save