king
2021-09-24 95ccc1acc6d8ede1c839493e7aecc9c97fd34c8c
src/pc/components/login/normal-login/loginform.jsx
@@ -20,14 +20,23 @@
  state = {
    activeWay: null,
    loginWays: [],
    scanWay: null
  }
  UNSAFE_componentWillMount () {
    const { loginWays, wrap } = this.props
    let _loginWays = []
    let scanWay = null
    loginWays.forEach(item => {
      if (!wrap.loginWays || wrap.loginWays.includes(item.type)) {
        if (item.type === 'sms_vcode') {
          item.label = '短信登录'
        } else if (item.type === 'uname_pwd') {
          item.label = '账号登录'
        } else if (item.type === 'app_scan') {
          scanWay = item
        }
        _loginWays.push(item)
      }
    })
@@ -35,6 +44,7 @@
    this.setState({
      loginWays: _loginWays,
      activeWay: _loginWays[0],
      scanWay
    })
  }
@@ -43,8 +53,16 @@
    if (!is(fromJS(wrap), fromJS(nextProps.wrap))) {
      let _loginWays = []
      let scanWay = null
      nextProps.loginWays.forEach(item => {
        if (!nextProps.wrap.loginWays || nextProps.wrap.loginWays.includes(item.type)) {
          if (item.type === 'sms_vcode') {
            item.label = '短信登录'
          } else if (item.type === 'uname_pwd') {
            item.label = '账号登录'
          } else if (item.type === 'app_scan') {
            scanWay = item
          }
          _loginWays.push(item)
        }
      })
@@ -52,6 +70,7 @@
      this.setState({
        loginWays: _loginWays,
        activeWay: _loginWays[0],
        scanWay
      })
    }
  }
@@ -81,15 +100,12 @@
  }
  render() {
    const { activeWay, loginWays } = this.state
    const { activeWay, loginWays, scanWay } = this.state
    return (
      <Form className="login-edit-form">
        <div className={'login-way-wrap ' + (loginWays.length === 1 ? 'simple' : '')}>
          {loginWays.map(item => (
            <div className={'login-way' + (activeWay.type === item.type ? ' active' : '')} onClick={() => this.onChangeTab(item)} key={item.type}>{item.label}</div>
          ))}
        </div>
        <div className="login-way-title">{activeWay.label}</div>
        {scanWay && activeWay.type !== 'app_scan' ? <div className="scan-icon" onClick={() => this.onChangeTab(scanWay)}><Icon type="qrcode" /></div> : null}
        {activeWay.type === 'uname_pwd' ? <div className={'form-item-wrap ' + (activeWay.shortcut === 'none' ? 'no-short' : '')}>
          <Form.Item>
            <Input
@@ -143,6 +159,12 @@
          </div>
          请使用客户端扫一扫登录
        </div> : null}
        <div className={'login-ways ' + (activeWay.type === 'app_scan' ? 'center' : '')}>
          {loginWays.map(item => {
            if (item.type === 'app_scan' || activeWay.type === item.type) return null
            return (<span key={item.type} onClick={() => this.onChangeTab(item)}>{item.label}</span>)
          })}
        </div>
      </Form>
    )
  }