列表查询

This commit is contained in:
caishi 2021-02-25 16:58:59 +08:00
parent 2c3d917bd4
commit efc2443bb8
2 changed files with 18 additions and 29 deletions

View File

@ -22,7 +22,6 @@ class Index extends Component {
sort: undefined,
total: 0,
isSpin: true,
project_type: undefined,
category_id: undefined,
typeList: undefined,
@ -36,8 +35,8 @@ class Index extends Component {
}
componentDidMount = () => {
const { page,search, sort, project_type, category_id , languageId } = this.state;
this.getListData(page,search, sort, project_type, category_id , languageId);
const { page,search, sort,category_id , languageId } = this.state;
this.getListData(page,search, sort,category_id , languageId);
this.getType();
@ -72,7 +71,7 @@ class Index extends Component {
}
// 获取列表
getListData = (page,search, sort, project_type, category_id,languageId) => {
getListData = (page,search, sort,category_id,language_id) => {
const { current_user } = this.props;
const url = `/projects.json`;
axios.get(url, {
@ -82,9 +81,8 @@ class Index extends Component {
limit:15,
search,
sort_by: sort,
project_type,
category_id,
language_id:languageId
language_id
}
}).then((result) => {
if (result) {
@ -111,7 +109,7 @@ class Index extends Component {
this.setState({
typeList: list.map((item, key) => {
return (
<li key={key} className={active_type && active_type === item.project_type ? 'active' : ''} onClick={() => this.changeType(`${item.project_type}`, list)}>
<li key={key} className={active_type && parseInt(active_type) === item.id ? 'active' : ''} onClick={() => this.changeType(`${item.id}`, list)}>
<p>
<span className="font-16">{item.name}</span>
<span className="color-blue">{item.projects_count}</span>
@ -123,15 +121,15 @@ class Index extends Component {
}
// 切换类型
changeType = (type, list) => {
changeType = (id, list) => {
this.setState({
isSpin: true,
project_type: type,
languageId: id,
search: undefined
})
this.setTypeList(list, type)
const { page,sort, category_id , languageId } = this.state;
this.getListData(page,undefined, sort, type, category_id , languageId);
this.setTypeList(list, id)
const { page,sort, category_id} = this.state;
this.getListData(page,undefined, sort,category_id , id);
}
// 获取类型
@ -166,8 +164,8 @@ class Index extends Component {
page: 1
});
this.setCategoryList(list, id)
const { sort, project_type , languageId } = this.state;
this.getListData(1,undefined, sort, project_type, id , languageId);
const { sort,languageId } = this.state;
this.getListData(1,undefined, sort,id , languageId);
}
// 排序
@ -178,8 +176,8 @@ class Index extends Component {
search: undefined,
isSpin: true
})
const {project_type, category_id , languageId } = this.state;
this.getListData(1,undefined, e.key, project_type, category_id , languageId);
const {category_id , languageId } = this.state;
this.getListData(1,undefined, e.key,category_id , languageId);
}
// 搜索
@ -192,7 +190,7 @@ class Index extends Component {
sort: "updated_on"
})
const {sort, category_id , languageId } = this.state;
this.getListData(1,value, sort, undefined, category_id , languageId);
this.getListData(1,value, sort,category_id , languageId);
}
changeSearchValue = (e) => {
this.setState({
@ -204,23 +202,14 @@ class Index extends Component {
this.setState({
page
})
const {search, sort, project_type, category_id , languageId } = this.state;
this.getListData(page,search, sort, project_type, category_id , languageId);
const {search, sort,category_id , languageId } = this.state;
this.getListData(page,search, sort, category_id , languageId);
}
getoDetail=(login,identifier)=>{
this.props.history.push(`/projects/${login}/${identifier}`);
}
// 选择语言类别
changeLanguage=(e)=>{
this.setState({
isSpin:true,
languageId:e === 0 ?undefined:e
})
const { page,sort , project_type , category_id } = this.state;
this.getListData(page, undefined, sort, project_type, category_id ,e === 0 ?undefined:e);
}
menu =()=> {
return(

View File

@ -227,7 +227,7 @@ class Infos extends Component {
<div className="bgcF">
<ul className="list-l-Menu">
<li className="MenuTitle" onClick={() => this.change_project_type(undefined)}>
<li className="MenuTitle" onClick={() => this.change_project_type()}>
<i className="iconfont icon-xiangmuleixing font-15 mr5"></i>
项目类型
<i className="iconfont icon-youjiantou font-15 mr20 color-grey-9 pull-right"></i>