From e51192ed5f41f206ffdec4f469467970ec91808c 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, 20 Jul 2019 22:38:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/user/usersInfo/InfosCourse.js | 406 +++++++++--------- 1 file changed, 204 insertions(+), 202 deletions(-) diff --git a/public/react/src/modules/user/usersInfo/InfosCourse.js b/public/react/src/modules/user/usersInfo/InfosCourse.js index 109a4d7b9..e27513963 100644 --- a/public/react/src/modules/user/usersInfo/InfosCourse.js +++ b/public/react/src/modules/user/usersInfo/InfosCourse.js @@ -1,203 +1,205 @@ -import React, { Component } from 'react'; -import { SnackbarHOC } from 'educoder'; -import {BrowserRouter as Router,Route,Switch} from 'react-router-dom'; -import {Tooltip,Menu,Pagination,Spin} from 'antd'; -import Loadable from 'react-loadable'; -import Loading from '../../../Loading'; -import axios from 'axios'; -import NoneData from '../../courses/coursesPublic/NoneData' -import {getImageUrl} from 'educoder'; -import { TPMIndexHOC } from '../../tpm/TPMIndexHOC'; -import { CNotificationHOC } from '../../courses/common/CNotificationHOC' -import "./usersInfo.css" -import Create from './publicCreatNew' - -class InfosCourse extends Component{ - constructor(props){ - super(props); - this.state={ - category:undefined, - status:undefined, - page:1, - per_page:16, - - totalCount:undefined, - data:undefined, - isSpin:false - } - } - - componentDidMount=()=>{ - this.setState({ - isSpin:true - }) - let{category,status,page}=this.state; - this.getCourses(category,status,page); - } - - getCourses=(category,status,page)=>{ - let url=`/users/${this.props.match.params.username}/courses.json`; - axios.get((url),{params:{ - category, - status, - page, - per_page: this.props.is_current && category && page ==1?17:16 - }}).then((result)=>{ - if(result){ - this.setState({ - totalCount:result.data.count, - data:result.data, - isSpin:false - }) - } - }).catch((error)=>{ - console.log(error); - }) - } - - //切换种类 - changeCategory=(cate)=>{ - this.setState({ - category:cate, - page:1, - isSpin:true - }) - let{status}=this.state; - this.getCourses(cate,status,1); - } - //切换状态 - changeStatus=(status)=>{ - this.setState({ - status:status, - page:1, - isSpin:true - }) - let{category}=this.state; - this.getCourses(category,status,1); - } - //切换页数 - changePage=(page)=>{ - this.setState({ - page, - isSpin:true - }) - let{category,status}=this.state; - this.getCourses(category,status,page); - } - - // 进入课堂 - turnToCourses=(url,flag)=>{ - if(flag){ - this.props.history.push(url); - } - } - - render(){ - let{ - category, - status, - page, - data, - totalCount, - isSpin - } = this.state; - let isStudent = this.props.isStudent(); - let is_current=this.props.is_current; - return( -
- -
-
  • this.changeCategory()}>全部
  • -
  • this.changeCategory("manage")}>{is_current ? "我":"TA"}管理的
  • -
  • this.changeCategory("study")}>{is_current ? "我":"TA"}学习的
  • -
    - { - is_current && -
    -
  • this.changeStatus()}>全部
  • -
  • this.changeStatus("processing")}>正在进行
  • -
  • this.changeStatus("end")}>已结束
  • -
    - } -

    - 共参与{totalCount}个{category?category=="manage"?"发布":"学习":"课堂"} - 时间最新 -

    -
    - { - !isStudent && page == 1 && !category && is_current && - - } - { - (!data || data.courses.length==0) && (isStudent || category) && - } - { - data && data.courses && data.courses.map((item,key)=>{ - return( -
    this.turnToCourses(`${item.first_category_url}`,item.can_visited)} style={{"cursor": "pointer"}}> - { - item.is_public == 1 && - -
    - - 公开 -
    - } - { - item.can_visited ==false? -
    - -

    非成员不能访问

    -
    :"" - } - -
    -

    - {item.name} -

    - 用户 -

    {item.teacher && item.teacher.real_name}

    -

    {item.teacher && item.teacher.school_name}

    -
    -
    -
    - { - item.members_count > 0 && - - - {item.members_count} - - } - { - item.homework_commons_count > 0 && - - - {item.homework_commons_count} - - } - { - item.attachments_count > 0 && - - - {item.attachments_count} - - } -
    -
    -
    - ) - }) - } -
    - { - totalCount > 15 && -
    - -
    - } -
    -
    - ) - } -} +import React, { Component } from 'react'; +import { SnackbarHOC } from 'educoder'; +import {BrowserRouter as Router,Route,Switch} from 'react-router-dom'; +import {Tooltip,Menu,Pagination,Spin} from 'antd'; +import Loadable from 'react-loadable'; +import Loading from '../../../Loading'; +import axios from 'axios'; +import NoneData from '../../courses/coursesPublic/NoneData' +import {getImageUrl} from 'educoder'; +import { TPMIndexHOC } from '../../tpm/TPMIndexHOC'; +import { CNotificationHOC } from '../../courses/common/CNotificationHOC' +import "./usersInfo.css" +import Create from './publicCreatNew' + +class InfosCourse extends Component{ + constructor(props){ + super(props); + this.state={ + category:undefined, + status:undefined, + page:1, + per_page:16, + + totalCount:undefined, + data:undefined, + isSpin:false + } + } + + componentDidMount=()=>{ + this.setState({ + isSpin:true + }) + let{category,status,page}=this.state; + this.getCourses(category,status,page); + } + + getCourses=(category,status,page)=>{ + let url=`/users/${this.props.match.params.username}/courses.json`; + axios.get((url),{params:{ + category, + status, + page, + per_page: this.props.is_current && category && page ==1?17:16 + }}).then((result)=>{ + if(result){ + this.setState({ + totalCount:result.data.count, + data:result.data, + isSpin:false + }) + } + }).catch((error)=>{ + console.log(error); + }) + } + + //切换种类 + changeCategory=(cate)=>{ + this.setState({ + category:cate, + page:1, + isSpin:true + }) + let{status}=this.state; + this.getCourses(cate,status,1); + } + //切换状态 + changeStatus=(status)=>{ + this.setState({ + status:status, + page:1, + isSpin:true + }) + let{category}=this.state; + this.getCourses(category,status,1); + } + //切换页数 + changePage=(page)=>{ + this.setState({ + page, + isSpin:true + }) + let{category,status}=this.state; + this.getCourses(category,status,page); + } + + // 进入课堂 + turnToCourses=(url,flag)=>{ + if(flag){ + this.props.history.push(url); + } + } + + render(){ + let{ + category, + status, + page, + data, + totalCount, + isSpin + } = this.state; + let isStudent = this.props.isStudent(); + let is_current=this.props.is_current; + + console.log(this.props.current_user&&this.props.current_user.user_identity==="学生") + return( +
    + +
    +
  • this.changeCategory()}>全部
  • +
  • this.changeCategory("manage")}>{is_current ? "我":"TA"}管理的
  • +
  • this.changeCategory("study")}>{is_current ? "我":"TA"}学习的
  • +
    + { + is_current && +
    +
  • this.changeStatus()}>全部
  • +
  • this.changeStatus("processing")}>正在进行
  • +
  • this.changeStatus("end")}>已结束
  • +
    + } +

    + 共参与{totalCount}个{category?category=="manage"?"发布":"学习":"课堂"} + 时间最新 +

    +
    + { + !isStudent && page == 1 && !category && is_current && + this.props.current_user&&this.props.current_user.user_identity==="学生"?"": + } + { + (!data || data.courses.length==0) && (isStudent || category) && + } + { + data && data.courses && data.courses.map((item,key)=>{ + return( +
    this.turnToCourses(`${item.first_category_url}`,item.can_visited)} style={{"cursor": "pointer"}}> + { + item.is_public == 1 && + +
    + + 公开 +
    + } + { + item.can_visited ==false? +
    + +

    非成员不能访问

    +
    :"" + } + +
    +

    + {item.name} +

    + 用户 +

    {item.teacher && item.teacher.real_name}

    +

    {item.teacher && item.teacher.school_name}

    +
    +
    +
    + { + item.members_count > 0 && + + + {item.members_count} + + } + { + item.homework_commons_count > 0 && + + + {item.homework_commons_count} + + } + { + item.attachments_count > 0 && + + + {item.attachments_count} + + } +
    +
    +
    + ) + }) + } +
    + { + totalCount > 15 && +
    + +
    + } +
    +
    + ) + } +} export default InfosCourse; \ No newline at end of file