Commit 5d467882 by zhanghaozhe

快捷登录

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