'use strict'; import React, { useState, useEffect } from 'react'; import { connect } from 'react-redux'; import { push } from 'react-router-redux'; import { Button, Input, Form, Row, Col, message } from 'antd'; import { login } from '../actions/auth'; import './style.less'; import leftTop from '../../quanju/containers/footer/conserve/left/left-top'; const FormItem = Form.Item; const Login = props => { const { dispatch, user, error, isRequesting } = props const [username, setUserName] = useState('') const [password, setPassword] = useState('') const [inputChanged, setInputChanged] = useState(false) useEffect(() => { }, []) useEffect(() => { if (error) { message.error(error); setPassword('') } }, [error]) useEffect(() => { const allroutes = JSON.parse(sessionStorage.getItem('allRoutes')) || [] let hasAuth = [] if (user && user.authorized) { hasAuth = allroutes?.filter((item) => { return user?.userResources.find((child) => { return child.resourceId === item.authCode }) }) if (user?.username === 'SuperAdmin') { dispatch(push('/fillion/infor')) } else if (hasAuth && hasAuth.length > 0) { const path = hasAuth[0].path //console.log('sasa', `${path}`) dispatch(push(path)) } else { dispatch(push('/noContent')) } } //user && user.authorized ? dispatch(push('/screen/cockpit')) : null }, [user]) const enterHandler = e => { if (e.key === 'Enter') { setInputChanged(false) dispatch(login(username, password)); } }; const handleLogin = () => { let reg_user = "SuperAdmin"; let reg_tel = /^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/; //11位手机号码正则 if (username == reg_user || reg_tel.test(username)) { setInputChanged(false) dispatch(login(username, password)) return } if (username == "" || password == "") { setInputChanged(false) dispatch(login(username, password)) return } setInputChanged(false) dispatch(login(username, password)) } return (