/* @author:李霆 @update:2018/05/29 @descript:复制粘贴,拿起来就是干!! */ import React from 'react'; import ajax from 'jquery/src/ajax/xhr.js'; import $ from 'jquery/src/ajax'; import { Row, Col, Form, Button, Spin, message, Modal, Input } from 'antd'; import {getStatuslist} from '@/tools.js'; import './account.less'; import SpinContainer from "../../SpinContainer"; const FormItem = Form.Item; class Account extends React.Component { constructor(props) { super(props); this.state = { loading: false, visible: false, editState: false, }; } loadData() { this.setState({ loading: true }); $.ajax({ method: 'get', dataType: 'json', crossDomain: false, url: globalConfig.context + '/api/user/userBase', success: function(data) { if (data.error.length || data.data == '') { if (data.error && data.error.length) { message.warning(data.error[0].message); } } else { this.setState({ uid:data.data.uid, username: data.data.username, //用户注册名 nickname: data.data.nickname, //用户昵称 identifyName: data.data.identifyName, //注册名称 email: data.data.email, mobile:data.data.mobile, //手机号码 headPortraitUrl:data.data.headPortraitUrl, //头像地址 type:data.data.type, //用户类型(0-个人,1-企业) accountData: data.data, status:data.data.status,//用户状态 0-正常,1-注销 ,2-锁定 authentication:data.data.authentication, //实名认证状态 0-未认证,1-个人实名认 createTime:data.data.createTime?new Date(data.data.createTime).toLocaleString():'' }); } }.bind(this) }).always( function() { this.setState({ loading: false }); }.bind(this) ); } //修改密码 passFun() { this.setState({ visible: true, password: '', repeatPass: '' }); } //企业认证 companyFun() {} //个人认证 personFun() {} //修改密码 passSubmit() { if (!this.state.name) { message.warning('请填写昵称!'); return; } if (!this.state.password) { message.warning('请填写新密码!'); return; } if (this.state.password !== this.state.repeatPass) { message.warning('两次输入的密码不一致!'); } this.setState({ loading: true }); $.ajax({ method: 'POST', dataType: 'json', crossDomain: false, url: globalConfig.context + '/api/user/mobile', data: { mobile: this.state.mobile, mobileCode: this.state.mcode, password: this.state.password, name: this.state.name } }).done( function(data) { if (!data.error.length) { this.setState({ visible: false }); message.success('修改成功!'); this.loadData(); } else { message.warning(data.error[0].message); } }.bind(this) ); } handleOk() { this.passSubmit(); } handleCancel() { this.setState({ visible: false }); } //单个修改 btnFun(item) { switch (item) { case 1: this.setState({ editName: true }); setTimeout(()=>{this.refs.name.focus()},10) break; case 2: this.setState({ editPhoto: true }); setTimeout(()=>{this.refs.photo.focus()},10) break; case 3: this.setState({ editEmail: true }); setTimeout(()=>{this.refs.email.focus()},10) break; case 4: this.setState({ editNickname: true }); setTimeout(()=>{this.refs.nickname.focus()},10) break; } this.enterFun(item); } //保存单个修改 saveFun(item) { $.ajax({ method: 'POST', dataType: 'json', crossDomain: false, url: globalConfig.context + '/api/user/updateUserBase', data: { identifyName: this.state.identifyName, mobile: this.state.mobile, email: this.state.email, nickname: this.state.nickname } }).done( function(data) { if (!data.error.length) { this.setState({ visible: false }); message.success('修改成功!'); switch (item) { case 1: this.setState({ editName: false }); break; case 2: this.setState({ editPhoto: false }); break; case 3: this.setState({ editEmail: false }); break; case 4: this.setState({ editNickname: false }); break; } this.loadData(); document.onkeydown={}; } else { message.warning(data.error[0].message); } }.bind(this) ); } //按下键盘回车键时保存 enterFun(item) { if(item){ document.onkeydown=function(e){ //对整个页面文档监听回车键 var keyNum=window.event ? e.keyCode :e.which; if(keyNum==13){ this.saveFun(item); } }.bind(this) } } componentWillMount(){ this.loadData(); } render() { const formItemLayout = { labelCol: { span: 8 }, wrapperCol: { span: 10 } }; const formItemLayoutBtn = { labelCol: { span: 8 }, wrapperCol: { span: 6 } }; const accountData = this.state.account || []; return (
账号管理
{/* {this.state.username} {/* */} {/* {this.state.editName ? ( { this.saveFun(1); }} ref="name" placeholder="请填写注册名称" onChange={(e) => { this.setState({ identifyName: e.target.value }); }} /> ) : ( {this.state.identifyName} )} {this.state.editName ? ( '' ) : ( 实行企业实名认证后,您将享受到技淘网提供的全方位的科技咨询服务 {accountData.account} 实行个人实名认证后,您将享受技淘网提供的全方位的知识产权运营服务 {accountData.account} 实行科技专家认证后,您将成为技淘网的科技服务专家,为其他用户提供科技咨询服务 */}
{this.state.followTime} { this.setState({ name: e.target.value }); }} /> { this.setState({ password: e.target.value }); }} /> { this.setState({ repeatPass: e.target.value }); }} />
); } } export default Account;