This commit is contained in:
caishi 2022-04-03 10:48:26 +08:00
parent ba56a106b4
commit eb6f54496f
8 changed files with 104 additions and 55 deletions

View File

@ -22,7 +22,7 @@ const JoinProjectModal: FC<PageProps> = ({
onCancel = () => { },
}) => {
const [inputValue, setInputValue] = useState<string>();
const [radioValue, setRadioValue] = useState<string>();
const [radioValue, setRadioValue] = useState<string>("developer");
const [isLoading, setIsLoading] = useState<boolean>(false);
const handleOk = async () => {
@ -41,36 +41,40 @@ const JoinProjectModal: FC<PageProps> = ({
setIsLoading(true);
const res = await projectApplies({
code: inputValue,
role: radioValue
applied_project:{
code: inputValue,
role: radioValue
}
});
setIsLoading(false);
handleCancel();
const mapping: any = {
1: "您输入的邀请码错误",
2: "您已经是该项目成员",
3: "请选择一个角色",
4: "您的申请已提交,请等待项目管理员审批",
5: "您已经申请加入该项目了,请耐心等待",
6: "您已成功加入项目",
}
// const mapping: any = {
// 1: "您输入的邀请码错误",
// 2: "您已经是该项目成员",
// 3: "请选择一个角色",
// 4: "您的申请已提交,请等待项目管理员审批",
// 5: "您已经申请加入该项目了,请耐心等待",
// 6: "您已成功加入项目",
// }
if (mapping[res.status]) {
message.info(mapping[res.status]);
return;
}
// if (res.status !== 0 ) {
// message.info(res.message);
// return;
// }
if (res.status === 0) {
if (radioValue === "reporter") {
message.success('您加入项目成功!');
trackEvent(['开发项目', '加入项目成功'])
history.push(`/projects/${res?.project_id}`);
} else {
trackEvent(['开发项目', '加入项目等待审批'])
message.success('您的申请已提交,请等待项目管理员审批!');
}
return;
}
// if (res.status === 0) {
// if (radioValue === "reporter") {
// message.success('您加入项目成功!');
// trackEvent(['开发项目', '加入项目成功'])
// history.push(`/projects/${res?.project_id}`);
// } else {
// trackEvent(['开发项目', '加入项目等待审批'])
// message.success('您的申请已提交,请等待项目管理员审批!');
// }
// return;
// }
message.info(res.message);
return;
};
const handleCancel = async () => {
@ -82,16 +86,17 @@ const JoinProjectModal: FC<PageProps> = ({
<Modal
centered
keyboard={false}
closable={false}
closable={true}
title="加入项目"
visible={visible}
confirmLoading={isLoading}
onOk={handleOk}
onCancel={handleCancel}
wrapClassName={styles.joinModal}
>
<div className="tc">
<div>
<span></span>
<span></span>
<Input
placeholder="请输入6位开发项目邀请码"
style={{ width: 270 }}
@ -105,12 +110,12 @@ const JoinProjectModal: FC<PageProps> = ({
}}
/>
</div>
<div className="mt10 font14">
<span></span>
<div className="mt30 font14">
<span className="mr5"></span>
<Radio.Group value={radioValue} onChange={e => setRadioValue(e.target.value)}>
<Radio value={Type.Manager}></Radio>
<Radio value={Type.Developer}></Radio>
<Radio value={Type.Reporter}></Radio>
<Radio value={Type.Manager}></Radio>
<Radio value={Type.Developer}></Radio>
<Radio value={Type.Reporter}></Radio>
</Radio.Group>
</div>
</div>

View File

@ -1,5 +1,29 @@
@import '../../../../global.less';
.dropdownFlex{
a{
font-size: 14px;
}
}
.joinModal{
[class=~'ant-modal-title']{
text-align: center;
height: 50px;
line-height: 50px;
}
[class~='ant-modal-close-x']{
height: 70px;
line-height: 70px;
svg{
font-size: 18px;
}
}
[class=~'tc']{
padding:22px 0px;
}
[class~='ant-btn']{
height: 32px;
}
}
.rightMenu {
width: 120px;
text-align: center;

View File

@ -55,20 +55,21 @@ const Join: FC<PageProps> = ({
const [visibleJoinProject, setVisibleJoinProject] = useState<boolean>();
const handleJoinVerify = (type: VerifyType) => {
if (!handleVerify(dispatch)) {
return;
}
// if (!handleVerify(dispatch)) {
// return;
// }
if (type === VerifyType.Projects && !user.userInfo?.email) {
message.info('请先绑定邮箱,谢谢');
return;
}
// if (type === VerifyType.Projects && !user.userInfo?.email) {
// message.info('请先绑定邮箱,谢谢');
// return;
// }
if (type === VerifyType.Classrooms) {
setVisibleJoinClassroom(true);
} else if (type === VerifyType.Projects) {
setVisibleJoinProject(true);
}
// if (type === VerifyType.Classrooms) {
// setVisibleJoinClassroom(true);
// } else if (type === VerifyType.Projects) {
// setVisibleJoinProject(true);
// }
setVisibleJoinProject(true);
}
const handleAddVerify = (url: string, type?: VerifyType) => {
@ -170,14 +171,31 @@ const Join: FC<PageProps> = ({
// </Row>
// </>
// }
const JoinOverlay = (joinProps: any) => {
const JoinOverlay = (list: any) => {
return <>
<div className={styles.dropdownFlex}>
<Menu>
{
list.map(function(item:any,key:number){
return(
(item.name !=="加入课堂" && item.name !=="加入开发项目") &&
<Menu.Item key={item.name+key}>
<a onClick={()=>{window.location.href=item.url}}>{item.name}</a>
</Menu.Item>
)
})
}
<Menu.Item>
<a onClick={() => handleJoinVerify(VerifyType.Projects)}></a>
</Menu.Item>
</Menu>
</div>
</>
}
return <section>
<Dropdown overlay={<Menu className={`${styles.rightMenu} ${styles.joinMenu} mt10`}><JoinOverlay /></Menu>} placement="bottomRight">
return (
<section>
<Dropdown overlay={()=>JoinOverlay(globalSetting?.setting?.add) } placement="bottomRight">
<span style={{ lineHeight: 'inherit' }} className="iconfont icon-tianjiafangda c-white font18 current ml15 mr15"></span>
</Dropdown>
<JoinClassroomModal
@ -188,7 +206,7 @@ const Join: FC<PageProps> = ({
visible={visibleJoinProject}
onCancel={() => setVisibleJoinProject(false)}
/>
</section>
</section>)
}
export default connect(
({

View File

@ -308,7 +308,7 @@ const User: FC<PageProps> = ({
if (isLogin()) {
return (
<Dropdown
className={`mr25`}
className={`${styles.height67} mr25`}
overlay={OwnerDownMenu}
placement="bottomLeft"
>

View File

@ -4,6 +4,7 @@
min-width: 1200px;
[class~='ant-layout-header'] {
padding: 0;
height: 60px;
}
.logo {

View File

@ -308,7 +308,7 @@ const HeaderComponents: FC<PageProps> = ({
{
!checkIsClientExam() && <>
<SearchInput />
{!isLogin && <Join />}
{!isLogin && !!user?.userInfo?.login && <Join />}
{
!!user?.userInfo?.login && <a className="iconfont icon-xiaoxilingdang c-white ml15 mr15 font18 relative" href ={`${globalSetting?.setting?.common?.main_site_url}/settings/notice`}>{user?.userInfo?.message_unread_total && <span className={styles.newslight}>{user?.userInfo?.message_unread_total}</span>}</a>
}

View File

@ -76,7 +76,7 @@ const UserModel: UserModelType = {
},
*getUserInfo({ payload }, { call, put }) {
// location.search
const response = yield call(getUserInfo, { ...payload,debug:"admin" })
const response = yield call(getUserInfo, { ...payload})
localStorage.userInfo = JSON.stringify(response);
yield put({

View File

@ -1,4 +1,5 @@
import Fetch from '@/utils/fetch';
import ENV from '@/utils/env';
export async function HomeIndex() {
return Fetch('/api/home/index.json', {
@ -13,7 +14,7 @@ export async function applyToJoinCourse(params: any) {
});
}
export async function projectApplies(params: any) {
return Fetch('/api/project_applies.json', {
return Fetch(`${ENV.FORGE_SERVER}/api/applied_projects.json`, {
method: 'post',
body: params
});