| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { InputItem, Icon, Checkbox, List, Button, Picker } from 'antd-mobile' |
| | | // import { is, fromJS } from 'immutable' |
| | | import { InputItem, Icon, Checkbox, Button, Picker, Toast } from 'antd-mobile' |
| | | import { createForm } from 'rc-form' |
| | | |
| | | import Api from '@/api' |
| | | import './index.scss' |
| | | |
| | | const CheckboxItem = Checkbox.CheckboxItem |
| | | const CustomChildren = props => ( |
| | | <div onClick={props.onClick} style={{display: 'inline-block', width: '50%', textAlign: 'right'}}> |
| | | <div className="test" style={{ display: 'flex', height: '45px', lineHeight: '45px' }}> |
| | | <div style={{ flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{props.children}</div> |
| | | </div> |
| | | </div> |
| | | ) |
| | | |
| | | class MobLogin extends Component { |
| | | static propTpyes = { |
| | |
| | | {value: 'zh-CN', label: '简体中文'}, |
| | | {value: 'en-US', label: 'English'} |
| | | ], |
| | | lang: 'zh-CN', |
| | | lang: {value: 'zh-CN', label: '简体中文'}, |
| | | rember: true |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | // shouldComponentUpdate (nextProps, nextState) { |
| | | // return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) |
| | | // } |
| | | |
| | | onChange = (e) => { |
| | | const { rember } = this.state |
| | |
| | | } |
| | | |
| | | onChangeLang = (value) => { |
| | | this.setState({ |
| | | lang: value |
| | | const { langs } = this.state |
| | | let lang = null |
| | | |
| | | langs.forEach(cell => { |
| | | if (cell.value === value[0]) { |
| | | lang = cell |
| | | } |
| | | }) |
| | | |
| | | this.setState({ |
| | | lang: lang |
| | | }) |
| | | } |
| | | |
| | | execLogin = () => { |
| | | const { getFieldProps } = this.props.form |
| | | let userName = getFieldProps('userName') |
| | | let password = getFieldProps('password') |
| | | |
| | | if (!userName.value) { |
| | | this.UserName.focus() |
| | | } else if (!password.value) { |
| | | this.Password.focus() |
| | | } else { |
| | | Api.getusermsg(userName.value, password.value).then((res) => { |
| | | if (res.status) { |
| | | sessionStorage.setItem('UserID', res.UserID) |
| | | sessionStorage.setItem('LoginUID', res.LoginUID) |
| | | } else { |
| | | Toast.fail(res.message, 3) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | execEnter = (e) => { |
| | | if (e.nativeEvent.keyCode === 13) { |
| | | this.execLogin() |
| | | } |
| | | } |
| | | |
| | | render () { |
| | |
| | | {...getFieldProps('userName', { |
| | | initialValue: '', |
| | | })} |
| | | disabled={true} |
| | | ref={el => this.UserName = el} |
| | | onKeyPress={this.execEnter} |
| | | > |
| | | <Icon type="check-circle-o" /> |
| | | </InputItem> |
| | |
| | | initialValue: '', |
| | | })} |
| | | type={'password'} |
| | | disabled={true} |
| | | ref={el => this.Password = el} |
| | | onKeyPress={this.execEnter} |
| | | > |
| | | <Icon type="check-circle" /> |
| | | </InputItem> |
| | |
| | | <CheckboxItem checked={rember} onChange={this.onChange}> |
| | | <span onClick={this.onChange}>记住密码</span> |
| | | </CheckboxItem> |
| | | <Picker data={langs} value={lang} cols={1} onChange={this.onChangeLang} className="forss"> |
| | | <List.Item>{lang}</List.Item> |
| | | <Picker data={langs} cols={1} onChange={this.onChangeLang} className="forss"> |
| | | <CustomChildren>{lang.label}</CustomChildren> |
| | | </Picker> |
| | | <div className="clear-both"></div> |
| | | </div> |
| | | <Button |
| | | type="primary" |
| | | className="login" |
| | | onDoubleClick={() => this.props.doubleClickconfig(config.login)} |
| | | style={config.login.style} |
| | | onClick={this.editLogin} |
| | | onClick={this.execLogin} |
| | | > |
| | | {config.login.content} |
| | | </Button> |