diff --git a/src/models/user/index.ts b/src/models/user/index.ts index 6dc29199..7d54c097 100755 --- a/src/models/user/index.ts +++ b/src/models/user/index.ts @@ -117,11 +117,11 @@ const UserModel: UserModelType = { }); }, *ForgeCheckName({ payload }, { call, put }) { - const response = yield call(ForgeCheckName, { ...payload,debug:"admin" }); + const response = yield call(ForgeCheckName, { ...payload }); return response; }, *ForgeCheckEmail({ payload }, { call, put }) { - const response = yield call(ForgeCheckEmail, { ...payload,debug:"admin" }); + const response = yield call(ForgeCheckEmail, { ...payload }); return response; }, *ForgeSaveUserInfo({ payload }, { call, put }) { diff --git a/src/pages/Competitions/Detail/components/InitGitLink/index.less b/src/pages/Competitions/Detail/components/InitGitLink/index.less index 935ca24b..b028e18f 100644 --- a/src/pages/Competitions/Detail/components/InitGitLink/index.less +++ b/src/pages/Competitions/Detail/components/InitGitLink/index.less @@ -13,3 +13,12 @@ text-align: left; } } +.tips { + max-width: 530px; + margin: 0px auto 15px; + padding: 10px 15px; + border: 1px solid #ffbb4e; + background-color: rgba(255, 187, 78, 0.1); + border-radius: 2px; + color: #333; +} diff --git a/src/pages/Competitions/Detail/components/InitGitLink/index.tsx b/src/pages/Competitions/Detail/components/InitGitLink/index.tsx index 092350f5..d14e7074 100644 --- a/src/pages/Competitions/Detail/components/InitGitLink/index.tsx +++ b/src/pages/Competitions/Detail/components/InitGitLink/index.tsx @@ -37,7 +37,6 @@ const InitGitlink:FC=({ email:user?.userInfo?.email, username:user?.userInfo?.login }) - setEmailforName(true) } },[user?.userInfo]) @@ -45,13 +44,17 @@ const InitGitlink:FC=({ setLoading(true); if(emailforName){ // 如果输入的邮箱已存在用户就走登录流程 - dispatch({ + var res = await dispatch({ type:"user/ForgeLogin", payload:{ login:values?.email || user?.userInfo?.email, password:values?.password } }) + if(res.status === 0){ + onClose(); + } + setLoading(false); }else{ let res = await dispatch({ type:"user/ForgeSaveUserInfo", @@ -81,35 +84,44 @@ const InitGitlink:FC=({ } //判断用户名(username)是否注册 - async function usernameConfirm(rule:any, value:string, callback:any,type:any){ - if(value){ - var result = await dispatch({ + const usernameConfirm=async()=>{ + let value = form.getFieldValue("username"); + if(value && !emailforName){ + let res = await dispatch({ type:"user/ForgeCheckName", payload:{ - value,type + value,type:1 } }) - } - callback(); - } - //判断邮箱(email)是否注册 - async function useremailConfirm(rule:any, value:string, callback:any,type:any){ - if(value){ - var result = await dispatch({ - type:"user/ForgeCheckEmail", - payload:{ - email:value - } - }) - if(result?.login){ - setEmailforName(true); - form.setFieldsValue({username:result?.login}) - }else{ - setEmailforName(false); - form.setFieldsValue({username:""}) + if(res?.status < 0){ + form.setFields([{ + name: 'username', + errors: [res?.message], + }]) } } - callback(); + } + //判断邮箱(email)是否注册 + async function useremailConfirm(){ + let value = form.getFieldValue('email'); + if (!value) { + return Promise.resolve() + } + var result = await dispatch({ + type:"user/ForgeCheckEmail", + payload:{ + email:value + } + }) + if(result?.login){ + setEmailforName(value === user?.userInfo?.email ? false : true); + form.setFieldsValue({username:result?.login}) + return Promise.resolve(); + }else{ + setEmailforName(false); + form.setFieldsValue({username:""}) + return Promise.resolve(); + } } @@ -126,94 +138,77 @@ const InitGitlink:FC=({ footer={null} > -
- + 请完善您在GitLink平台上的账号信息以便后续参赛:如果您已有GitLink账号,请输入已有账号;如果暂无GitLink账号,平台将根据您输入的信息自动为您创建一个账号,请记住您输入的用户名和密码等信息。 +

+ - {user?.userInfo?.real_name} -
- { useremailConfirm(rule, value, callback,2) } - }]} - validateTrigger={"onBlur"} - validateFirst={true} - > - - - { usernameConfirm(rule, value, callback,1) } - } - ]} - validateTrigger={"onBlur"} - validateFirst={true} - > - - - - - - - - - -
+ + + + + + + + + + + + +
) diff --git a/src/pages/Competitions/Detail/index.tsx b/src/pages/Competitions/Detail/index.tsx index 0405f7e4..488dd7c6 100644 --- a/src/pages/Competitions/Detail/index.tsx +++ b/src/pages/Competitions/Detail/index.tsx @@ -82,8 +82,10 @@ const competitionDetails: FC = ({ const see = useRef(null); useEffect(()=>{ - setSubGitlinkShow(true); - },[]) + if(user?.userInfo?.is_new){ + setSubGitlinkShow(true); + } + },[user?.userInfo]) useEffect(() => { async function init() { @@ -323,7 +325,7 @@ const competitionDetails: FC = ({ return (
setSubComShow(false)} filterlist={subComList}/> - setSubGitlinkShow(false)}/> + setSubGitlinkShow(false)}/> 在线竞赛 {HeaderDetail.name}{HeaderDetail.sub_title ? '-' + HeaderDetail.sub_title : null} diff --git a/src/service/user.ts b/src/service/user.ts index 0bc5855b..5b71af97 100755 --- a/src/service/user.ts +++ b/src/service/user.ts @@ -14,7 +14,7 @@ export async function ForgeLoginOut(params: any) { }); } export async function ForgeCheckName(params: any) { - return Fetch(`${ENV.FORGE_SERVER}/api/accounts/check.json`, { + return Fetch(`${ENV.FORGE_SERVER}/api/accounts/login_check.json`, { method: 'post', body: { ...params }, });