Commit d6020b62 by zhanghaozhe

忘记密码验证

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