account.jsx 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import React from 'react';
  2. import {Form,Button,Spin,message,Input,Select,Radio} from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. const FormItem =Form.Item;
  6. import {statuslist,lvl,currentMember} from '@/dataDic.js';
  7. import {getcustomerTyp,getCustomerSource,getStatuslist} from '@/tools.js';
  8. const Account =React.createClass({
  9. httpAccount(record) {
  10. this.RowClick;
  11. $.ajax({
  12. method: "get",
  13. dataType: "json",
  14. crossDomain: false,
  15. url: globalConfig.context + '/api/admin/customer/findUserAccountDetail',
  16. data: {
  17. uid: record
  18. },
  19. success: function(data) {
  20. let thisData = data.data;
  21. if(!thisData) {
  22. if(data.error && data.error.length) {
  23. message.warning(data.error[0].message);
  24. };
  25. thisData = {};
  26. };
  27. this.setState({
  28. Accountuid: thisData.id,
  29. mobile: thisData.mobile,
  30. nickname: thisData.nickname,
  31. email: thisData.email,
  32. type: getcustomerTyp(String(thisData.type)),
  33. source: thisData.source,
  34. isMember: thisData.isMember,
  35. currentMemberStatus: String(thisData.currentMemberStatus),
  36. lvl: String(thisData.lvl),
  37. status: String(thisData.status),
  38. createTimes: thisData.createTimes,
  39. });
  40. }.bind(this),
  41. }).always(function() {
  42. this.setState({
  43. loading: false
  44. });
  45. }.bind(this));
  46. },
  47. getInitialState(){
  48. return{
  49. loading:false
  50. }
  51. },
  52. //账户信息保存
  53. accountSave(e) {
  54. e.preventDefault();
  55. if(!this.state.mobile) {
  56. message.warning('手机号码不能为空!')
  57. return false;
  58. }
  59. this.setState({
  60. loading: true
  61. });
  62. $.ajax({
  63. method: "post",
  64. dataType: "json",
  65. url: globalConfig.context + '/api/admin/customer/updateUserAccount',
  66. data: {
  67. id: this.state.Accountuid,
  68. mobile: this.state.mobile,
  69. nickname: this.state.nickname,
  70. email: this.state.email,
  71. isMember: this.state.isMember,
  72. currentMemberStatus: this.state.currentMemberStatus,
  73. lvl: this.state.lvl,
  74. status: this.state.status,
  75. }
  76. }).done(function(data) {
  77. this.setState({
  78. loading: false
  79. });
  80. if(!data.error.length) {
  81. message.success('保存成功!');
  82. this.props.closeDetail(false,true)
  83. } else {
  84. message.warning(data.error[0].message);
  85. }
  86. }.bind(this));
  87. },
  88. componentWillMount(){
  89. this.httpAccount(this.props.data.id);
  90. },
  91. detailsModal(){
  92. this.props.closeDetail(false, false)
  93. },
  94. componentWillReceiveProps(nextProps) {
  95. if(nextProps.data.id&&nextProps.accountState){
  96. this.httpAccount(nextProps.data.id)
  97. }
  98. },
  99. render(){
  100. const formItemLayout = {
  101. labelCol: { span: 8 },
  102. wrapperCol: { span: 14 },
  103. };
  104. return(
  105. <div className="clearfix">
  106. <Form layout="horizontal" id="demand-form" onSubmit={this.accountSave} >
  107. <Spin spinning={this.state.loading} >
  108. <FormItem className="half-item"
  109. {...formItemLayout}
  110. label="注册手机号" >
  111. <span>{this.state.mobile}</span>
  112. </FormItem>
  113. <FormItem className="half-item"
  114. {...formItemLayout}
  115. label="注册用户名" >
  116. <span>{this.state.nickname}</span>
  117. </FormItem>
  118. <FormItem className="half-item"
  119. {...formItemLayout}
  120. label="注册邮箱" >
  121. <span>{this.state.email}</span>
  122. </FormItem>
  123. <div className="clearfix">
  124. <FormItem className="half-item"
  125. {...formItemLayout}
  126. label="客户来源" >
  127. <span>{getCustomerSource(this.state.source)}</span>
  128. </FormItem>
  129. <FormItem className="half-item"
  130. {...formItemLayout}
  131. label="客户类型" >
  132. <span>{this.state.type}</span>
  133. </FormItem>
  134. <FormItem className="half-item"
  135. {...formItemLayout}
  136. label="创建时间" >
  137. <span>{this.state.createTimes}</span>
  138. </FormItem>
  139. <FormItem className="half-item"
  140. {...formItemLayout}
  141. label="账户状态"
  142. >
  143. <span>{getStatuslist(this.state.status)}</span>
  144. </FormItem>
  145. </div>
  146. </Spin>
  147. </Form>
  148. </div>
  149. )
  150. }
  151. })
  152. export default Account;