dev_forum
杨树林 5 years ago
parent 2f0ddc7da4
commit 32f9ed1799

@ -118,22 +118,23 @@ function loadHeader(){
function header_search(reactHeaderComponnet){
console.log(old_url)
var keyword = $("input[name='search_keyword']").val(); // 搜索关键字
if (!reactHeaderComponnet) {
reactHeaderComponnet = window._header_componentHandler
}
if (!reactHeaderComponnet) {
var index = $("#search_type").val(); // 搜索课程/项目
keyword = encodeURIComponent(keyword);
// $.get('/users/search_shixuns_or_course',
// { search: keyword,
// index: index});
window.location.href = old_url+"/users/search_shixuns_or_courses" + "?search=" + keyword + "&index=" + index;
window.location.href ="/search"+"?value="+keyword;
// if (!reactHeaderComponnet) {
// reactHeaderComponnet = window._header_componentHandler
// }
// if (!reactHeaderComponnet) {
// var index = $("#search_type").val(); // 搜索课程/项目
// keyword = encodeURIComponent(keyword);
// // $.get('/users/search_shixuns_or_course',
// // { search: keyword,
// // index: index});
// window.location.href = old_url+"/users/search_shixuns_or_courses" + "?search=" + keyword + "&index=" + index;
//e.stopPropagation();//阻止冒泡
} else {
window.__headSearchKeyword = keyword
reactHeaderComponnet.props.history.push(`/shixuns`)
trigger('searchKeywordChange', keyword)
}
// } else {
// window.__headSearchKeyword = keyword
// reactHeaderComponnet.props.history.push(`/shixuns`)
// trigger('searchKeywordChange', keyword)
// }
}
//头部导航条的隐藏
function closeSearch(){
@ -382,12 +383,14 @@ class NewHeader extends Component {
header_search(this)
}
onKeywordSearchKeyDown = (e) => {
let code = e.keyCode;
if(code == 13) {
header_search(this);
return false;
}
window.location.href ="/search"+"?value="+e.target.value;
// let code = e.keyCode;
// if(code == 13) {
// header_search(this);
// return false;
// }
}
hideAddcoursestypes=()=>{

@ -13,7 +13,7 @@ class SearchPage extends Component{
this.state={
tab:"0",
count:0,
keywords:"python",
keywords:"",
type:"",
page:1,
perpages:20,
@ -22,11 +22,29 @@ class SearchPage extends Component{
}
//切换tab
changeTab=(e)=>{
this.setState({
tab:e.key
})
console.log(e.key);
let types ="";
if(parseInt(e.key)===0){
types="course";
}
if(parseInt(e.key)===1){
types="shixun";
}
if(parseInt(e.key)===2){
types="subject";
}
if(parseInt(e.key)===3){
types="memo";
}
this.setState({
tab:e.key,
type:types
})
this.getdata(1,types,this.state.keywords);
}
componentDidMount(){
@ -39,25 +57,31 @@ class SearchPage extends Component{
// this.setState({
// tab:sum,
// })
this.getdata(this.state.page);
let courstype=this.props.match.url;
courstype = courstype.split('?value=');
console.log(courstype);
this.getdata(this.state.page,this.state.type,this.state.keywords);
}
setdatafuns =(value)=>{
this.setState({
keywords:value
})
this.getdata(this.state.page,this.state.type,value);
}
paginationonChanges = (pageNumber) => {
this.setState({
page: pageNumber,
loadingstate: true,
})
this.getdata(pageNumber);
this.getdata(pageNumber,this.state.type,this.state.keywords);
}
//获取数据
getdata=(pages)=>{
getdata=(pages,type,keywords)=>{
let url = "/search.json";
axios.get(url,{params:{
keyword:this.state.keywords,
type:this.state.types,
keyword:keywords,
type:type,
page:pages,
per_page:this.state.perpages,
}
@ -106,7 +130,7 @@ class SearchPage extends Component{
JSON.stringify(data) === "[]" ?
<div id="forum_list" className="forum_table">
<div className="mh650 edu-back-white">
<div className="mh650 bjyss">
<div className="edu-tab-con-box clearfix edu-txt-center">
<img className="edu-nodata-img mb20" src={getImageUrl("images/educoder/nodata.png")}/>
<p className="edu-nodata-p mb30">没有数据可以显示</p>

@ -115,3 +115,6 @@
.tzbqx{
margin-left: 24px;
}
.bjyss{
background: #F8F8F8;
}
Loading…
Cancel
Save