adminLogin.jsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3. import { Input, Button, Checkbox, message, Spin, Icon } from 'antd';
  4. import './adminLogin.less';
  5. import ajax from 'jquery/src/ajax/xhr.js'
  6. import $ from 'jquery/src/ajax';
  7. var Login = React.createClass({
  8. getInitialState() {
  9. return {
  10. user: '',
  11. password: '',
  12. checked: '',
  13. loading: false
  14. };
  15. },
  16. handleSubmit() {
  17. if (this.state.user === "" || this.state.password === "") {
  18. message.warning('账号或者密码不能为空!');
  19. } else {
  20. this.setState({
  21. loading: true
  22. });
  23. // debugger
  24. $.ajax({
  25. method: "POST",
  26. dataType: "json",
  27. crossDomain: false,
  28. url: globalConfig.context + "/managesignin",
  29. data: {
  30. mobile: this.state.user,
  31. password: this.state.password,
  32. remeber: false
  33. }
  34. }).done(function (data) {
  35. if (!data.error.length) {
  36. localStorage.setItem("userId", data.data.id)
  37. window.location.href = globalConfig.context + "/RD/admin/index.html";
  38. } else {
  39. message.warning(data.error[0].message);
  40. }
  41. }.bind(this)).always(function () {
  42. this.setState({
  43. loading: false
  44. });
  45. }.bind(this));
  46. };
  47. },
  48. keyboard(event) {
  49. if (event.keyCode == 13) {
  50. this.handleSubmit()
  51. }
  52. },
  53. getUser(event) {
  54. this.setState({ user: event.target.value });
  55. },
  56. getPassword(event) {
  57. this.setState({ password: event.target.value });
  58. },
  59. onChange(event) {
  60. this.setState({ checked: event.target.checked });
  61. },
  62. render() {
  63. return (
  64. <div className='content'>
  65. {/* 旋转动画 */}
  66. <div className="ui_base u_p3d">
  67. <div className="ball_c"></div>
  68. <div className="base u_p3d">
  69. <div className="pan"></div>
  70. <div className="ball_base u_p3d ball_1">
  71. <div className="ball"></div>
  72. </div>
  73. <div className="ball_base u_p3d ball_2">
  74. <div className="ball"></div>
  75. </div>
  76. <div className="ball_base u_p3d ball_3">
  77. <div className="ball"></div>
  78. </div>
  79. <div className="ball_base u_p3d ball_4">
  80. <div className="ball"></div>
  81. </div>
  82. <div className="ball_base u_p3d ball_5">
  83. <div className="ball"></div>
  84. </div>
  85. <div className="ball_base u_p3d ball_6">
  86. <div className="ball"></div>
  87. </div>
  88. </div>
  89. </div>
  90. <div className="login-box">
  91. <Spin spinning={this.state.loading} className='spin-box'>
  92. <div className="user-box">
  93. <Input onChange={this.getUser}
  94. autocomplete="off"
  95. onKeyDown={this.keyboard} placeholder="账号" value={this.state.user}
  96. // prefix={<Icon width={"18px"} type="user" />}
  97. />
  98. </div>
  99. <div className="pw-box">
  100. <Input onChange={this.getPassword}
  101. autocomplete="off"
  102. onKeyDown={this.keyboard} type="password" placeholder="密码" value={this.state.password}
  103. // prefix={<Icon width={"18px"} type="lock" />}
  104. />
  105. </div>
  106. <Button onClick={this.handleSubmit}>登录</Button>
  107. </Spin>
  108. </div>
  109. <div id="title">科技厚生 正德卓行</div>
  110. </div>
  111. );
  112. }
  113. });
  114. export default Login;