Login.jsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import React, { Component } from 'react'
  2. import { Modal, Input, notification } from 'antd'
  3. import styles from './Login.less'
  4. import { getUserByUserNoOrNiceNo } from '@/services/common'
  5. class Login extends Component {
  6. constructor (props) {
  7. super(props)
  8. this.state = {
  9. userNo: ''
  10. }
  11. }
  12. onLogin = async (e) => {
  13. e.preventDefault()
  14. const { userNo } = this.state
  15. if (!userNo) {
  16. notification.error({
  17. message: '请输入您的ID或靓号'
  18. })
  19. return
  20. }
  21. const { code, data } = await getUserByUserNoOrNiceNo({ params: userNo })
  22. if (code === 'OK' && data) {
  23. const { onOk } = this.props
  24. onOk && onOk(data)
  25. } else {
  26. notification.error({ message: '用户不存在' })
  27. }
  28. }
  29. onUserNoChange = (e) => {
  30. const { value } = e.target
  31. this.setState({ userNo: value })
  32. }
  33. render () {
  34. const { userNo } = this.state
  35. return (
  36. <Modal
  37. {...this.props}
  38. footer={null}
  39. width={700}
  40. title='登录'
  41. >
  42. <div>
  43. <h3 className={styles['modal-title']}>请登录您的账号</h3>
  44. <p className={styles['input-title']}>请输入您的ID或靓号</p>
  45. <div className={styles['input-wrap']}>
  46. <Input
  47. placeholder='请输入您的ID或靓号'
  48. value={userNo}
  49. onChange={this.onUserNoChange}
  50. />
  51. </div>
  52. <div className={styles['recharge-btn-wrap']}>
  53. <a href="#" onClick={this.onLogin} className={styles['recharge-btn']}>登录</a>
  54. </div>
  55. </div>
  56. </Modal>
  57. )
  58. }
  59. }
  60. export default Login