From fc68f6006949a91fced69951778a7c88859cbb6c Mon Sep 17 00:00:00 2001 From: Mr Ke <kelq@hugeinfo.com.cn> Date: Wed, 06 May 2020 10:49:07 +0800 Subject: [PATCH] Merge branch 'master' of http://120.79.193.119:9090/r/huge/frontEnd/hugeOA --- src/pages/login/login.jsx | 198 ++++++++++++++++++++++++------------------------ 1 files changed, 99 insertions(+), 99 deletions(-) diff --git a/src/pages/login/login.jsx b/src/pages/login/login.jsx index 8d6150e..3d77cf0 100644 --- a/src/pages/login/login.jsx +++ b/src/pages/login/login.jsx @@ -14,121 +14,121 @@ import fetch from '../../api/request'; class NormalLoginForm extends React.Component { - constructor(props) { - super(props); - this.config = { - navigationBarTitleText: '', - }; - this.state = { - btnLoading: false - }; - } - componentWillMount() { - document.title = '用户登录' - } - - handleSubmit = e => { - e.preventDefault(); - this.props.form.validateFields((err, values) => { - if (!err) { - console.log('Received values of form: ', values); - this.setState({ - btnLoading: true - }); - fetch({ - url: `api/account/login`, - method: 'POST', - data: { - ...values - } - }).then(res => { - this.setState({ - btnLoading: false - }) - if (res) { - this.handleRes(res); - } - }) - } - }); + constructor(props) { + super(props); + this.config = { + navigationBarTitleText: '', }; + this.state = { + btnLoading: false + }; + } + componentWillMount() { + document.title = '恒巨信息OA-用户登录' + } - handleRes = (res) => { - - // 将token放入缓存 - window.localStorage.setItem('token', res.token); - + handleSubmit = e => { + e.preventDefault(); + this.props.form.validateFields((err, values) => { + if (!err) { + console.log('Received values of form: ', values); + this.setState({ + btnLoading: true + }); fetch({ - url: `api/resource/getResource`, + url: `api/account/login`, + method: 'POST', + data: { + ...values + } }).then(res => { - console.log('res', res); - if (res) { - window.localStorage.setItem('menu', JSON.stringify(res)); - message.success('登录成功'); - this.props.history.push({ pathname: "/index" }); - } + this.setState({ + btnLoading: false + }) + if (res) { + this.handleRes(res); + } }) + } + }); + }; + handleRes = (res) => { - } + // 将token放入缓存 + window.localStorage.setItem('token', res.token); + window.localStorage.setItem('loginUser', JSON.stringify(res)); //登录的用户信息 - render() { - const { getFieldDecorator } = this.props.form; - const { btnLoading } = this.state; - return ( - <div className="login-main"> - <div className="login-div"> - <div className="login-div-top"> - <img className="login-div-top-img" src={logo} /> - </div> - <div className="login-div-content"> - <div className="login-div-content-div"> - <div className="login-div-content-div-title">登录OA云平台</div> - <Form onSubmit={this.handleSubmit} className="login-form"> - <Form.Item className="login-div-content-form-flex" > - {getFieldDecorator('account', { - rules: [{ required: true, message: '请输入账号!' }], - })( - <Input - style={{ width: '32vh', height: '5vh', margin: '12px' }} - prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />} - placeholder="请输入账号" - />, - )} - </Form.Item> - <Form.Item className="login-div-content-form-flex"> - {getFieldDecorator('credential', { - rules: [{ required: true, message: '请输入密码!' }], - initialValue: 'admin' - })( - <Input - style={{ width: '32vh', height: '5vh', margin: '12px' }} - prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />} - type="password" - placeholder="请输入密码" - />, - )} - </Form.Item> - <Form.Item className="login-div-content-form-flex"> - {/* {getFieldDecorator('remember', { + // 获取登录用户的菜单权限 + fetch({ + url: `api/resource/getResource`, + }).then(res => { + console.log('res', res); + if (res) { + window.localStorage.setItem('menu', JSON.stringify(res)); + message.success('登录成功'); + this.props.history.push({ pathname: "/index" }); + } + }) + } + + render() { + const { getFieldDecorator } = this.props.form; + const { btnLoading } = this.state; + return ( + <div className="login-main"> + <div className="login-div"> + <div className="login-div-top"> + <img className="login-div-top-img" src={logo} /> + </div> + <div className="login-div-content"> + <div className="login-div-content-div"> + <div className="login-div-content-div-title">登录OA云平台</div> + <Form onSubmit={this.handleSubmit} className="login-form"> + <Form.Item className="login-div-content-form-flex" > + {getFieldDecorator('account', { + rules: [{ required: true, message: '请输入账号!' }], + })( + <Input + style={{ width: '300px', height: '48px', margin: '12px' }} + prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />} + placeholder="请输入账号" + />, + )} + </Form.Item> + <Form.Item className="login-div-content-form-flex"> + {getFieldDecorator('credential', { + rules: [{ required: true, message: '请输入密码!' }], + initialValue: 'admin' + })( + <Input + style={{ width: '300px', height: '48px', margin: '12px' }} + prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />} + type="password" + placeholder="请输入密码" + />, + )} + </Form.Item> + <Form.Item className="login-div-content-form-flex"> + {/* {getFieldDecorator('remember', { valuePropName: 'checked', initialValue: true, })(<Checkbox>记住</Checkbox>)} <a className="login-form-forgot" href=""> 忘记密码 </a> */} - <Button type="primary" htmlType="submit" className="login-form-button" loading={btnLoading}>登录</Button> - </Form.Item> - </Form> - - </div> - </div> - <div className="login-div-bottom">2011 10215489广州恒巨信息科技有限公司 版权所有 - 粤ICP备10215489号</div> - </div> + <Button type="primary" htmlType="submit" className="login-form-button" loading={btnLoading}>登录</Button> + </Form.Item> + </Form> </div> - ); - } + </div> + <div className="login-div-bottom">2011 10215489广州恒巨信息科技有限公司 版权所有 - 粤ICP备10215489号</div> + </div> + + </div> + ); + } } const WrappedNormalLoginForm = Form.create({ name: 'normal_login' })(NormalLoginForm); -- Gitblit v1.8.0