group.jsx 11 KB

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