personal.jsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. import React from 'react';
  2. import { Input, Button, Form, Upload, Icon, Spin, message, Row, Col } from 'antd';
  3. import './certify.less';
  4. import { addressInit, getBase64, beforeUpload, beforeUploadFile } from '../tools.js';
  5. import ajax from 'jquery/src/ajax/xhr.js'
  6. import $ from 'jquery/src/ajax';
  7. import card1 from '../../../image/idcard1.jpg';
  8. import card2 from '../../../image/idcard2.jpg';
  9. class Avatar extends React.Component {
  10. constructor(props) {
  11. super(props);
  12. this.state = {
  13. imageUrl: ''
  14. }
  15. }
  16. handleChange(info) {
  17. if (info.file.status === 'done') {
  18. // Get this url from response in real world.
  19. getBase64(info.file.originFileObj, imageUrl => this.setState({ imageUrl }));
  20. this.props.urlData(info.file.response.data);
  21. }
  22. }
  23. render() {
  24. const imageUrl = this.state.imageUrl;
  25. return (
  26. <Upload
  27. className="avatar-uploader"
  28. name={this.props.name}
  29. showUploadList={false}
  30. action={globalConfig.context + "/api/user/identity/upload"}
  31. data={{ 'sign': this.props.name }}
  32. beforeUpload={beforeUpload}
  33. onChange={this.handleChange.bind(this)}
  34. >
  35. {
  36. imageUrl ?
  37. <img src={imageUrl} role="presentation" id={this.props.name} /> :
  38. <Icon type="plus" className="avatar-uploader-trigger" />
  39. }
  40. </Upload>
  41. );
  42. }
  43. };
  44. class UploadFile extends React.Component {
  45. constructor(props) {
  46. super(props);
  47. }
  48. handleChange(info) {
  49. if (info.file.status === 'done') {
  50. this.props.urlData(info.file.response.data);
  51. }
  52. }
  53. render() {
  54. return (
  55. <Upload
  56. name={this.props.name}
  57. action={globalConfig.context + "/api/user/identity/upload"}
  58. data={{ 'sign': this.props.name }}
  59. beforeUpload={beforeUploadFile}
  60. onChange={this.handleChange.bind(this)}
  61. >
  62. <Button><Icon type="upload" />上传</Button>
  63. </Upload>
  64. );
  65. }
  66. };
  67. const Content = Form.create()(React.createClass({
  68. getData() {
  69. this.setState({
  70. loading: true
  71. });
  72. $.ajax({
  73. method: "get",
  74. dataType: "json",
  75. url: globalConfig.context + "/api/user/orgProcess",
  76. success: function (data) {
  77. if (data.data) {
  78. addressInit('cmbProvince', 'cmbCity', 'cmbArea',
  79. data.data.licenceProvince, data.data.licenceCity, data.data.licenceArea);
  80. this.setState({
  81. contacts:data.data.contacts,
  82. contactMobile: data.data.contactMobile,
  83. aftUsername: data.data.aftUsername,
  84. unitName: data.data.unitName,
  85. registeredCapital: data.data.registeredCapital,
  86. licenceNumber: data.data.licenceNumber,
  87. orgCode: data.data.orgCode,
  88. legalPerson: data.data.legalPerson,
  89. legalPersonIdCard: data.data.legalPersonIdCard,
  90. licenceScanningUrl: data.data.licenceScanningUrl,
  91. orgCodeUrl: data.data.orgCodeUrl,
  92. lastYearTaxReportUrl: data.data.lastYearTaxReportUrl
  93. });
  94. } else {
  95. message.warning(data.error[0].message);
  96. };
  97. }.bind(this),
  98. }).always(function () {
  99. this.setState({
  100. loading: false
  101. });
  102. }.bind(this));
  103. },
  104. getInitialState() {
  105. return {
  106. loading: false,
  107. vsCodeSrc : globalConfig.context + '/open/getVCode'
  108. };
  109. },
  110. handleSubmit(e) {
  111. e.preventDefault();
  112. this.props.form.validateFields((err, values) => {
  113. //地址值
  114. let cmbP = document.getElementById('cmbProvince').value;
  115. let cmbC = document.getElementById('cmbCity').value;
  116. let cmbA = document.getElementById('cmbArea').value;
  117. if (!cmbP || !cmbC || !cmbA) {
  118. message.warning("请选择所在地!");
  119. return;
  120. };
  121. if (!this.state.licenceScanningUrl) {
  122. message.warning("请上传营业执照副本!");
  123. return;
  124. };
  125. if (!this.state.orgCodeUrl) {
  126. message.warning("请上传组织机构代码证!");
  127. return;
  128. };
  129. if (!this.state.lastYearTaxReportUrl) {
  130. message.warning("请上传上年度纳税报表!");
  131. return;
  132. };
  133. if (!err) {
  134. this.setState({
  135. loading: true
  136. });
  137. $.ajax({
  138. method: "POST",
  139. dataType: "json",
  140. crossDomain: false,
  141. url: globalConfig.context + "/api/user/orgNextPro",
  142. data: {
  143. contacts: values.contacts,
  144. contactMobile: values.contactMobile,
  145. aftUsername: values.aft,
  146. unitName: values.unitName,
  147. registeredCapital: values.registeredCapital,
  148. licenceNumber: values.licenceNumber,
  149. licenceProvince: cmbP,
  150. licenceCity: cmbC,
  151. licenceArea: cmbA,
  152. licenceScanningUrl: this.state.licenceScanningUrl,
  153. orgCode: values.orgCode,
  154. orgCodeUrl: this.state.orgCodeUrl,
  155. lastYearTaxReportUrl: this.state.lastYearTaxReportUrl,
  156. legalPerson: values.legalPerson,
  157. legalPersonIdCard: values.legalPersonIdCard,
  158. verificationCode: values.captcha,
  159. process: 1
  160. }
  161. }).done(function (data) {
  162. if (!data.error.length) {
  163. message.success('保存成功!');
  164. this.props.changeStep(2);
  165. } else {
  166. message.warning(data.error[0].message);
  167. this.reloadVCode();
  168. this.setState({
  169. loading: false
  170. });
  171. }
  172. }.bind(this));
  173. }
  174. });
  175. },
  176. checkIdcardnum(rule, value, callback) {
  177. if (!/(^\d{15}$)|(^\d{17}(\d|X)$)/.test(value)) {
  178. callback('请输入正确的身份证号!');
  179. } else {
  180. callback();
  181. }
  182. },
  183. checkPhone(rule, value, callback) {
  184. const form = this.props.form;
  185. const _me = this;
  186. if (!(/^1[34578]\d{9}$/.test(value))) {
  187. callback('请输入正确的手机号码!');
  188. _me.setState({
  189. getCodeButton: true
  190. });
  191. } else {
  192. callback();
  193. _me.setState({
  194. getCodeButton: false
  195. });
  196. }
  197. },
  198. checkNumber(rule, value, callback) {
  199. if (!/(^\d{15}$)/.test(value)) {
  200. callback('请输入正确的营业执照注册号!');
  201. } else {
  202. callback();
  203. }
  204. },
  205. getLicenceScanningUrl(e) {
  206. this.state.licenceScanningUrl = e;
  207. },
  208. getOrgCodeUrl(e) {
  209. this.state.orgCodeUrl = e;
  210. },
  211. getLastYearTaxReportUrl(e) {
  212. this.state.lastYearTaxReportUrl = e;
  213. },
  214. componentDidMount() {
  215. addressInit('cmbProvince', 'cmbCity', 'cmbArea');
  216. this.getData();
  217. },
  218. reloadVCode() {
  219. this.setState({
  220. vsCodeSrc:globalConfig.context + '/open/getVCode?t=' + Math.random()
  221. });
  222. },
  223. render() {
  224. const FormItem = Form.Item;
  225. const { getFieldDecorator } = this.props.form;
  226. const formItemLayout = {
  227. labelCol: { span: 6 },
  228. wrapperCol: { span: 12 },
  229. };
  230. const _me = this;
  231. return (
  232. <Spin spinning={this.state.loading} className="certify-spin">
  233. <Form horizontal onSubmit={this.handleSubmit} className="certify-form">
  234. <FormItem
  235. {...formItemLayout}
  236. label="用户名"
  237. extra={<span><Icon type="exclamation-circle" /> 建议字母、数字和符号两种以上组合,6-20个字符</span>}
  238. >
  239. {getFieldDecorator('aftUsername', {
  240. initialValue: this.state.aftUsername || null,
  241. rules: [{ required: true, message: '请输入用户名!' }]
  242. })(
  243. <Input />
  244. )}
  245. </FormItem>
  246. <FormItem
  247. {...formItemLayout}
  248. label="企业名称"
  249. >
  250. {getFieldDecorator('unitName', {
  251. initialValue: this.state.unitName || null,
  252. rules: [{ required: true, message: '请输入企业名称!' }]
  253. })(
  254. <Input placeholder="请输入企业名称" />
  255. )}
  256. </FormItem>
  257. <FormItem
  258. {...formItemLayout}
  259. label="注册资金"
  260. > {getFieldDecorator('registeredCapital', {
  261. initialValue: this.state.registeredCapital || null
  262. })(
  263. <Input />
  264. )}
  265. <span className="fromItem-postfix">万元</span>
  266. </FormItem>
  267. <FormItem
  268. {...formItemLayout}
  269. label="联系人"
  270. >
  271. {getFieldDecorator('contacts', {
  272. initialValue: this.state.contacts || null,
  273. rules: [{ required: true, message: '请输入联系人姓名!' }]
  274. })(
  275. <Input />
  276. )}
  277. </FormItem>
  278. <FormItem
  279. {...formItemLayout}
  280. label="联系方式"
  281. extra={<span><Icon type="exclamation-circle" /> 请填写联系人手机号码,我们会将重要进度以短信形式通知您</span>}
  282. >
  283. {getFieldDecorator('contactMobile', {
  284. initialValue: this.state.contactMobile || null,
  285. rules: [{ validator: this.checkPhone }]
  286. })(
  287. <Input placeholder="建议使用常用手机" />
  288. )}
  289. </FormItem>
  290. <FormItem
  291. {...formItemLayout}
  292. label="法人姓名"
  293. >
  294. {getFieldDecorator('legalPerson', {
  295. initialValue: this.state.legalPerson || null,
  296. rules: [{ required: true, message: '请输入联系人姓名!' }]
  297. })(
  298. <Input />
  299. )}
  300. </FormItem>
  301. <FormItem
  302. {...formItemLayout}
  303. label="身份证号"
  304. >
  305. {getFieldDecorator('legalPersonIdCard', {
  306. rules: [{
  307. validator: this.checkIdcardnum,
  308. }],
  309. initialValue: this.state.legalPersonIdCard || null
  310. })(
  311. <Input placeholder="请输入真实有效的身份证号码" />
  312. )}
  313. </FormItem>
  314. <FormItem
  315. {...formItemLayout}
  316. label="营业执照注册号"
  317. >
  318. {getFieldDecorator('licenceNumber', {
  319. initialValue: this.state.licenceNumber || null,
  320. rules: [{
  321. validator: this.checkNumber,
  322. }],
  323. })(
  324. <Input />
  325. )}
  326. </FormItem>
  327. <FormItem
  328. labelCol={{ span: 6 }}
  329. wrapperCol={{ span: 18 }}
  330. label="营业执照所在地"
  331. >
  332. {getFieldDecorator('address')(
  333. <div>
  334. <select id="cmbProvince" name="cmbProvince"></select>
  335. <select id="cmbCity" name="cmbCity"></select>
  336. <select id="cmbArea" name="cmbArea"></select>
  337. </div>
  338. )}
  339. </FormItem>
  340. <FormItem
  341. labelCol={{ span: 6 }}
  342. wrapperCol={{ span: 18 }}
  343. label="营业执照副本扫描件"
  344. >
  345. {getFieldDecorator('licenceScanningUrl')(
  346. <Avatar name="licenceScanningUrl" urlData={this.getLicenceScanningUrl} />
  347. )}
  348. </FormItem>
  349. <FormItem wrapperCol={{ span: 21, offset: 6 }}>
  350. <p>1.企业营业执照副本复印件加盖企业公章后,扫描或拍照上传,图片大小不超过2M以内,仅支持jpg格式。</p>
  351. <p>2.若已办理三证合一,请输入统一社会信用代码并上传营业执照副本复印件(加盖企业公章)。</p>
  352. </FormItem>
  353. <FormItem
  354. {...formItemLayout}
  355. label="组织机构代码证号码"
  356. extra={<span><Icon type="exclamation-circle" /> 如机构已五证合一,社会统一注册号的第九位至倒数第二位,即为您单位的组织机构代码证号码。</span>}
  357. >
  358. {getFieldDecorator('orgCode', {
  359. initialValue: this.state.orgCode || null,
  360. rules: [{ required: true, message: '请输入组织机构代码证号码!' }]
  361. })(
  362. <Input />
  363. )}
  364. </FormItem>
  365. <FormItem
  366. labelCol={{ span: 6 }}
  367. wrapperCol={{ span: 18 }}
  368. label="组织机构代码证扫描件"
  369. >
  370. {getFieldDecorator('orgCodeUrl')(
  371. <Avatar name="orgCodeUrl" urlData={this.getOrgCodeUrl} />
  372. )}
  373. </FormItem>
  374. <FormItem wrapperCol={{ span: 21, offset: 6 }}>
  375. <p>1.组织机构代码证副本复印件加盖企业公章后,扫描或拍照上传,图片大小不超过2M以内,仅支持jpg格式。</p>
  376. <p>2.若已办理三证合一,请输入统一社会信用代码并上传营业执照副本复印件(加盖企业公章)。</p>
  377. </FormItem>
  378. <FormItem
  379. labelCol={{ span: 6 }}
  380. wrapperCol={{ span: 18 }}
  381. label="上年度纳税报表"
  382. >
  383. {getFieldDecorator('lastYearTaxReportUrl')(
  384. <UploadFile name="lastYearTaxReportUrl" urlData={this.getLastYearTaxReportUrl} />
  385. )}
  386. </FormItem>
  387. <FormItem
  388. {...formItemLayout}
  389. label="验证码"
  390. extra={<span style={{ 'color': '#ea0862' }}><Icon type="exclamation-circle" /> 看不清?点击图片更换验证码</span>}
  391. >
  392. <Row gutter={8}>
  393. <Col span={16}>
  394. {getFieldDecorator('captcha', {
  395. rules: [{ required: true, message: '请输入图片中的验证码' }],
  396. })(
  397. <Input />
  398. )}
  399. </Col>
  400. <Col span={8}>
  401. <div className="getVcode">
  402. <img id="VCode" src={this.state.vsCodeSrc} alt="" onClick={this.reloadVCode} />
  403. </div>
  404. </Col>
  405. </Row>
  406. </FormItem>
  407. <FormItem wrapperCol={{ span: 12, offset: 6 }}>
  408. <Button className="set-submit" type="primary" htmlType="submit">下一步</Button>
  409. <Button className="exit" type="ghost">退出实名认证</Button>
  410. </FormItem>
  411. </Form >
  412. </Spin >
  413. );
  414. },
  415. }));
  416. export default Content;