forked from Gitlink/forgeplus-react
竞赛详情完善信息-第一版
This commit is contained in:
parent
3ecfec141c
commit
66da0266fc
|
@ -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 }) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ const InitGitlink:FC<PageProps>=({
|
|||
email:user?.userInfo?.email,
|
||||
username:user?.userInfo?.login
|
||||
})
|
||||
setEmailforName(true)
|
||||
}
|
||||
},[user?.userInfo])
|
||||
|
||||
|
@ -45,13 +44,17 @@ const InitGitlink:FC<PageProps>=({
|
|||
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<PageProps>=({
|
|||
}
|
||||
|
||||
//判断用户名(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<PageProps>=({
|
|||
footer={null}
|
||||
>
|
||||
<Spin spinning={loading}>
|
||||
<Form
|
||||
className={styles.formWrap}
|
||||
form={form}
|
||||
layout="horizontal"
|
||||
onFinish={handleFinish}
|
||||
>
|
||||
<Form.Item
|
||||
label="姓名"
|
||||
<p className={styles.tips}>
|
||||
请完善您在GitLink平台上的账号信息以便后续参赛:如果您已有GitLink账号,请输入已有账号;如果暂无GitLink账号,平台将根据您输入的信息自动为您创建一个账号,请记住您输入的用户名和密码等信息。
|
||||
</p>
|
||||
<Form
|
||||
className={styles.formWrap}
|
||||
form={form}
|
||||
layout="horizontal"
|
||||
onFinish={handleFinish}
|
||||
>
|
||||
<span style={{fontSize:"16px"}}>{user?.userInfo?.real_name}</span>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="邮箱"
|
||||
name="email"
|
||||
rules={[{
|
||||
required: true,
|
||||
message: '请输入邮箱',
|
||||
},
|
||||
{
|
||||
validator: (rule:any, value:any, callback:any) => { useremailConfirm(rule, value, callback,2) }
|
||||
}]}
|
||||
validateTrigger={"onBlur"}
|
||||
validateFirst={true}
|
||||
>
|
||||
<Input placeholder="请输入邮箱" size={"large"} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="用户名"
|
||||
name="username"
|
||||
rules={[
|
||||
{
|
||||
required:true,
|
||||
message:"请输入用户名"
|
||||
},
|
||||
{
|
||||
pattern: /^[a-zA-Z]/,
|
||||
message: "用户名必须以字母开头"
|
||||
},
|
||||
{
|
||||
pattern: /[a-zA-Z0-9]$/,
|
||||
message: "用户名只能使用英文字母和数字"
|
||||
},
|
||||
{
|
||||
min: 4,
|
||||
max: 15,
|
||||
message: "用户名长度为4到15个字符"
|
||||
},
|
||||
{
|
||||
validator: (rule:any, value:any, callback:any,type:any) => { usernameConfirm(rule, value, callback,1) }
|
||||
}
|
||||
]}
|
||||
validateTrigger={"onBlur"}
|
||||
validateFirst={true}
|
||||
>
|
||||
<Input placeholder="请输入4-15位用户名,以字母开头,只能使用字母和数字" disabled={emailforName} size={"large"}/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="密码"
|
||||
name="password"
|
||||
rules={[{
|
||||
required: true,
|
||||
message: '请输入密码',
|
||||
}]}
|
||||
>
|
||||
<Input.Password placeholder="请输入密码" size={"large"}/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label=" "
|
||||
colon={false}
|
||||
>
|
||||
<Button
|
||||
size="large"
|
||||
type="default"
|
||||
onClick={onClose}
|
||||
style={{marginRight:"30px",width:"80px"}}
|
||||
<Form.Item
|
||||
label="姓名"
|
||||
>
|
||||
取消
|
||||
</Button>
|
||||
<Button
|
||||
size="large"
|
||||
type="primary"
|
||||
htmlType="submit"
|
||||
style={{marginRight:"30px",width:"80px"}}
|
||||
<span style={{fontSize:"16px"}}>{user?.userInfo?.real_name}</span>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="邮箱"
|
||||
name="email"
|
||||
rules={[
|
||||
{required: true,message: '请输入邮箱'},
|
||||
]}
|
||||
validateFirst={true}
|
||||
validateTrigger={'onChange'}
|
||||
>
|
||||
保存
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
<Input placeholder="请输入邮箱" size={"large"} onBlur={useremailConfirm}/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="用户名"
|
||||
name="username"
|
||||
rules={[
|
||||
{required:true,message:"请输入用户名"},
|
||||
{pattern: /^[a-zA-Z]/,message: "用户名必须以字母开头"},
|
||||
{pattern: /[a-zA-Z0-9]$/,message: "用户名只能使用英文字母和数字"},
|
||||
{min: 4,max: 15,message: "用户名长度为4到15个字符"}
|
||||
]}
|
||||
validateFirst={true}
|
||||
validateTrigger={'onChange'}
|
||||
>
|
||||
<Input placeholder="请输入4-15位用户名,以字母开头,只能使用字母和数字" disabled={emailforName} size={"large"} onBlur={usernameConfirm}/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="密码"
|
||||
name="password"
|
||||
rules={[{
|
||||
required: true,
|
||||
message: '请输入密码',
|
||||
}]}
|
||||
>
|
||||
<Input.Password placeholder="请输入密码" size={"large"}/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label=" "
|
||||
colon={false}
|
||||
>
|
||||
<Button
|
||||
size="large"
|
||||
type="default"
|
||||
onClick={onClose}
|
||||
style={{marginRight:"30px",width:"80px"}}
|
||||
>
|
||||
取消
|
||||
</Button>
|
||||
<Button
|
||||
size="large"
|
||||
type="primary"
|
||||
htmlType="submit"
|
||||
style={{marginRight:"30px",width:"80px"}}
|
||||
>
|
||||
保存
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Spin>
|
||||
</Modal>
|
||||
)
|
||||
|
|
|
@ -82,8 +82,10 @@ const competitionDetails: FC<PageProps> = ({
|
|||
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<PageProps> = ({
|
|||
return (
|
||||
<div className={"edu-container minH500"}>
|
||||
<SubCompetition visible={subComShow} onClose={()=>setSubComShow(false)} filterlist={subComList}/>
|
||||
<InitGitLink visible={subGitlinkShow && !user?.userInfo?.is_new} onClose={()=>setSubGitlinkShow(false)}/>
|
||||
<InitGitLink visible={subGitlinkShow} onClose={()=>setSubGitlinkShow(false)}/>
|
||||
<Breadcrumb className="mt10" separator=">">
|
||||
<Breadcrumb.Item><Link to={"/competitions/index"}>在线竞赛</Link></Breadcrumb.Item>
|
||||
<Breadcrumb.Item>{HeaderDetail.name}{HeaderDetail.sub_title ? '-' + HeaderDetail.sub_title : null}</Breadcrumb.Item>
|
||||
|
|
|
@ -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 },
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue