group.jsx 8.2 KB

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