diff --git a/src/modules/user/usersInfo/Infos.js b/src/modules/user/usersInfo/Infos.js index b673176ed..f1463e072 100644 --- a/src/modules/user/usersInfo/Infos.js +++ b/src/modules/user/usersInfo/Infos.js @@ -32,6 +32,10 @@ const InfosProject = Loadable({ loader: () => import('./InfosProject'), loading: Loading, }) +const UserProjects = Loadable({ + loader: () => import('./Projects'), + loading: Loading, +}) const InfosVideo = Loadable({ loader: () => import('./video/InfosVideo'), loading: Loading, @@ -263,12 +267,21 @@ class Infos extends Component { > {/* 开发项目 */} - () } + > */} + + + () + } > + + {/* 众包 */} { + this.setState({ + isSpin:true + }) + let {category, status, page, sort_by, sort_direction} = this.state; + this.getCourses(category, status, page, sort_by, sort_direction); + } + + getCourses = (category, status, page, sort_by, sort_direction) => { + let url=`/users/${this.props.match.params.username}/projects.json`; + axios.get((url),{params:{ + category, + status, + page, + sort_by, + sort_direction, + per_page:this.props.is_current && category && page ==1?17:16 + }}).then((result)=>{ + if(result){ + if (result.data.status === 403||result.data.status === 401||result.data.status === 500||result.data.status === 404) { + this.setState({ + isSpin:false, + totalCount:0 + }) + }else{ + 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 + }) + }) + } + + //切换种类 + changeCategory=(cate)=>{ + this.setState({ + category:cate, + page:1, + isSpin:true + }) + let {status, sort_by, sort_direction} = this.state; + this.getCourses(cate, status, 1, sort_by, + sort_direction); + } + //切换状态 + changeStatus=(status)=>{ + this.setState({ + status:status, + page:1, + isSpin:true + }) + let { + category, sort_by, + sort_direction + } = this.state; + this.getCourses(category, status, 1, sort_by, + sort_direction); + } + //切换页数 + changePage=(page)=>{ + this.setState({ + page, + isSpin:true + }) + let { + category, status, sort_by, + sort_direction + } = this.state; + this.getCourses(category, status, page, sort_by, + sort_direction); + } + + // 进入项目 + turnToCourses=(url,flag)=>{ + if(flag){ + window.location.href=url; + } + } + + + //切换种类 + updatedlist(sort_by) { + //按照什么样子排序 + this.setState({ + isSpin: true + }); + let {category, status, page, sort_direction} = this.state; + this.getCourses(category, status, 1, sort_by, "desc"); + } + + //排序 + updatedlists(sort_directions) { + //是否是倒序 + this.setState({ + isSpin: true + }); + let {category, status, page, sort_by, sort_direction} = this.state; + let sort_directiony = sort_directions; + if (sort_directions === "asc") { + if (sort_directions === sort_direction) { + sort_directiony = "desc" + } + } else if (sort_directions === "desc") { + if (sort_directions === sort_direction) { + sort_directiony = "asc" + } + } + this.getCourses(category, status, page, sort_by, sort_directiony); + } + + render(){ + let{ + category, + status, + page, + data, + totalCount, + isSpin, + sort_by, + sort_direction + } = this.state; + let isStudent = this.props.isStudent(); + let is_current=this.props.is_current; + const {current_user} = this.props + + const menu = ( + + this.updatedlist("updated_on")}> + 最新动态 + + this.updatedlist("created_on")}> + 最新创建 + + + + ); + return( +
+ + +
+
  • this.changeCategory()} className="font-16 w32">全部
  • +
  • this.changeCategory("manage")} + className={is_current ? "font-16 w66" : "font-16 w80"}>{is_current ? "我" : "TA"}管理的
  • +
  • this.changeCategory("study")} + className={is_current ? "font-16 w66" : "font-16 w80"}>{is_current ? "我" : "TA"}参与的
  • +
    + + { + is_current && +
    +
  • this.changeStatus()} + className=" w32">全部
  • +
  • this.changeStatus("publicly")} className=" w60">公开
  • +
  • this.changeStatus("personal")} className=" w60">私有
  • +
    + } +

    + 共参与{totalCount}个{category?category=="manage"?"发布":"学习":"项目"} + + + this.updatedlists("asc")}> + + + + + this.updatedlists("desc")}> + + + + + {sort_by === "updated_on" ? '最近更新' : sort_by === "created_on" ? '最新创建' : ""} + + + +

    + +
    + {/* 289 */} + { + page == 1 && is_current ? + :"" + } + { + (!data || (data && data.projects.length==0)) && category && + + } + { + data===undefined||data.projects.length===0?category=="manage"||category=="study"?""::"" + } + { + data && data.projects && data.projects.map((item,key)=>{ + return( +
    this.turnToCourses(`/projects/${item.id}`,item.can_visited)} style={{"cursor": "pointer","height":"289px"}}> + { + item.is_public==1 && + +
    + + 公开 +
    + } + { + item.can_visited ==false? +
    + +

    非成员不能访问

    +
    :"" + } +
    +

    + {item.name} +

    + 用户 +

    {item.owner.real_name}

    +

    + { + item.category && item.category.name && {item.category.name} + } + { + item.language && item.language.name && {item.language.name} + } + {/*{item.category.school_name}*/} +

    +
    +
    +
    + { + item.members_count > 0 && + + + {item.members_count} + + + } + { + item.issues_count > 0 && + + + {item.issues_count} + + + } + { + item.changesets_count > 0 && + + + {item.changesets_count} + + + } +
    +
    +
    + ) + }) + } +
    + { + totalCount > 15 && +
    + +
    + } +
    +
    + ) + } +} +export default Projects;