king
2020-12-30 e003a8ee8843aa60b0b7135f413b2b99857acff9
src/components/login/login-1/index.jsx
@@ -1,10 +1,10 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
// import { is, fromJS } from 'immutable'
import { InputItem, Icon, Checkbox, Button, Picker, Toast } from 'antd-mobile'
import { InputItem, Checkbox, Button, Picker, Toast } from 'antd-mobile'
import { createForm } from 'rc-form'
import Api from '@/api'
// import Api from '@/api'
import './index.scss'
const CheckboxItem = Checkbox.CheckboxItem
@@ -27,6 +27,7 @@
      {value: 'en-US', label: 'English'}
    ],
    lang: {value: 'zh-CN', label: '简体中文'},
    loading: false,
    rember: true
  }
@@ -56,6 +57,7 @@
        lang = cell
      }
    })
    Toast.success('切换成功', 3)
    
    this.setState({
      lang: lang
@@ -63,24 +65,33 @@
  }
  execLogin = () => {
    const { getFieldProps } = this.props.form
    let userName = getFieldProps('userName')
    let password = getFieldProps('password')
    const { config } = this.props
    // const { getFieldProps } = this.props.form
    // const { loading } = this.state
    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)
        }
      })
    }
    // if (loading) return
    // let userName = getFieldProps('userName')
    // let password = getFieldProps('password')
    // if (!userName.value) {
    //   this.UserName.focus()
    // } else if (!password.value) {
    //   this.Password.focus()
    // } else {
      // this.setState({loading: true})
      // Api.getusermsg(userName.value, password.value).then((res) => {
      //   if (res.status) {
      //     sessionStorage.setItem('UserID', res.UserID)
      //     sessionStorage.setItem('LoginUID', res.LoginUID)
      //     this.setState({loading: false})
      //   } else {
      //     this.setState({loading: false})
      //     Toast.fail(res.message, 3)
      //   }
      // })
      this.props.history.replace({pathname: `/loading/${config.NextMenuID}`})
    // }
  }
  execEnter = (e) => {
@@ -92,7 +103,7 @@
  render () {
    const { config } = this.props
    const { getFieldProps } = this.props.form
    const { rember, langs, lang } = this.state
    const { rember, langs, lang, loading } = this.state
    return (
      <div className="mob-login-1" style={config.box.style}>
@@ -112,7 +123,7 @@
            ref={el => this.UserName = el}
            onKeyPress={this.execEnter}
          >
            <Icon type="check-circle-o" />
            <i className="minke-user" />
          </InputItem>
          <InputItem
            placeholder="Password"
@@ -124,7 +135,7 @@
            ref={el => this.Password = el}
            onKeyPress={this.execEnter}
          >
            <Icon type="check-circle" />
            <i className="minke-lock" />
          </InputItem>
          <div className="other-setting">
            <CheckboxItem checked={rember} onChange={this.onChange}>
@@ -139,6 +150,7 @@
            type="primary"
            className="login"
            style={config.login.style}
            loading={loading}
            onClick={this.execLogin}
          >
            {config.login.content}