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'; import { User } from '../../stores/user'; 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 = { type: LOGIN_WX }; window.addEventListener( 'message', event => { if (typeof event.data === 'string' && event.data.indexOf('code:') === 0) { const code = event.data.split(':')[1]; console.log(code); } }, false, ); } close() { User.closeLogin(); } render() { const { type } = this.state; const { user } = this.props; return ( {this.renderBody(type)} this.close()} /> ); } 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 (
微信扫码登录