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 }) {
|
*ForgeCheckName({ payload }, { call, put }) {
|
||||||
const response = yield call(ForgeCheckName, { ...payload,debug:"admin" });
|
const response = yield call(ForgeCheckName, { ...payload });
|
||||||
return response;
|
return response;
|
||||||
},
|
},
|
||||||
*ForgeCheckEmail({ payload }, { call, put }) {
|
*ForgeCheckEmail({ payload }, { call, put }) {
|
||||||
const response = yield call(ForgeCheckEmail, { ...payload,debug:"admin" });
|
const response = yield call(ForgeCheckEmail, { ...payload });
|
||||||
return response;
|
return response;
|
||||||
},
|
},
|
||||||
*ForgeSaveUserInfo({ payload }, { call, put }) {
|
*ForgeSaveUserInfo({ payload }, { call, put }) {
|
||||||
|
|
|
@ -13,3 +13,12 @@
|
||||||
text-align: left;
|
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,
|
email:user?.userInfo?.email,
|
||||||
username:user?.userInfo?.login
|
username:user?.userInfo?.login
|
||||||
})
|
})
|
||||||
setEmailforName(true)
|
|
||||||
}
|
}
|
||||||
},[user?.userInfo])
|
},[user?.userInfo])
|
||||||
|
|
||||||
|
@ -45,13 +44,17 @@ const InitGitlink:FC<PageProps>=({
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
if(emailforName){
|
if(emailforName){
|
||||||
// 如果输入的邮箱已存在用户就走登录流程
|
// 如果输入的邮箱已存在用户就走登录流程
|
||||||
dispatch({
|
var res = await dispatch({
|
||||||
type:"user/ForgeLogin",
|
type:"user/ForgeLogin",
|
||||||
payload:{
|
payload:{
|
||||||
login:values?.email || user?.userInfo?.email,
|
login:values?.email || user?.userInfo?.email,
|
||||||
password:values?.password
|
password:values?.password
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if(res.status === 0){
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
setLoading(false);
|
||||||
}else{
|
}else{
|
||||||
let res = await dispatch({
|
let res = await dispatch({
|
||||||
type:"user/ForgeSaveUserInfo",
|
type:"user/ForgeSaveUserInfo",
|
||||||
|
@ -81,35 +84,44 @@ const InitGitlink:FC<PageProps>=({
|
||||||
}
|
}
|
||||||
|
|
||||||
//判断用户名(username)是否注册
|
//判断用户名(username)是否注册
|
||||||
async function usernameConfirm(rule:any, value:string, callback:any,type:any){
|
const usernameConfirm=async()=>{
|
||||||
if(value){
|
let value = form.getFieldValue("username");
|
||||||
var result = await dispatch({
|
if(value && !emailforName){
|
||||||
|
let res = await dispatch({
|
||||||
type:"user/ForgeCheckName",
|
type:"user/ForgeCheckName",
|
||||||
payload:{
|
payload:{
|
||||||
value,type
|
value,type:1
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
if(res?.status < 0){
|
||||||
callback();
|
form.setFields([{
|
||||||
}
|
name: 'username',
|
||||||
//判断邮箱(email)是否注册
|
errors: [res?.message],
|
||||||
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:""})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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}
|
footer={null}
|
||||||
>
|
>
|
||||||
<Spin spinning={loading}>
|
<Spin spinning={loading}>
|
||||||
<Form
|
<p className={styles.tips}>
|
||||||
className={styles.formWrap}
|
请完善您在GitLink平台上的账号信息以便后续参赛:如果您已有GitLink账号,请输入已有账号;如果暂无GitLink账号,平台将根据您输入的信息自动为您创建一个账号,请记住您输入的用户名和密码等信息。
|
||||||
form={form}
|
</p>
|
||||||
layout="horizontal"
|
<Form
|
||||||
onFinish={handleFinish}
|
className={styles.formWrap}
|
||||||
>
|
form={form}
|
||||||
<Form.Item
|
layout="horizontal"
|
||||||
label="姓名"
|
onFinish={handleFinish}
|
||||||
>
|
>
|
||||||
<span style={{fontSize:"16px"}}>{user?.userInfo?.real_name}</span>
|
<Form.Item
|
||||||
</Form.Item>
|
label="姓名"
|
||||||
<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"}}
|
|
||||||
>
|
>
|
||||||
取消
|
<span style={{fontSize:"16px"}}>{user?.userInfo?.real_name}</span>
|
||||||
</Button>
|
</Form.Item>
|
||||||
<Button
|
<Form.Item
|
||||||
size="large"
|
label="邮箱"
|
||||||
type="primary"
|
name="email"
|
||||||
htmlType="submit"
|
rules={[
|
||||||
style={{marginRight:"30px",width:"80px"}}
|
{required: true,message: '请输入邮箱'},
|
||||||
|
]}
|
||||||
|
validateFirst={true}
|
||||||
|
validateTrigger={'onChange'}
|
||||||
>
|
>
|
||||||
保存
|
<Input placeholder="请输入邮箱" size={"large"} onBlur={useremailConfirm}/>
|
||||||
</Button>
|
</Form.Item>
|
||||||
</Form.Item>
|
<Form.Item
|
||||||
</Form>
|
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>
|
</Spin>
|
||||||
</Modal>
|
</Modal>
|
||||||
)
|
)
|
||||||
|
|
|
@ -82,8 +82,10 @@ const competitionDetails: FC<PageProps> = ({
|
||||||
const see = useRef(null);
|
const see = useRef(null);
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
setSubGitlinkShow(true);
|
if(user?.userInfo?.is_new){
|
||||||
},[])
|
setSubGitlinkShow(true);
|
||||||
|
}
|
||||||
|
},[user?.userInfo])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function init() {
|
async function init() {
|
||||||
|
@ -323,7 +325,7 @@ const competitionDetails: FC<PageProps> = ({
|
||||||
return (
|
return (
|
||||||
<div className={"edu-container minH500"}>
|
<div className={"edu-container minH500"}>
|
||||||
<SubCompetition visible={subComShow} onClose={()=>setSubComShow(false)} filterlist={subComList}/>
|
<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 className="mt10" separator=">">
|
||||||
<Breadcrumb.Item><Link to={"/competitions/index"}>在线竞赛</Link></Breadcrumb.Item>
|
<Breadcrumb.Item><Link to={"/competitions/index"}>在线竞赛</Link></Breadcrumb.Item>
|
||||||
<Breadcrumb.Item>{HeaderDetail.name}{HeaderDetail.sub_title ? '-' + HeaderDetail.sub_title : null}</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) {
|
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',
|
method: 'post',
|
||||||
body: { ...params },
|
body: { ...params },
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue