bank.jsx 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. import React from 'react';
  2. import { Input, Button, Form, Icon, Spin, message, } from 'antd';
  3. import './certify.less';
  4. import ajax from 'jquery/src/ajax/xhr.js'
  5. import $ from 'jquery/src/ajax';
  6. const Content = Form.create()(React.createClass({
  7. getData() {
  8. this.setState({
  9. loading: true
  10. });
  11. $.ajax({
  12. method: "get",
  13. dataType: "json",
  14. url: globalConfig.context + "/api/user/userPro",
  15. success: function (data) {
  16. if (data.data) {
  17. this.state.username = data.data.username;
  18. } else {
  19. message.warning(data.error[0].message);
  20. };
  21. }.bind(this),
  22. }).always(function () {
  23. this.setState({
  24. loading: false
  25. });
  26. }.bind(this));
  27. },
  28. getInitialState() {
  29. return {
  30. loading: false
  31. };
  32. },
  33. handleSubmit(e) {
  34. e.preventDefault();
  35. this.props.form.validateFields((err, values) => {
  36. if (!err) {
  37. this.setState({
  38. loading: true
  39. });
  40. $.ajax({
  41. method: "POST",
  42. dataType: "json",
  43. crossDomain: false,
  44. url: globalConfig.context + "/api/user/userNextPro",
  45. data: {
  46. bankName: this.state.username,
  47. bankAccount: values.bankAccount,
  48. bankCardNumber: values.bankCardNumber,
  49. process: 2
  50. }
  51. }).done(function (data) {
  52. if (!data.error.length) {
  53. message.success('保存成功!');
  54. this.props.changeStep(3);
  55. } else {
  56. message.warning(data.error[0].message);
  57. }
  58. }.bind(this)).always(function () {
  59. this.setState({
  60. loading: false
  61. });
  62. }.bind(this));
  63. }
  64. });
  65. },
  66. checkBankCardNum(rule, value, callback) {
  67. if (!/(^\d{15,}$)/.test(value)) {
  68. callback('请输入正确的银行卡号!');
  69. } else {
  70. callback();
  71. }
  72. },
  73. getIdCardUrl1(e) {
  74. this.state.idCardUrl1 = e;
  75. },
  76. getIdCardUrl2(e) {
  77. this.state.idCardUrl2 = e;
  78. },
  79. componentDidMount() {
  80. this.getData();
  81. },
  82. changeStep() {
  83. this.props.changeStep(1);
  84. },
  85. render() {
  86. const FormItem = Form.Item;
  87. const { getFieldDecorator } = this.props.form;
  88. const formItemLayout = {
  89. labelCol: { span: 4 },
  90. wrapperCol: { span: 12 },
  91. };
  92. const _me = this;
  93. return (
  94. <Spin spinning={this.state.loading} className="certify-spin">
  95. <Form horizontal onSubmit={this.handleSubmit} className="certify-form">
  96. <FormItem wrapperCol={{ span: 20, offset: 4 }}>
  97. <p className="certify-title">请填写您的银行卡信息,该银行卡仅用于认证您的身份。</p>
  98. </FormItem>
  99. <FormItem
  100. {...formItemLayout}
  101. label="银行开户名"
  102. extra={<span><Icon type="exclamation-circle" /> 必须使用以“{this.state.username}”为开户名的银行卡进行认证</span>}
  103. >
  104. {getFieldDecorator('username')(
  105. <span>{this.state.username}</span>
  106. )}
  107. <a style={{ 'color': '#ea0862' }} onClick={_me.changeStep}>修改</a>
  108. </FormItem>
  109. <FormItem
  110. {...formItemLayout}
  111. label="开户银行"
  112. extra={<span><Icon type="exclamation-circle" /> 不支持信用卡和存折进行认证</span>}
  113. >
  114. {getFieldDecorator('bankAccount', {
  115. initialValue: this.state.bankAccount || null,
  116. rules: [{ required: true, message: '请输入开户银行名称!' }]
  117. })(
  118. <Input placeholder="请输入开户银行名称" />
  119. )}
  120. </FormItem>
  121. <FormItem
  122. {...formItemLayout}
  123. label="银行卡号"
  124. extra={
  125. <span style={{ 'color': '#ea0862' }}>
  126. <Icon type="exclamation-circle" />
  127. 认证系统会给该银行卡打入一笔1元以下的确认金额,您需要通过银行柜台并在
  128. 步骤4输入该银行卡收到的阿凡提打款金额数目
  129. </span>}
  130. >
  131. {getFieldDecorator('bankCardNumber', {
  132. initialValue: this.state.bankCardNumber || null,
  133. rules: [{
  134. validator: this.checkIdcardnum,
  135. }],
  136. })(
  137. <Input placeholder="请输入银行卡号" />
  138. )}
  139. </FormItem>
  140. <FormItem wrapperCol={{ span: 12, offset: 4 }}>
  141. <Button className="set-submit" type="primary" htmlType="submit">下一步</Button>
  142. </FormItem>
  143. </Form >
  144. </Spin >
  145. );
  146. },
  147. }));
  148. export default Content;