group.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. import React from 'react';
  2. import { Input, Button, Form, Icon, Spin, message } from 'antd';
  3. import './base.less';
  4. import ajax from 'jquery/src/ajax/xhr.js'
  5. import $ from 'jquery/src/ajax';
  6. import ChangePw from './changePassword.jsx';
  7. const FormItem = Form.Item;
  8. import weixin from '../../../../image/weixin-w.png';
  9. import qq from '../../../../image/qq-w.png';
  10. import weibo from '../../../../image/weibo-w.png';
  11. const BaseFrom = Form.create()(React.createClass({
  12. getData() {
  13. this.props.spinState(true);
  14. $.ajax({
  15. method: "get",
  16. dataType: "json",
  17. url: globalConfig.context + "/api/user/base",
  18. success: function (data) {
  19. if (data.data) {
  20. this.setState({
  21. fixedTel: data.data.fixedTel,
  22. firstContacts: data.data.firstContacts,
  23. firstMobile: data.data.firstMobile,
  24. secondContacts: data.data.secondContacts,
  25. secondMobile: data.data.secondMobile,
  26. thirdContacts: data.data.thirdContacts,
  27. thirdMobile: data.data.thirdMobile,
  28. qq: data.data.qq,
  29. address: data.data.postalAddress,
  30. postcode: data.data.postcode,
  31. legalPerson: data.data.legalPerson,
  32. email: data.data.email,
  33. });
  34. };
  35. }.bind(this),
  36. }).done(function (data) {
  37. if (data.error.length) {
  38. message.warning(data.error[0].message);
  39. }
  40. }.bind(this)).always(function () {
  41. this.props.spinState(false);
  42. }.bind(this));
  43. },
  44. getInitialState() {
  45. return {
  46. };
  47. },
  48. componentWillMount() {
  49. this.getData();
  50. },
  51. handleSubmit(e) {
  52. e.preventDefault();
  53. this.props.form.validateFields((err, values) => {
  54. if (!err) {
  55. this.props.spinState(true);
  56. $.ajax({
  57. method: "POST",
  58. dataType: "json",
  59. crossDomain: false,
  60. url: globalConfig.context + "/api/user/orgIdentity",
  61. data: {
  62. "firstContacts": values.firstContacts,
  63. "firstMobile": values.firstMobile,
  64. "secondContacts": values.secondContacts,
  65. "secondMobile": values.secondMobile,
  66. "thirdContacts": values.thirdContacts,
  67. "thirdMobile": values.thirdMobile,
  68. "email": values.email,
  69. "fixedTel": values.telephone,
  70. "qq": values.qq,
  71. "postalAddress": values.address,
  72. "postcode": values.postcode,
  73. "moblie": values.moblie,
  74. "legalPerson": values.legalPerson
  75. }
  76. }).done(function (data) {
  77. if (!data.error.length) {
  78. message.success('保存成功!');
  79. } else {
  80. message.warning(data.error[0].message);
  81. }
  82. }.bind(this)).always(function () {
  83. this.props.spinState(false);
  84. }.bind(this));
  85. }
  86. });
  87. },
  88. checkidNum(rule, value, callback) {
  89. const form = this.props.form;
  90. if (value && value !== form.getFieldValue('password')) {
  91. callback('Two passwords that you enter is inconsistent!');
  92. } else {
  93. callback();
  94. }
  95. },
  96. checkUpload(file) {
  97. const isJPG = file.type === 'image/jpeg';
  98. if (!isJPG) {
  99. callback('You can only upload JPG file!');
  100. }
  101. const isLt2M = file.size / 1024 / 1024 < 2;
  102. if (!isLt2M) {
  103. callback('Image must smaller than 2MB!');
  104. }
  105. return isJPG && isLt2M;
  106. },
  107. checkPhone(rule, value, callback) {
  108. const form = this.props.form;
  109. if (value.length !== 0 && !(/^1[34578]\d{9}$/.test(value))) {
  110. callback('请输入正确的手机号码!');
  111. } else {
  112. callback();
  113. }
  114. },
  115. render() {
  116. const { getFieldDecorator } = this.props.form;
  117. const formItemLayout = {
  118. labelCol: { span: 4 },
  119. wrapperCol: { span: 12 },
  120. };
  121. return (
  122. <Form horizontal onSubmit={this.handleSubmit} className="base-form">
  123. <FormItem
  124. {...formItemLayout}
  125. label='第一联系人'
  126. >
  127. {getFieldDecorator('firstContacts', {
  128. initialValue: this.state.firstContacts,
  129. })(
  130. <Input />
  131. )}
  132. </FormItem>
  133. <FormItem
  134. {...formItemLayout}
  135. label="手机号码"
  136. >
  137. {getFieldDecorator('firstMobile', {
  138. initialValue: this.state.firstMobile,
  139. rules: [
  140. {
  141. validator: this.checkPhone
  142. }],
  143. })(
  144. <Input />
  145. )}
  146. </FormItem>
  147. <FormItem
  148. {...formItemLayout}
  149. label='第二联系人'
  150. >
  151. {getFieldDecorator('secondContacts', {
  152. initialValue: this.state.secondContacts,
  153. })(
  154. <Input />
  155. )}
  156. </FormItem>
  157. <FormItem
  158. {...formItemLayout}
  159. label="手机号码"
  160. >
  161. {getFieldDecorator('secondMobile', {
  162. initialValue: this.state.secondMobile,
  163. rules: [
  164. {
  165. validator: this.checkPhone
  166. }],
  167. })(
  168. <Input />
  169. )}
  170. </FormItem>
  171. <FormItem
  172. {...formItemLayout}
  173. label='第三联系人'
  174. >
  175. {getFieldDecorator('thirdContacts', {
  176. initialValue: this.state.thirdContacts,
  177. })(
  178. <Input />
  179. )}
  180. </FormItem>
  181. <FormItem
  182. {...formItemLayout}
  183. label="手机号码"
  184. >
  185. {getFieldDecorator('thirdMobile', {
  186. initialValue: this.state.thirdMobile,
  187. rules: [
  188. {
  189. validator: this.checkPhone
  190. }],
  191. })(
  192. <Input />
  193. )}
  194. </FormItem>
  195. <FormItem
  196. {...formItemLayout}
  197. label="电子邮箱"
  198. >
  199. {getFieldDecorator('email', {
  200. initialValue: this.state.email,
  201. rules: [{
  202. type: 'email', message: '请输入正确的邮箱地址!',
  203. }],
  204. })(
  205. <Input />
  206. )}
  207. </FormItem>
  208. <FormItem
  209. {...formItemLayout}
  210. label="固定电话"
  211. >
  212. {getFieldDecorator('telephone', {
  213. initialValue: this.state.fixedTel
  214. })(
  215. <Input />
  216. )}
  217. </FormItem>
  218. <FormItem
  219. {...formItemLayout}
  220. label="QQ"
  221. >
  222. {getFieldDecorator('qq', {
  223. initialValue: this.state.qq
  224. })(
  225. <Input />
  226. )}
  227. </FormItem>
  228. <FormItem
  229. {...formItemLayout}
  230. label="通讯地址"
  231. >
  232. {getFieldDecorator('address', {
  233. initialValue: this.state.address
  234. })(
  235. <Input />
  236. )}
  237. </FormItem>
  238. <FormItem wrapperCol={{ span: 12, offset: 4 }}>
  239. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  240. </FormItem>
  241. </Form >
  242. );
  243. },
  244. }));
  245. // <FormItem
  246. // {...formItemLayout}
  247. // label="法人"
  248. // >
  249. // {getFieldDecorator('legalPerson', {
  250. // initialValue: this.state.legalPerson
  251. // })(
  252. // <Input />
  253. // )}
  254. // </FormItem>
  255. const Base = React.createClass({
  256. getInitialState() {
  257. return {
  258. loading: false,
  259. };
  260. },
  261. spinChange(e) {
  262. this.setState({
  263. loading: e
  264. });
  265. },
  266. render() {
  267. return (
  268. <Spin spinning={this.state.loading} className='spin-box'>
  269. <div className="set-base">
  270. <div className="acc-detail">
  271. <p className="acc-title">您登录的账号</p>
  272. <p>阿凡提号: <span>{userData.number}</span></p>
  273. <p>认证状态: <span>{userData.lvl == '1' ? <span>已认证</span> : <span>未认证 <a href={globalConfig.context + '/user/groupCertify'}> 马上认证</a></span>}</span></p>
  274. <div className="clearfix">
  275. <ChangePw />
  276. </div>
  277. </div>
  278. <div className="acc-bind" style={{ 'display': 'none' }}>
  279. <p className="acc-title">绑定账号 <span>绑定后,可使用第三方账号直接登录阿凡提网</span></p>
  280. <p>
  281. <Button className="relateqq"><img src={qq} alt="" /> QQ账号登录</Button>
  282. <Button className="relateweibo"><img src={weibo} alt="" />微博账号登录</Button>
  283. <Button className="relateweixin"><img src={weixin} alt="" />微信账号登录</Button>
  284. </p>
  285. </div>
  286. <div className="acc-info">
  287. <p className="acc-title">请确认您的联系信息</p>
  288. <BaseFrom spinState={this.spinChange} />
  289. </div>
  290. </div>
  291. </Spin>
  292. )
  293. }
  294. });
  295. export default Base;