forked from Gitlink/forgeplus-react
注册和找回密码优化
This commit is contained in:
parent
d81d456d76
commit
4e18d13b6b
|
@ -6,11 +6,13 @@ export default ({history}) => {
|
|||
const [searchValue, setSearchValue] = useState("");
|
||||
|
||||
function onGlobalSearch(e) {
|
||||
history.push('/search?value=' + e.target.value);
|
||||
window.location.href = `/search?value=${e.target.value}`;
|
||||
}
|
||||
return (
|
||||
<React.Fragment>
|
||||
<div className="headSerach aboutSubTitle" onBlur={()=>setSearchValue("")}>
|
||||
<div className="headSerach aboutSubTitle" onBlur={()=>{setTimeout(() => {
|
||||
setSearchValue("");
|
||||
}, 500)}}>
|
||||
<i className = "iconfont icon-bianzu11 font-15" onClick={()=>onGlobalSearch({target:{value:searchValue}})}></i>
|
||||
<Input placeholder="请输入搜索关键字" onPressEnter={onGlobalSearch} onChange={(value)=>setSearchValue(value.target.value)} value={searchValue}></Input>
|
||||
</div>
|
||||
|
|
|
@ -8,7 +8,10 @@ import './LoginRegisterPage.scss';
|
|||
function Register(props){
|
||||
const {form} = props;
|
||||
const {getFieldDecorator } = form;
|
||||
//用户输入的符合规则的邮箱(用于获取验证码)
|
||||
const [emailStr, setEmailStr] = useState(undefined);
|
||||
//用户输入的符合规则的用户名,用于当用户输入符合规则的用户名之后再更改又去触发check.json接口
|
||||
const [loginStr, setLoginStr] = useState(undefined);
|
||||
const [secondsStr, setSecondsStr] = useState(60);
|
||||
const [countDown, setCountDown] = useState(false);
|
||||
const [getCaptchaBut, setGetCaptchaBut] = useState(false);
|
||||
|
@ -50,27 +53,29 @@ function Register(props){
|
|||
//判断用户名(username)是否注册
|
||||
function usernameConfirm(rule, value, callback){
|
||||
setUserNameGo(true);
|
||||
value && userNameGo ? axios.post(`/accounts/check.json`, {
|
||||
value && (userNameGo || value !== loginStr) ? axios.post(`/accounts/check.json`, {
|
||||
value: value,
|
||||
type: 1
|
||||
}).then(response => {
|
||||
if (response.data.status === -1) {
|
||||
callback('该名称已经被使用');
|
||||
} else {
|
||||
setLoginStr(value);
|
||||
setUserNameGo(false);
|
||||
callback();
|
||||
}
|
||||
}):callback()
|
||||
}):callback();setLoginStr(undefined);
|
||||
}
|
||||
|
||||
//判断邮箱是否注册
|
||||
function emailConfirm(rule, value, callback) {
|
||||
setEmailGo(true);
|
||||
value && emailGo ? axios.post(`/accounts/check.json`, {
|
||||
value && (emailGo || value !== emailStr) ? axios.post(`/accounts/check.json`, {
|
||||
value: value,
|
||||
type: 2
|
||||
}).then(response => {
|
||||
if (response.data.status === -1) {
|
||||
setGetCaptchaBut(false);
|
||||
callback('该邮箱已被注册');
|
||||
} else {
|
||||
setEmailStr(value);
|
||||
|
|
|
@ -57,16 +57,17 @@ function ResetPassword(props) {
|
|||
//判断邮箱是否注册
|
||||
function emailConfirm(rule, value, callback) {
|
||||
setEmailGo(true);
|
||||
value && emailGo ? axios.post(`/accounts/check.json`, {
|
||||
value && (emailGo || value !== emailStr) ? axios.post(`/accounts/check.json`, {
|
||||
value: value,
|
||||
type: 2
|
||||
}).then(response => {
|
||||
if (response.data && response.data.status === -1) {
|
||||
setEmailStr(value)
|
||||
setEmailStr(value);
|
||||
setGetCaptchaBut(true);
|
||||
setEmailGo(false);
|
||||
callback();
|
||||
} else {
|
||||
setGetCaptchaBut(false);
|
||||
callback('此邮箱未注册');
|
||||
}
|
||||
}):callback();setEmailStr(undefined);
|
||||
|
|
Loading…
Reference in New Issue