import React, { Component } from 'react'; import './index.less'; import { Modal, Icon, Button, Tooltip } from 'antd'; import Assets from '@src/components/Assets'; import { Icon as GIcon } from '../Icon'; import { Button as GButton } from '../Button'; const LOGIN_PHONE = 'LOGIN_PHONE'; const REGISTER_PHONE = 'REGISTER_PHONE'; const LOGIN_WX = 'LOGIN_WX'; const BIND_PHONE = 'BIND_PHONE'; const BIND_WX = 'BIND_WX'; const BIND_WX_ERROR = 'BIND_WX_ERROR'; export default class Login extends Component { constructor(props) { super(props); this.state = { show: false, type: BIND_WX_ERROR }; } render() { const { show, type } = this.state; return ( {this.renderBody(type)} ); } renderBody(type) { switch (type) { case LOGIN_PHONE: return this.renderLoginPhone(); case REGISTER_PHONE: return this.renderRegisterPhone(); case LOGIN_WX: return this.renderLoginWx(); case BIND_PHONE: return this.renderBindPhone(); case BIND_WX: return this.renderBindWx(); case BIND_WX_ERROR: return this.renderBindWxError(); default: return this.LOGIN_PHONE(); } } renderLoginPhone() { return (
手机号登录
); } renderRegisterPhone() { return (
手机号登录
该手机号尚未注册,将自动为您注册账户
); } renderLoginWx() { return (
微信扫码登录
请使用微信扫描二维码登录
); } renderBindPhone() { return (
绑定手机号
微信登录成功!为更好的使用服务,请您绑定手机号和邮箱。
); } renderBindWx() { return (
绑定微信号
手机号注册成功!为更好的使用服务,建议您绑定微信号。
请使用微信扫描二维码登录
跳过
); } renderBindWxError() { return (
绑定失败
该微信账户已绑定其他手机号,您可直接使用微信登入。
Ok
); } } class Input extends Component { render() { const { className = '', onChange, placeholder, error, left, right } = this.props; return (
{left &&
{left}
} onChange && onChange(data)} /> {right &&
{right}
}
); } } class SelectInput extends Component { render() { const { className = '', onChange, placeholder, value, selectValue, onSelect } = this.props; return ( onSelect && onSelect()}> {selectValue} } value={value} placeholder={placeholder} onChange={data => onChange && onChange(data)} /> ); } } class VerificationInput extends Component { constructor(props) { super(props); this.timeKey = null; this.state = { loading: 0 }; } componentWillUnmount() { if (this.timeKey) clearTimeout(this.timeKey); } onSend() { const { onSend, time = 60 } = this.props; if (onSend) { onSend(); } this.setTime(time); } setTime(time) { this.setState({ loading: time }); this.timeKey = setTimeout(() => { this.setTime(time - 1); }, 1000); } render() { const { loading } = this.state; const { className = '', onChange, placeholder, value } = this.props; return ( this.onSend()}> 获取验证码 ) : ( 等待{loading}秒 ) } value={value} placeholder={placeholder} onChange={data => onChange && onChange(data)} /> ); } }