注册和找回密码优化

This commit is contained in:
谢思 2021-11-18 15:37:06 +08:00
parent d81d456d76
commit 4e18d13b6b
3 changed files with 15 additions and 7 deletions

View File

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

View File

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

View File

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