From ea9709bbca7d1f6bce4c8bdbb3bcde6609816af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 29 Feb 2020 23:08:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=AD=9B=E9=80=89=E6=94=B9?= =?UTF-8?q?=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/paths/ShixunPathSearch.js | 162 +++++++++++------- .../src/modules/tpm/shixuns/ShixunCardList.js | 2 +- .../modules/tpm/shixuns/ShixunSearchBar.js | 2 +- 3 files changed, 102 insertions(+), 64 deletions(-) diff --git a/public/react/src/modules/paths/ShixunPathSearch.js b/public/react/src/modules/paths/ShixunPathSearch.js index f45098f8e..c7a668fd6 100644 --- a/public/react/src/modules/paths/ShixunPathSearch.js +++ b/public/react/src/modules/paths/ShixunPathSearch.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import axios from 'axios'; -import {Input} from 'antd'; +import {Dropdown,Menu} from 'antd'; import {getImageUrl} from 'educoder'; import PathCard from "./ShixunPathCard"; import UpgradeModals from '../modals/UpgradeModals'; @@ -18,59 +18,49 @@ class ShixunPathSearch extends Component{ page:1, pathList:null, sortList:'', - total_count:0 + total_count:0, + sort:"desc", + limit:16, + discipline_id:undefined, + sub_discipline_id:undefined } } + + //切换列表状态 changeStatus=(value)=>{ - this.setState( - { - pathList:null - } - ) - let {select,search}=this.state; + + let {discipline_id,sub_discipline_id }=this.state; this.setState({ order:value, page:1 }) - this.getList(value,select,search,1); - } - //搜索输入 - inputSearchValue=(e)=>{ - this.setState({ - search:e.target.value, - page:1 - }) - } - //搜索 - searchValue=(e)=>{ - let {order,select,search}=this.state; - this.setState({ - page:1 - }) - this.getList(order,select,search,1 ); + this.getList(value,discipline_id,sub_discipline_id,1); } + + //选择页数 onChange=(pageNumber)=> { - let {order,select,search}=this.state; + + let { order,discipline_id,sub_discipline_id }=this.state; this.setState({ page:pageNumber }) - this.getList(order,select,search,pageNumber); + this.getList(order,discipline_id,sub_discipline_id,pageNumber); } //顶部分类 - changeSelect=(tag_id)=>{ - this.setState( - { - pathList:null - } - ) - let { order,search }=this.state; + changeSelect=(e,tag_id,sum)=>{ + this.setState({ - select:tag_id + order:"updated_at", + discipline_id:tag_id, + page:1, + sub_discipline_id:undefined }) - this.getList( order,tag_id,search,1 ); + let { order }=this.state; + this.getList(order,tag_id,undefined,1 ); + e.stopPropagation(); } @@ -85,31 +75,41 @@ class ShixunPathSearch extends Component{ }).catch((error)=>{ console.log(error); }) + this.getdisciplines() + let { order,discipline_id,sub_discipline_id,page }=this.state; + this.getList(order,discipline_id,sub_discipline_id,page ); - let { order,select,search,page }=this.state; - this.getList(order,select,search,page ); } + getdisciplines=()=>{ + let url='/disciplines.json'; + axios.get(url,{params:{ + source:"subject" + }}).then((result)=>{ + if(result.status==200){ + // console.log(result.data.disciplines) + this.setState({ + sortList:result.data.disciplines + }) + } + }).catch((error)=>{ + console.log(error); + }) + } - getList=(order,select,search,page )=>{ + getList=(order,discipline_id,sub_discipline_id,page )=>{ let url='/paths.json'; - // '?order='+order+'&page='+page; - // if(select!=""){ - // url+='&select='+select; - // } - // if(search!=""){ - // url+='&search='+search; - // } axios.get(url,{params:{ - order:order, + sort:"desc", + limit:16, + order:order, page:page, - select:select, - // search:search + discipline_id:discipline_id, + sub_discipline_id:sub_discipline_id }}).then((result)=>{ if(result.status==200){ this.setState({ - sortList:result.data.tags, pathList:result.data.subjects, total_count:result.data.total_count }) @@ -119,11 +119,6 @@ class ShixunPathSearch extends Component{ }) } - - setHistoryFun=(url)=>{ - this.props.history.push(url) - } - //头部获取是否已经登录了 getUser=(url,type)=>{ if(this.props.checkIfLogin()===false){ @@ -140,9 +135,41 @@ class ShixunPathSearch extends Component{ } + } + + getshixunchildValues=(e,id,item)=>{ + + this.setState({ + discipline_id:item.id, + sub_discipline_id:id, + }) + let { order,page }=this.state; + this.getList(order,item.id,id,page ); + e.stopPropagation(); + } + + getmenu=(list,item)=>{ + return( +
+ ) } render() { - let { order,sortList,search,page,total_count,select }=this.state; + let { order,sortList,search,page,total_count,discipline_id }=this.state; let pathstype=false; if(this.props&&this.props.mygetHelmetapi!=null){ let paths="/paths"; @@ -156,8 +183,8 @@ class ShixunPathSearch extends Component{ }) } - // console.log(this.props) - return ( + + return (