|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
|
|
|
|
|
import { Pagination , Spin } from 'antd';
|
|
|
|
|
import {Pagination, Spin, Dropdown, Menu} from 'antd';
|
|
|
|
|
|
|
|
|
|
import NoneData from '../../courses/coursesPublic/NoneData'
|
|
|
|
|
import axios from 'axios';
|
|
|
|
@ -16,11 +16,11 @@ class InfosShixun extends Component{
|
|
|
|
|
this.state={
|
|
|
|
|
category:undefined,
|
|
|
|
|
page:1,
|
|
|
|
|
sort_by:'time',
|
|
|
|
|
status:undefined,
|
|
|
|
|
per_page:16,
|
|
|
|
|
isSpin:false,
|
|
|
|
|
|
|
|
|
|
sort_by: "updated_at",
|
|
|
|
|
sort_direction: "desc",
|
|
|
|
|
totalCount:undefined,
|
|
|
|
|
data:undefined
|
|
|
|
|
}
|
|
|
|
@ -30,11 +30,15 @@ class InfosShixun extends Component{
|
|
|
|
|
this.setState({
|
|
|
|
|
isSpin:true
|
|
|
|
|
})
|
|
|
|
|
let{category,status,sort_by,page}=this.state;
|
|
|
|
|
this.getCourses(category,status,sort_by,page);
|
|
|
|
|
let {category, status, sort_by, page, sort_direction} = this.state;
|
|
|
|
|
this.getCourses(category, status, sort_by, page, sort_direction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getCourses=(category,status,sort_by,page)=>{
|
|
|
|
|
getCourses = (category, status, sort_by, page, sort_direction) => {
|
|
|
|
|
// console.log("请求数据成功");
|
|
|
|
|
// console.log("getCourses");
|
|
|
|
|
// console.log(sort_by);
|
|
|
|
|
// console.log(sort_direction);
|
|
|
|
|
let url=`/users/${this.props.match.params.username}/shixuns.json`;
|
|
|
|
|
axios.get((url),{params:{
|
|
|
|
|
category,
|
|
|
|
@ -44,14 +48,21 @@ class InfosShixun extends Component{
|
|
|
|
|
per_page:this.props.is_current && category && page ==1?17:16
|
|
|
|
|
}}).then((result)=>{
|
|
|
|
|
if(result){
|
|
|
|
|
console.log("请求数据成功");
|
|
|
|
|
console.log(sort_by);
|
|
|
|
|
this.setState({
|
|
|
|
|
totalCount:result.data.count,
|
|
|
|
|
data:result.data,
|
|
|
|
|
sort_by: sort_by,
|
|
|
|
|
sort_direction: sort_direction,
|
|
|
|
|
isSpin:false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}).catch((error)=>{
|
|
|
|
|
console.log(error);
|
|
|
|
|
this.setState({
|
|
|
|
|
isSpin: false
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -63,8 +74,8 @@ class InfosShixun extends Component{
|
|
|
|
|
page:1,
|
|
|
|
|
isSpin:true
|
|
|
|
|
})
|
|
|
|
|
let{sort_by}=this.state;
|
|
|
|
|
this.getCourses(cate,undefined,sort_by,1);
|
|
|
|
|
let {sort_by, sort_direction} = this.state;
|
|
|
|
|
this.getCourses(cate, undefined, sort_by, 1, sort_direction);
|
|
|
|
|
}
|
|
|
|
|
// 切换状态
|
|
|
|
|
changeStatus=(status)=>{
|
|
|
|
@ -73,8 +84,8 @@ class InfosShixun extends Component{
|
|
|
|
|
page:1,
|
|
|
|
|
isSpin:true
|
|
|
|
|
})
|
|
|
|
|
let{category,sort_by}=this.state;
|
|
|
|
|
this.getCourses(category,status,sort_by,1);
|
|
|
|
|
let {category, sort_by, sort_direction} = this.state;
|
|
|
|
|
this.getCourses(category, status, sort_by, 1, sort_direction);
|
|
|
|
|
}
|
|
|
|
|
//切换页数
|
|
|
|
|
changePage=(page)=>{
|
|
|
|
@ -82,8 +93,8 @@ class InfosShixun extends Component{
|
|
|
|
|
page,
|
|
|
|
|
isSpin:true
|
|
|
|
|
})
|
|
|
|
|
let{category,sort_by,status}=this.state;
|
|
|
|
|
this.getCourses(category,status,sort_by,page);
|
|
|
|
|
let {category, sort_by, status, sort_direction} = this.state;
|
|
|
|
|
this.getCourses(category, status, sort_by, page, sort_direction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 进入课堂
|
|
|
|
@ -98,8 +109,28 @@ class InfosShixun extends Component{
|
|
|
|
|
sort_by:sort,
|
|
|
|
|
isSpin:true
|
|
|
|
|
})
|
|
|
|
|
let{category,status,page}=this.state;
|
|
|
|
|
this.getCourses(category,status,sort,page);
|
|
|
|
|
let {category, status, page, sort_direction} = this.state;
|
|
|
|
|
this.getCourses(category, status, sort, page, sort_direction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//切换种类
|
|
|
|
|
updatedlist(sort_by) {
|
|
|
|
|
//按照什么样子排序
|
|
|
|
|
this.setState({
|
|
|
|
|
isSpin: true
|
|
|
|
|
});
|
|
|
|
|
let {category, status, page, sort_direction} = this.state;
|
|
|
|
|
this.getCourses(category, status, sort_by, 1, "desc");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//排序
|
|
|
|
|
updatedlists(sort_direction) {
|
|
|
|
|
//是否是倒序
|
|
|
|
|
this.setState({
|
|
|
|
|
isSpin: true
|
|
|
|
|
});
|
|
|
|
|
let {category, status, page, sort_by} = this.state;
|
|
|
|
|
this.getCourses(category, status, sort_by, page, sort_direction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
@ -110,10 +141,22 @@ class InfosShixun extends Component{
|
|
|
|
|
page,
|
|
|
|
|
data,
|
|
|
|
|
totalCount,
|
|
|
|
|
sort_direction,
|
|
|
|
|
isSpin
|
|
|
|
|
} = this.state;
|
|
|
|
|
|
|
|
|
|
let is_current=this.props.is_current;
|
|
|
|
|
const menu = (
|
|
|
|
|
<Menu>
|
|
|
|
|
<Menu.Item onClick={() => this.updatedlist("updated_at")}>
|
|
|
|
|
最新动态
|
|
|
|
|
</Menu.Item>
|
|
|
|
|
<Menu.Item onClick={() => this.updatedlist("created_at")}>
|
|
|
|
|
语言类别
|
|
|
|
|
</Menu.Item>
|
|
|
|
|
|
|
|
|
|
</Menu>
|
|
|
|
|
);
|
|
|
|
|
return(
|
|
|
|
|
<div className="educontent">
|
|
|
|
|
<Spin size="large" spinning={isSpin}>
|
|
|
|
@ -140,17 +183,57 @@ class InfosShixun extends Component{
|
|
|
|
|
<li className={status=="passed" ? "active" : ""}><a href="javascript:void(0)" onClick={()=>this.changeStatus("passed")}>已通关</a></li>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
<div className="pl25 pr25 clearfix font-12 mb20 mt20">
|
|
|
|
|
<div className="pl25 pr25 clearfix font-12 " style={{
|
|
|
|
|
lineHeight: "41px",
|
|
|
|
|
}}>
|
|
|
|
|
<span className="fl color-grey-9">共参与{totalCount}个{category?category=="manage"?"发布":"学习":"实训"}</span>
|
|
|
|
|
<div className="fr">
|
|
|
|
|
<li className="drop_down">
|
|
|
|
|
<span className="color-grey-9 font-12">{sort_by=="time"?"时间最新":"语言类别"}</span><i className="iconfont icon-xiajiantou font-12 ml2 color-grey-6"></i>
|
|
|
|
|
<ul className="drop_down_normal">
|
|
|
|
|
<li onClick={()=>this.changeOrder("time")}>时间最新</li>
|
|
|
|
|
<li onClick={()=>this.changeOrder("language")}>语言类别</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</li>
|
|
|
|
|
</div>
|
|
|
|
|
<sapn className="relativef fr"
|
|
|
|
|
style={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
height: "40px",
|
|
|
|
|
lineHeight: "40px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<span
|
|
|
|
|
style={{
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
textAlign: "center",
|
|
|
|
|
height: "10px",
|
|
|
|
|
lineHeight: "10px",
|
|
|
|
|
display: "table",
|
|
|
|
|
marginTop: "9px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<i className={sort_direction === "asc" ?
|
|
|
|
|
"iconfont icon-sanjiaoxing-up font-12 color-blue h10 " : "iconfont icon-sanjiaoxing-up font-12 h10"}
|
|
|
|
|
onClick={() => this.updatedlists("asc")}></i>
|
|
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<span
|
|
|
|
|
style={{
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
height: "10px",
|
|
|
|
|
lineHeight: "10px",
|
|
|
|
|
textAlign: "center",
|
|
|
|
|
display: "table",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<i className={sort_direction === "desc" ?
|
|
|
|
|
"iconfont icon-sanjiaoxing-down font-12 yslbottomsj color-blue h10" : "iconfont icon-sanjiaoxing-down font-12 yslbottomsj h10"}
|
|
|
|
|
onClick={() => this.updatedlists("desc")}></i>
|
|
|
|
|
</span>
|
|
|
|
|
</sapn>
|
|
|
|
|
<Dropdown overlay={menu}>
|
|
|
|
|
<span className="fr color-grey-9 mr10 pointer " style={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "initial",
|
|
|
|
|
}}>
|
|
|
|
|
<span>{sort_by === "updated_at" ? '最新动态' : sort_by === "created_at" ? '语言类别' : ""}</span>
|
|
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
</div>
|
|
|
|
|
<style>
|
|
|
|
|
{
|
|
|
|
@ -160,6 +243,7 @@ class InfosShixun extends Component{
|
|
|
|
|
left: 10px;
|
|
|
|
|
bottom: 100px;
|
|
|
|
|
}
|
|
|
|
|
.square-list{width: 100%;box-sizing: border-box;margin-top:10px}
|
|
|
|
|
`
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|