Commit d6020b62 by zhanghaozhe

忘记密码验证

parent ed40ea49
......@@ -12,7 +12,7 @@ class ClearableInput extends Component {
inputClass,
type = 'text',
icon,
setValues,
setFieldValue,
...rest
} = this.props
let clearIconStyle = {
......@@ -31,7 +31,7 @@ class ClearableInput extends Component {
<i
className={'iconfont icondanseshixintubiao-3 clear'}
onClick={() => {
setValues({[name]: ''})
setFieldValue(name,'')
}}
style={clearIconStyle}
/>
......
......@@ -6,12 +6,16 @@ function Input({
icon,
wrapperClass,
children,
value,
name,
...rest
}) {
return (
<div className={classnames('input-wrapper', wrapperClass)}>
<input
className='input'
name={name}
value={value}
{...rest}
/>
{icon}
......
......@@ -21,7 +21,6 @@ class VeriCodeInput extends Component {
countDown = () => {
let {count} = this.state
if (!this.state.isFirst) {
Toast.info('请重新进行滑块验证', 2, null, false)
this.props.instance.refresh()
......@@ -57,7 +56,6 @@ class VeriCodeInput extends Component {
sendCode = () => {
if (!this.validate()) return
console.log(this.getType())
this.getType() === 'email' ? this.sendEmail() : this.sendSMS();
return true;
}
......@@ -82,6 +80,10 @@ class VeriCodeInput extends Component {
sendSMS = () => {
const {action, tel, challenge} = this.props
if (!tel) {
Toast.info('请输入手机号或邮箱地址')
return
}
http.post(`${api['passport-api']}/quick_sms`, {
phone_num: tel,
action: action || 'login',
......@@ -103,16 +105,29 @@ class VeriCodeInput extends Component {
const {tel, challenge, account} = this.props
let hasTel = has(this.props, 'tel')
let content
if (hasTel) {
if (!tel) {
content = '手机号码不能为空'
}
if (validateTel(tel)) {
content = '请输入正确格式的手机号码'
}
} else {
if (!account) {
content = '手机号或电子邮件不能为空'
}
if ((hasTel && !tel) || (!hasTel && !account)) {
if (!validateTel(account) && !validateEmail(account)) {
content = '请输入正确格式的手机号或电子邮件'
}
}
if (content) {
Toast.info(content, 2, null, false)
return false
}
if (!challenge) {
Toast.info('请进行滑块验证', 2, null, false)
return false
......@@ -121,10 +136,10 @@ class VeriCodeInput extends Component {
}
render() {
let {type = 'number', className, ...rest} = this.props
let { className, ...rest} = this.props
return (
<Input
type={type}
type={'number'}
wrapperClass={className}
{...rest}
>
......
......@@ -7,7 +7,7 @@ import { connect } from 'react-redux';
import { compose } from 'redux';
import { Toast } from "antd-mobile";
import { HeaderBar, Captcha, ClearableInput } from "@/common";
import { validateTel, validateEmail } from "@/utils";
import { validateTel, validateEmail, http, api } from "@/utils";
import { quickLogin } from '@/store/userAction';
import { isEmpty } from "lodash";
......@@ -52,10 +52,10 @@ class ForgotPassword extends Component {
return (
<ClearableInput
{...field}
setValues={form.setValues}
type={'tel'}
placeholder={'请输入注册时的邮箱账号或手机号'}
wrapperClass={'tel-input'}
setFieldValue={form.setFieldValue}
icon={<i className={'iconfont iconshouji'}
style={{fontSize: '22px', left: '11px'}}
/>}
......@@ -107,17 +107,25 @@ const formikConfig = {
return errors
},
handleSubmit(values, {props}) {
console.log(props)
props.quickLogin({
phone_num: values.account,
phone_code: values.veriCode
}).then(res => {
if (res.hasError) {
Toast.info(res.msg);
let account, address
if (validateEmail(values.account)) {
account = 'email'
address = 'check_email_code'
} else {
let state = props.location.state || {from: {pathname: '/'}}
account = 'phone_num'
address = 'check_phone_code'
}
props.history.replace(state.from)
http.post(`${api['passport-api']}/${address}`, {
[account]: values.account,
code: values.veriCode
}).then(res => {
if(res.data.errno == 0){
props.history.push('/passport/set-password')
}else {
Toast.info(res.data.msg)
}
})
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment