group.jsx 8.7 KB

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