竞赛详情完善信息-第一版

This commit is contained in:
caishi 2022-05-25 14:35:44 +08:00
parent 3ecfec141c
commit 66da0266fc
5 changed files with 122 additions and 116 deletions

View File

@ -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 }) {

View File

@ -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;
}

View File

@ -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>
)

View File

@ -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>

View File

@ -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 },
});