Commit 5d467882 by zhanghaozhe

快捷登录

parent b41c453e
import React, { Component } from 'react'; import React, { Component } from 'react';
import './index.scss' import './index.scss'
import Input from '../Input' import Input from '../Input'
import { Link } from "react-router-dom";
class InputWithCountryCodes extends Component { class InputWithCountryCodes extends Component {
static defaultProps = {
countryCode: '86'
}
render() { render() {
const {countryCode, ...rest} = this.props const {country, ...rest} = this.props
return ( return (
<div className={'input-with-country-codes'}> <div className={'input-with-country-codes'}>
<div className="country-codes"> <div className="country-codes">
+{countryCode} <Link to={'/country'}>
<i className={'iconfont iconiconfront-69'}/> +{country && country.num || 86}
<i className={'iconfont iconiconfront-69'}/>
</Link>
</div> </div>
<Input {...rest}/> <Input {...rest}/>
</div> </div>
......
...@@ -8,7 +8,7 @@ import { compose } from 'redux'; ...@@ -8,7 +8,7 @@ import { compose } from 'redux';
import { Toast } from "antd-mobile"; import { Toast } from "antd-mobile";
import { HeaderBar, Captcha } from "@/common"; import { HeaderBar, Captcha } from "@/common";
import ClearableInput from '../common/clearableInputWithCountryCodes' import ClearableInput from '../common/clearableInputWithCountryCodes'
import { validateTel, http, api } from "@/utils"; import { http } from "@/utils";
import { quickLogin } from '@/store/userAction'; import { quickLogin } from '@/store/userAction';
import OnSubmissionError from '../common/OnSubmissionError' import OnSubmissionError from '../common/OnSubmissionError'
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
...@@ -111,7 +111,7 @@ const formikConfig = { ...@@ -111,7 +111,7 @@ const formikConfig = {
validateOnBlur: true, validateOnBlur: true,
validate: values => { validate: values => {
let errors = {} let errors = {}
if (!validateTel(values.tel)) { if (!/\d/.test(values.tel)) {
errors.tel = '请输入正确的手机号' errors.tel = '请输入正确的手机号'
} }
values.veriCode.toString().length !== 6 && (errors.veriCode = '验证码格式不正确') values.veriCode.toString().length !== 6 && (errors.veriCode = '验证码格式不正确')
......
...@@ -13,7 +13,7 @@ import { connect } from 'react-redux'; ...@@ -13,7 +13,7 @@ import { connect } from 'react-redux';
import { compose } from 'redux'; import { compose } from 'redux';
import { isEmpty } from 'lodash' import { isEmpty } from 'lodash'
import { Toast } from 'antd-mobile'; import { Toast } from 'antd-mobile';
import { validateTel, getParam } from "@/utils"; import { validateTel } from "@/utils";
import { HeaderBar } from "@/common"; import { HeaderBar } from "@/common";
...@@ -70,7 +70,8 @@ class Login extends Component { ...@@ -70,7 +70,8 @@ class Login extends Component {
const { const {
loginWays, loginWays,
errors, errors,
values values,
country
} = this.props } = this.props
return ( return (
<div className='login'> <div className='login'>
...@@ -85,9 +86,7 @@ class Login extends Component { ...@@ -85,9 +86,7 @@ class Login extends Component {
type={'tel'} type={'tel'}
placeholder={'手机号快捷登录(免注册)'} placeholder={'手机号快捷登录(免注册)'}
wrapperClass={'tel-input'} wrapperClass={'tel-input'}
/*icon={<i className={'iconfont iconshouji'} country={country}
style={{fontSize: '22px', left: '10px'}}
/>}*/
/> />
)} )}
> >
...@@ -109,6 +108,7 @@ class Login extends Component { ...@@ -109,6 +108,7 @@ class Login extends Component {
errors={errors} errors={errors}
placeholder={'请输入验证码'} placeholder={'请输入验证码'}
instance={this.state.captchaInstance} instance={this.state.captchaInstance}
country={country}
/> />
)} )}
/> />
...@@ -133,7 +133,8 @@ const FormikConfig = { ...@@ -133,7 +133,8 @@ const FormikConfig = {
handleSubmit(values, {props}) { handleSubmit(values, {props}) {
props.quickLogin({ props.quickLogin({
phone_num: values.tel, phone_num: values.tel,
phone_code: values.veriCode phone_code: values.veriCode,
area_code: props.country.num
}).then(res => { }).then(res => {
if (res.hasError) { if (res.hasError) {
Toast.info(res.msg); Toast.info(res.msg);
...@@ -159,7 +160,7 @@ const FormikConfig = { ...@@ -159,7 +160,7 @@ const FormikConfig = {
export default compose( export default compose(
connect( connect(
null, state => ({country: state.country}),
{quickLogin} {quickLogin}
), ),
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