diff --git a/src/glcc/api.js b/src/glcc/api.js index 217d7870d..89e8e5694 100644 --- a/src/glcc/api.js +++ b/src/glcc/api.js @@ -88,4 +88,12 @@ export function studentApplyList(params) { method: 'get', params }); +} + +// 课题详情 +export function getTaskById(id) { + return fetch({ + url: `/api/applyInformation/task/${id}`, + method: 'get' + }); } \ No newline at end of file diff --git a/src/glcc/home/index.jsx b/src/glcc/home/index.jsx index c3085b392..04bc9a8ca 100644 --- a/src/glcc/home/index.jsx +++ b/src/glcc/home/index.jsx @@ -14,7 +14,7 @@ import apply2 from "../img/apply2.png"; import './index.scss'; export default (props) => { - const { current_user, isGlccApplyDate, showNotification } = props; + const { current_user, isGlccApplyDate, showNotification, studentApplyStart } = props; function goToApply() { if (isGlccApplyDate) { if (current_user && current_user.login) { @@ -30,9 +30,10 @@ export default (props) => { function goToStudent(){ // 学生报名时间 - const studentApply = Date.parse(new Date()) > 1653494400000; - if(!studentApply){ + if(!studentApplyStart){ showNotification("不在报名时间,报名开始时间为5月26日"); + }else{ + window.location.href="/glcc/student/2"; } } @@ -76,7 +77,7 @@ export default (props) => { - + diff --git a/src/glcc/home/lightspot/index.jsx b/src/glcc/home/lightspot/index.jsx index 93206a353..7b259963c 100644 --- a/src/glcc/home/lightspot/index.jsx +++ b/src/glcc/home/lightspot/index.jsx @@ -12,7 +12,7 @@ import { Link } from 'react-router-dom'; function Lightspot(props) { - const {current_user, isGlccApplyDate, showNotification} = props; + const {current_user, isGlccApplyDate, showNotification, studentApplyStart} = props; function goToApply(){ if(isGlccApplyDate){ @@ -29,9 +29,10 @@ function Lightspot(props) { function goToStudent(){ // 学生报名时间 - const studentApply = Date.parse(new Date()) > 1653494400000; - if(!studentApply){ + if(!studentApplyStart){ showNotification("不在报名时间,报名开始时间为5月26日"); + }else{ + window.location.href="/glcc/student/2"; } } diff --git a/src/glcc/img/bgPng.png b/src/glcc/img/bgPng.png new file mode 100644 index 000000000..abfa4a502 Binary files /dev/null and b/src/glcc/img/bgPng.png differ diff --git a/src/glcc/index.jsx b/src/glcc/index.jsx index 1778b66d9..0654858ee 100644 --- a/src/glcc/index.jsx +++ b/src/glcc/index.jsx @@ -12,6 +12,8 @@ import Loadable from "react-loadable"; import Loading from "../Loading"; import { ImageLayerOfCommentHOC } from "../modules/page/layers/ImageLayerOfCommentHOC"; import { useState } from "react"; +import { useEffect } from "react"; +import { getStudentApplyInfo } from "./api"; // 任务管理审核 @@ -40,11 +42,41 @@ const Project = Loadable({ loader: () => import("./project"), loading: Loading, }); +// 课题详情页面 +const TaskDetail = Loadable({ + loader: () => import("./project/taskDetail"), + loading: Loading, +}); const Glcc = (propsF) => { + const {current_user} = propsF; // 判断时间是否在开源夏令营报名时间内(4月15日~5月20日) const isGlccApplyDate = Date.parse(new Date()) < 1653062400000; + // 学生报名时间new Date().getTime() > new Date('2022-05-26').getTime() + const studentApplyStart = new Date().getTime() > new Date('2022-05-26').getTime(); + const isStudentApplyDate = new Date().getTime() > new Date('2022-05-26').getTime() && new Date().getTime() < new Date('2022-06-25').getTime(); + const studentApplyEnd = new Date().getTime() > new Date('2022-06-25').getTime(); + + // 用户已报名课题id数组 + const [applyTaskId, setApplyTaskId] = useState({}); + // 刷新用户课题报名信息 + const [studentInfoReset, setStudentInfoReset] = useState(undefined); + + useEffect(()=>{ + // 获取用户课题报名信息current_user user_id + current_user && current_user.login && getStudentApplyInfo({userId: current_user.user_id}).then(response=>{ + if(response && response.message === "success"){ + // setData(response.data.rows); + const data = {}; + response.data && response.data.registrationStudentTaskList.map(item=>{ + data[item.taskId] = item.id; + }) + setApplyTaskId(data); + } + }) + },[studentInfoReset, current_user]) + return (
@@ -52,7 +84,7 @@ const Glcc = (propsF) => { ( - + )} > {/* 开源夏令营报名页面 */} @@ -69,18 +101,24 @@ const Glcc = (propsF) => { )} > + ( + + )} + > {/* 项目/课题列表 */} ( - + )} > {/* 首页 */} ( - + )} > diff --git a/src/glcc/project/component/projectDetail.jsx b/src/glcc/project/component/projectDetail.jsx index e8575d900..43ee10346 100644 --- a/src/glcc/project/component/projectDetail.jsx +++ b/src/glcc/project/component/projectDetail.jsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { Button, message } from 'antd'; +import { Button, message, Tooltip } from 'antd'; import Nodata from '../../../forge/Nodata'; import { useEffect } from 'react'; import { getProjectById } from '../../api'; @@ -45,16 +45,19 @@ export default ({ detail, projectId, applyTaskId, current_user, showLoginDialog, {info.registrationTaskList && info.registrationTaskList.length > 0 ? info.registrationTaskList.map(item=>{ return
-
{item.taskName}
+
{window.location.href=`/glcc/student/detail/${item.id}`}}>{item.taskName}
导师姓名:   {item.tutorName}
邮箱地址:   {item.tutorMail}
      {item.taskDesc}
-
奖金:   {item.taskReward}
- {item.taskUrl &&
课题链接:   {item.taskUrl}
} -
{(isStudentApplyDate || studentApplyEnd) && (applyTaskId && item.id && Object.keys(applyTaskId).includes(item.id.toString()) ? : isStudentApplyDate && )}
+ {item.taskUrl &&
课题链接:   {item.taskUrl}
} +
+ {(isStudentApplyDate || studentApplyEnd) && (applyTaskId && item.id && Object.keys(applyTaskId).includes(item.id.toString()) ? : isStudentApplyDate && )} + +
+
¥{item.taskReward}
}) : }
:
diff --git a/src/glcc/project/index.jsx b/src/glcc/project/index.jsx index 652de14c0..cf78af126 100644 --- a/src/glcc/project/index.jsx +++ b/src/glcc/project/index.jsx @@ -1,4 +1,4 @@ -import React , { useEffect , useState } from 'react'; +import React from 'react'; import { Spin } from 'antd'; import { Route, Switch } from "react-router-dom"; import banner from "../img/studentProject.png"; @@ -6,7 +6,6 @@ import './index.scss'; import Loadable from "react-loadable"; import Loading from "../../Loading"; import { Link } from 'react-router-dom'; -import { getStudentApplyInfo } from '../api'; // 项目列表页面 const ProjectList = Loadable({ @@ -20,31 +19,9 @@ const TaskList = Loadable({ }); function Project(propsF) { - const {location, current_user, showLoginDialog} = propsF; + const {location, current_user, showLoginDialog, isStudentApplyDate, studentApplyEnd, applyTaskId, setStudentInfoReset} = propsF; const {pathname} = location; - const isStudentApplyDate = Date.parse(new Date()) > 1653494400000 && Date.parse(new Date()) < 1656086400000; - const studentApplyEnd = Date.parse(new Date()) > 1656086400000; - // const studentApplyEnd = false; - // const isStudentApplyDate = true; - // 用户已报名课题id数组 - const [applyTaskId, setApplyTaskId] = useState({}); - // 刷新用户课题报名信息 - const [studentInfoReset, setStudentInfoReset] = useState(undefined); - - useEffect(()=>{ - // 获取用户课题报名信息current_user user_id - current_user && current_user.login && getStudentApplyInfo({userId: current_user.user_id}).then(response=>{ - if(response && response.message === "success"){ - // setData(response.data.rows); - const data = {}; - response.data && response.data.registrationStudentTaskList.map(item=>{ - data[item.taskId] = item.id; - }) - setApplyTaskId(data); - } - }) - },[studentInfoReset, current_user]) return(
@@ -67,7 +44,7 @@ function Project(propsF) { ( - + )} >
+ + ) } diff --git a/src/glcc/project/taskDetail/index.jsx b/src/glcc/project/taskDetail/index.jsx new file mode 100644 index 000000000..25cf6911f --- /dev/null +++ b/src/glcc/project/taskDetail/index.jsx @@ -0,0 +1,76 @@ +import React, {useEffect, useState } from 'react'; +import { Button, message, Spin} from 'antd'; +import '../index.scss'; +import './index.scss'; +import { getTaskById } from '../../api'; +import banner from "../../img/studentProject.png"; +import bgPng from "../../img/bgPng.png"; + +// 课题列表 +function TaskDetail(props) { + const {match, current_user, showLoginDialog, isStudentApplyDate, studentApplyEnd, applyTaskId} = props + const taskId = Number(match.params.taskId); + const [detail, setDetail] = useState(undefined); + + useEffect(()=>{ + getTaskById(taskId).then(res=>{ + if(res && res.message === "success"){ + setDetail(res.data); + } + }) + },[]) + + // 申请课题按钮点击函数 + function applyTask(id){ + // 判断用户是否已经登录 + if(current_user && current_user.login){ + // 判断用户是否已经报名两个课题 + if(applyTaskId && Object.keys(applyTaskId).length >= 2){ + message.error('最多只能同时报名两个课题'); + }else{ + // 跳转到学生报名页 + window.location.href=`/glcc/student/apply/${id}`; + } + }else{ + showLoginDialog(); + } + } + + return ( +
+ + + {detail &&
+ +
+
+
{detail.taskName}
+
+ {detail.projectType && {detail.projectType}} + {detail.taskUrl && 课题链接: {detail.taskUrl}} +
+
+
+
所属项目{detail.projectName}
+
课题奖金¥{detail.taskReward}
+
导师信息{detail.tutorName} | {detail.tutorMail}
+
+
课题简介
+
{detail.taskDesc}
+
+ {(isStudentApplyDate || studentApplyEnd) && (applyTaskId && taskId && Object.keys(applyTaskId).includes(taskId.toString()) ? : isStudentApplyDate && )} +
+ + +
} +
+
+ ) +} +export default TaskDetail; \ No newline at end of file diff --git a/src/glcc/project/taskDetail/index.scss b/src/glcc/project/taskDetail/index.scss new file mode 100644 index 000000000..ac8837a6a --- /dev/null +++ b/src/glcc/project/taskDetail/index.scss @@ -0,0 +1,116 @@ +.taskDetailBgBox{ + text-align: center; + .glcc-banner { + width: 100%; + } + .goBackBox{ + width: 1200px; + margin: 0 auto; + padding: 25px 0 12px; + color: #202d40; + font-size: 16px; + border-bottom: 1px dashed #bec5d5; + a{ + color:#a4aabb; + } + } + .bgBox{ + text-align: left; + background-image:linear-gradient(180deg,#ebf2ff 0%,#ebf2ff 43.09%,#f3f4f8 100%); + padding-bottom: 100px; + position: relative; + .bgPng1{ + width: 146px; + position: absolute; + top: 230px; + left: 110px; + z-index: 0; + } + .bgPng2{ + width: 186px; + position: absolute; + top: 520px; + right: 310px; + z-index: 0; + } + } + .detailContent{ + position: relative; + z-index: 1; + width: 1200px; + margin: 25px auto 0; + background-image:linear-gradient(180deg,#f1f5ff 0%,#f3f8ff 100%); + border:1px solid #ffffff; + border-radius:4px; + padding: 40px 30px 30px; + .detailHead{ + border-bottom: 1px dashed #bec5d5; + .title{ + font-weight:700; + color:#3753c5; + font-size:20px; + } + .box{ + color:#465474; + font-size:15px; + margin: 15px 0; + .classify{ + padding: 0px 8px; + display: inline-block; + border:1px solid #6680bb; + border-radius: 4px; + margin-right: 25px; + } + } + .link{margin-left: 6px;} + } + } + .detailCont{ + background-color:#e9efff; + padding: 20px 15px; + color:#465474; + font-size:15px; + margin-top: 20px; + .bor{ + margin: 0 -15px 20px -15px; + border-bottom: 1px dashed #bec5d5;; + } + .smallTil{ + font-weight:500; + color:#000000; + margin-right: 15px; + } + .moneyBox{ + display: flex; + align-items: center; + } + .money{ + font-weight:700; + color:#ff8800; + font-size:20px; + } + div{ + margin-bottom: 15px; + } + } + .link{ + color:#466aff; + &:hover{ + color: #5d7cff !important; + } + &:active{ + color: #1140ff !important; + } + } + .applyBut{ + background-color:#466aff; + border-color: #466aff; + &:hover{background-color:#5d7cff;} + &:focus{background-color:#1140ff;} + } + .detailBut{ + height: 36px; + line-height: 36px; + margin-top: 25px; + } +} diff --git a/src/glcc/project/taskList/index.jsx b/src/glcc/project/taskList/index.jsx index f6d580828..fef20a795 100644 --- a/src/glcc/project/taskList/index.jsx +++ b/src/glcc/project/taskList/index.jsx @@ -1,12 +1,13 @@ import React, { Fragment, useEffect, useState } from 'react'; import { Checkbox, Input, message, Modal, Table, Tooltip } from 'antd'; import './index.scss'; -import { cancelTaskApply, taskList, studentApplyList } from '../../api'; +import { cancelTaskApply, taskList } from '../../api'; import ProjectDetail from '../component/projectDetail'; +import bgPng from "../../img/bgPng.png"; const { Search } = Input; // 课题列表 -function TaskList({applyTaskId, setStudentInfoReset, current_user, showLoginDialog, isStudentApplyDate, studentApplyEnd, studentInfoReset}) { +function TaskList({applyTaskId, setStudentInfoReset, current_user, showLoginDialog, isStudentApplyDate, studentApplyEnd}) { const [visible, setVisible] = useState(false); const [deleteTaskId, setDeleteTaskId] = useState(undefined); // 输入搜索框 @@ -23,7 +24,7 @@ function TaskList({applyTaskId, setStudentInfoReset, current_user, showLoginDial const columns = [ { title: '序号', dataIndex: 'index', align: 'center', className:"taskTableColumns", width: '6%', render: (text, item, index) => {(current-1)*pageSize+index + 1} }, - { title: '课题名称', dataIndex: 'taskName', className:"taskTableColumns taskName", width: '28%', ellipsis: true, render: (text, item) => {window.location.href=item.taskUrl}}>{text} }, + { title: '课题名称', dataIndex: 'taskName', className:"taskTableColumns taskName", width: '28%', ellipsis: true, render: (text, item) => {window.location.href=`/glcc/student/detail/${item.id}`}}>{text} }, { title: '项目名称', dataIndex: 'projectName', className:"taskTableColumns", width: '28%', ellipsis: true, render: (text) => {text} }, { title: '课题奖金', dataIndex: 'taskReward', className:"taskTableColumns", ellipsis: true, width: `${isStudentApplyDate || studentApplyEnd ? '15%' : ''}`, render: (text) => {text} }, { @@ -124,7 +125,8 @@ function TaskList({applyTaskId, setStudentInfoReset, current_user, showLoginDial const params = { curPage: current, keyword, - pageSize + pageSize, + userId: apply ? current_user.user_id : '' } taskList(params).then(response => { if (response && response.message === "success") { @@ -139,7 +141,7 @@ function TaskList({applyTaskId, setStudentInfoReset, current_user, showLoginDial } setLoading(false); }) - }, [keyword, current, pageSize, applyTaskId]) + }, [keyword, current, pageSize, applyTaskId, apply]) useEffect(()=>{ // if(apply){ @@ -160,7 +162,7 @@ function TaskList({applyTaskId, setStudentInfoReset, current_user, showLoginDial
- {setApply(e.target.checked)}}>已报名 + {setCurrent(1);setApply(e.target.checked)}}>已报名 { setCurrent(1); setKeyword(value) }} />
@@ -178,6 +180,8 @@ function TaskList({applyTaskId, setStudentInfoReset, current_user, showLoginDial pagination={{current: current, pageSize: pageSize, total: total, showSizeChanger: true, onShowSizeChange:onShowSizeChange, showQuickJumper: true, onChange: changePage}} />
+ + { if (response && response.message === "success") { showNotification("修改信息成功"); - // setStudentInfoReset(Math.random()); + setStudentInfoReset(Math.random()); setReload(Math.random()); setLoading(false); history.push(`/glcc/student/2`) @@ -200,7 +200,7 @@ function Apply(props) { studentApply(params).then(response => { if (response && response.message === "success") { showNotification("报名成功"); - // setStudentInfoReset(Math.random()); + setStudentInfoReset(Math.random()); setReload(Math.random()); setLoading(false); history.push(`/glcc/student/2`)