Commit 17482b6c by zhanghaozhe

账号登录

parent 48f9746a
import React, { PureComponent } from "react" import React, { PureComponent } from "react"
import './accountLogin.scss' import './accountLogin.scss'
import { Link } from "react-router-dom"; import { Link } from "react-router-dom"
import { withFormik, FastField, Form } from "formik"; import { withFormik, FastField, Form } from "formik"
import { compose } from 'redux'; import { compose } from 'redux'
import { accountLogin } from '@/store/userAction'; import { accountLogin } from '@/store/userAction'
import { connect } from "react-redux"; import { connect } from "react-redux"
import { isEmpty } from 'lodash' import { isEmpty } from 'lodash'
import { HeaderBar } from "@/common"; import { HeaderBar } from "@/common"
import Header from "../common/Header"; import Header from "../common/Header"
import Input from '../common/Input' import Input from '../common/Input'
import LoginButton from '../common/LoginButton' import LoginButton from '../common/LoginButton'
import PasswordInput from '../common/passwordInput' import PasswordInput from '../common/passwordInput'
import { Toast } from "antd-mobile"; import { Toast } from "antd-mobile"
class AccountLogin extends PureComponent { class AccountLogin extends PureComponent {
...@@ -60,7 +60,7 @@ class AccountLogin extends PureComponent { ...@@ -60,7 +60,7 @@ class AccountLogin extends PureComponent {
<Link className={'forgot-password-btn'} to='/passport/forgot-password'>忘记密码</Link> <Link className={'forgot-password-btn'} to='/passport/forgot-password'>忘记密码</Link>
</Form> </Form>
</div> </div>
); )
} }
} }
...@@ -74,12 +74,21 @@ const formikConfig = { ...@@ -74,12 +74,21 @@ const formikConfig = {
const {props, props: {history}} = formikBag const {props, props: {history}} = formikBag
const from = props.location.state && props.location.state.from const from = props.location.state && props.location.state.from
props.accountLogin({ props.accountLogin({
username, password,redirect: from && window.location.origin + from.pathname + from.search + from.hash username, password, redirect: from && window.location.origin + from.pathname + from.search + from.hash
}).then(res => { }).then(res => {
if (res.hasError) { if (res.hasError) {
Toast.info(res.msg, 2, null, false) Toast.info(res.msg, 2, null, false)
} }
}) })
},
validate: values => {
const errors = {}
if (!values.account) {
errors.account = '账号不能为空'
} else if (!values.password) {
errors.password = '密码不能为空'
}
return errors
} }
} }
......
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