Commit ebb78528 by zhanghaozhe

绑定手机号

parent 5d467882
...@@ -7,10 +7,6 @@ ...@@ -7,10 +7,6 @@
color: $color_666; color: $color_666;
} }
.tel {
margin-bottom: 21px;
}
.verification { .verification {
margin-bottom: 21px; margin-bottom: 21px;
} }
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import './binding-tel.scss' import './binding-tel.scss'
import { withFormik, Field, Form } from "formik"; import { withFormik, Field, Form } from "formik";
import { validateTel, http, api, getParam } from "@/utils"; import { http, getParam } from "@/utils";
import { compose } from "redux"; import { compose } from "redux";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { setCurrentUser } from "@/store/userAction"; import { setCurrentUser } from "@/store/userAction";
import Captcha from '@/common/Captcha' import Captcha from '@/common/Captcha'
import {HeaderBar} from '@/common' import { HeaderBar } from '@/common'
import ClearableInput from '@common/ClearableInput' // import ClearableInput from '@common/ClearableInput'
import ClearableInput from '../common/clearableInputWithCountryCodes'
import Button from '../common/Button' import Button from '../common/Button'
import VeriCodeInput from '../common/veriCodeInput' import VeriCodeInput from '../common/veriCodeInput'
import { Toast } from "antd-mobile"; import { Toast } from "antd-mobile";
...@@ -42,7 +43,8 @@ class BindingTel extends Component { ...@@ -42,7 +43,8 @@ class BindingTel extends Component {
render() { render() {
const { const {
values, values,
errors errors,
country
} = this.props } = this.props
return ( return (
<> <>
...@@ -59,9 +61,7 @@ class BindingTel extends Component { ...@@ -59,9 +61,7 @@ class BindingTel extends Component {
setFieldValue={form.setFieldValue} setFieldValue={form.setFieldValue}
placeholder={'请输入需要绑定的手机号'} placeholder={'请输入需要绑定的手机号'}
wrapperClass={'tel'} wrapperClass={'tel'}
icon={<i className={'iconfont iconshouji'} country={country}
style={{fontSize: '22px', left: '11px'}}
/>}
/> />
) )
...@@ -77,18 +77,21 @@ class BindingTel extends Component { ...@@ -77,18 +77,21 @@ class BindingTel extends Component {
icon={<i className={'iconfont iconduanxin'} icon={<i className={'iconfont iconduanxin'}
style={{fontSize: '20px', left: '12px'}} style={{fontSize: '20px', left: '12px'}}
/>} />}
placeholder={'验证码'}
account={values.tel} account={values.tel}
tel={values.tel} tel={values.tel}
challenge={this.state.validate} challenge={this.state.validate}
instance={this.state.captchaInstance} instance={this.state.captchaInstance}
action={'auth'} action={'auth'}
country={country}
/> />
) )
}} }}
/> />
<Captcha onVerify={this.onVerify} getInstance={this.getCaptchaInstance}/> <Captcha onVerify={this.onVerify} getInstance={this.getCaptchaInstance}/>
<Button className={'complete-btn'} active={values.tel && values.veriCode && isEmpty(errors)}>完成</Button> <Button className={'complete-btn'}
active={values.tel && values.veriCode && isEmpty(errors)}>完成</Button>
</Form> </Form>
</div> </div>
</> </>
...@@ -107,7 +110,7 @@ const formikConfig = { ...@@ -107,7 +110,7 @@ const formikConfig = {
validateOnChange: true, validateOnChange: true,
validate(values) { validate(values) {
let errors = {} let errors = {}
if (!validateTel(values.tel)) { if (!/\d/.test(values.tel)) {
errors.tel = '请输入正确的手机号' errors.tel = '请输入正确的手机号'
} }
if (!values.veriCode) { if (!values.veriCode) {
...@@ -116,10 +119,12 @@ const formikConfig = { ...@@ -116,10 +119,12 @@ const formikConfig = {
return errors return errors
}, },
handleSubmit(values, {props}) { handleSubmit(values, {props}) {
alert(props.country.num)
http.post(`${API['passport-api']}/bind_mobile`, { http.post(`${API['passport-api']}/bind_mobile`, {
phone_num: values.tel, phone_num: values.tel,
phone_code: values.veriCode, phone_code: values.veriCode,
mkey: getParam('mkey'), mkey: getParam('mkey'),
area_code: props.country.num,
plat: 5 plat: 5
}).then(res => { }).then(res => {
const data = res.data const data = res.data
...@@ -135,7 +140,7 @@ const formikConfig = { ...@@ -135,7 +140,7 @@ const formikConfig = {
msg: data.data.msg msg: data.data.msg
}) })
props.history.replace(`/passport/set-password`) props.history.replace(`/passport/set-password`)
}else { } else {
location.assign(data.data['jump_url']) location.assign(data.data['jump_url'])
} }
...@@ -143,17 +148,12 @@ const formikConfig = { ...@@ -143,17 +148,12 @@ const formikConfig = {
} else { } else {
Toast.info(data.msg, 2, null, false) Toast.info(data.msg, 2, null, false)
} }
/*props.setCurrentUser({
hasError,
data
})*/
}) })
} }
} }
export default compose( export default compose(
connect( connect(
null, state => ({country: state.country}),
{setCurrentUser} {setCurrentUser}
), ),
withFormik(formikConfig), withFormik(formikConfig),
......
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