Commit aae775b1 by zhanghaozhe

忘记密码

parent ff30733f
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
border: 1px solid $border_ccc; border: 1px solid $border_ccc;
border-radius: 3px; border-radius: 3px;
-webkit-appearance: none; -webkit-appearance: none;
font-size: 15px;
&::-webkit-input-placeholder { &::-webkit-input-placeholder {
color: $color_999; color: $color_999;
......
...@@ -3,9 +3,9 @@ import './button.scss' ...@@ -3,9 +3,9 @@ import './button.scss'
import classnames from 'classnames' import classnames from 'classnames'
const Button = ({className, children}) => { const Button = ({children, active}) => {
return ( return (
<button className={classnames('custom-button', className)}> <button className={classnames('custom-button', {active})}>
{children} {children}
</button> </button>
); );
......
...@@ -18,10 +18,6 @@ class VeriCodeInput extends Component { ...@@ -18,10 +18,6 @@ class VeriCodeInput extends Component {
} }
timer = null timer = null
componentDidMount() {
console.log(this.props);
}
countDown = () => { countDown = () => {
let {count} = this.state let {count} = this.state
...@@ -52,8 +48,8 @@ class VeriCodeInput extends Component { ...@@ -52,8 +48,8 @@ class VeriCodeInput extends Component {
} }
getType = () => { getType = () => {
const {value} = this.props const {account} = this.props
if (validateEmail(value)) { if (validateEmail(account)) {
return 'email' return 'email'
} }
} }
...@@ -61,14 +57,15 @@ class VeriCodeInput extends Component { ...@@ -61,14 +57,15 @@ 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;
} }
sendEmail = () => { sendEmail = () => {
const {value, challenge} = this.props const {account, challenge} = this.props
http.post(`${api['passport-api']}/send_email_code`, { http.post(`${api['passport-api']}/send_email_code`, {
email: value, email: account,
challenge challenge
}).then(res => { }).then(res => {
if (res.data.errno === 0) { if (res.data.errno === 0) {
...@@ -111,7 +108,7 @@ class VeriCodeInput extends Component { ...@@ -111,7 +108,7 @@ class VeriCodeInput extends Component {
} else { } else {
content = '手机号或电子邮件不能为空' content = '手机号或电子邮件不能为空'
} }
if (hasTel && !tel || !hasTel && !account) { if ((hasTel && !tel) || (!hasTel && !account)) {
Toast.info(content, 2, null, false) Toast.info(content, 2, null, false)
return false return false
} }
......
...@@ -41,6 +41,7 @@ class ForgotPassword extends Component { ...@@ -41,6 +41,7 @@ class ForgotPassword extends Component {
values, values,
errors errors
} = this.props } = this.props
console.log(this.props)
return ( return (
<div className={'forgot-password'}> <div className={'forgot-password'}>
<HeaderBar title='忘记密码'/> <HeaderBar title='忘记密码'/>
...@@ -62,23 +63,29 @@ class ForgotPassword extends Component { ...@@ -62,23 +63,29 @@ class ForgotPassword extends Component {
/>) />)
}} }}
/> />
<Field {
name='veriCode' this.state.validate &&
render={({field}) => { <Field
return ( name='veriCode'
<VeriCodeInput render={({field}) => {
{...field} return (
className={'verify-code'} <VeriCodeInput
icon={<i className={'iconfont iconduanxin'} {...field}
style={{fontSize: '20px', left: '12px'}} className={'verify-code'}
/>} icon={<i className={'iconfont iconduanxin'}
/> style={{fontSize: '20px', left: '12px'}}
) />}
}} account={values.account}
/> challenge={this.state.validate}
instance={this.state.captchaInstance}
/>
)
}}
/>
}
<Captcha getInstance={this.getCaptchaInstance} onVerify={this.onVerify}/>
<Button active={values.account && values.veriCode && isEmpty(errors)}>下一步</Button>
</Form> </Form>
<Captcha getInstance={this.getCaptchaInstance} onVerify={this.onVerify}/>
<Button active={values.account && values.veriCode && isEmpty(errors)}>下一步</Button>
</div> </div>
</div> </div>
); );
...@@ -101,6 +108,7 @@ const formikConfig = { ...@@ -101,6 +108,7 @@ const formikConfig = {
return errors return errors
}, },
handleSubmit(values, {props}) { handleSubmit(values, {props}) {
console.log(props)
props.quickLogin({ props.quickLogin({
phone_num: values.account, phone_num: values.account,
phone_code: values.veriCode phone_code: values.veriCode
...@@ -118,9 +126,9 @@ const formikConfig = { ...@@ -118,9 +126,9 @@ const formikConfig = {
} }
export default compose( export default compose(
withFormik(formikConfig),
connect( connect(
null, null,
{quickLogin} {quickLogin}
) ),
withFormik(formikConfig)
)(ForgotPassword) )(ForgotPassword)
\ No newline at end of file
import React, { Component } from 'react'; import React, { Component } from 'react';
import './set-password.scss' import './set-password.scss'
import { withFormik, Form, Field } from "formik";
import PasswordInput from '../common/passwordInput' import PasswordInput from '../common/passwordInput'
import Button from '../common/Button' import Button from '../common/Button'
import classnames from 'classnames' import classnames from 'classnames'
import { compose } from 'redux'
class SetPassword extends Component { class SetPassword extends Component {
...@@ -26,14 +26,25 @@ class SetPassword extends Component { ...@@ -26,14 +26,25 @@ class SetPassword extends Component {
} }
render() { render() {
return ( return (
<div className={'set-password'}> <div className={'set-password'}>
<p className='title'>密码需要包含6-16位字母及数字</p> <p className='title'>密码需要包含6-16位字母及数字</p>
<PasswordInput <Form>
placeholder={'设置密码'} <Field
onChange={this.handleChange} name='password'
/> render={({field}) => {
<Button className={'btn-active'}>完成</Button> return (
<PasswordInput
placeholder={'设置密码'}
onChange={this.handleChange}
{...field}
/>
)
}}
/>
<Button className={'btn-active'}>完成</Button>
</Form>
<p className='user-agreement'> <p className='user-agreement'>
<i className={classnames({ <i className={classnames({
'iconfont iconiconfront-3': this.state.agree, 'iconfont iconiconfront-3': this.state.agree,
...@@ -47,4 +58,15 @@ class SetPassword extends Component { ...@@ -47,4 +58,15 @@ class SetPassword extends Component {
} }
} }
export default SetPassword; const formikConfig = {
\ No newline at end of file mapValuesToProps: () => ({
password: ''
}),
handleSubmit: (values) => {
}
}
export default compose(
withFormik(formikConfig)
)(SetPassword);
\ No newline at end of file
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