|
|
@ -1,11 +1,12 @@ |
|
|
|
import React from "react"; |
|
|
|
import React from "react"; |
|
|
|
import {Col, Container, Image, Row} from "react-bootstrap"; |
|
|
|
import {Button, Col, Container, Form, FormControl, Image, Row} from "react-bootstrap"; |
|
|
|
import {User} from "../entity"; |
|
|
|
import {UserEdit} from "../entity"; |
|
|
|
|
|
|
|
import {Input} from "../bootstrap/InputGroup"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 个人信息 |
|
|
|
* 个人信息 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
export class MyInfo extends React.Component<any, User>{ |
|
|
|
export class MyInfo extends React.Component<any, UserEdit>{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(props: Readonly<any>) { |
|
|
|
constructor(props: Readonly<any>) { |
|
|
@ -17,9 +18,9 @@ export class MyInfo extends React.Component<any, User>{ |
|
|
|
//用户姓名
|
|
|
|
//用户姓名
|
|
|
|
name:"", |
|
|
|
name:"", |
|
|
|
//用户年龄
|
|
|
|
//用户年龄
|
|
|
|
age:NaN, |
|
|
|
age:0, |
|
|
|
//用户电话
|
|
|
|
//用户电话
|
|
|
|
mobile:NaN, |
|
|
|
mobile:0, |
|
|
|
//用户邮箱
|
|
|
|
//用户邮箱
|
|
|
|
email:"", |
|
|
|
email:"", |
|
|
|
//地点
|
|
|
|
//地点
|
|
|
@ -27,7 +28,12 @@ export class MyInfo extends React.Component<any, User>{ |
|
|
|
//个人简介
|
|
|
|
//个人简介
|
|
|
|
info:"", |
|
|
|
info:"", |
|
|
|
//头像
|
|
|
|
//头像
|
|
|
|
headImg:"" |
|
|
|
headImg:"", |
|
|
|
|
|
|
|
contentEditable:false, |
|
|
|
|
|
|
|
modifyPassword:false, |
|
|
|
|
|
|
|
oldPassword:"", |
|
|
|
|
|
|
|
newPassword:"", |
|
|
|
|
|
|
|
confirmNewPwd:"" |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -51,6 +57,46 @@ export class MyInfo extends React.Component<any, User>{ |
|
|
|
this.loadInfo() |
|
|
|
this.loadInfo() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 进入编辑模式 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
openEdit(){ |
|
|
|
|
|
|
|
this.setState({ |
|
|
|
|
|
|
|
contentEditable:true |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 进入修改密码 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
openModifyPwd(){ |
|
|
|
|
|
|
|
this.setState({ |
|
|
|
|
|
|
|
modifyPassword:true |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 修改密码 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
modifyPwd(){ |
|
|
|
|
|
|
|
this.setState({ |
|
|
|
|
|
|
|
modifyPassword:false |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 保存信息 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
doSave(){ |
|
|
|
|
|
|
|
this.setState({ |
|
|
|
|
|
|
|
contentEditable:false |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.debug(this.state) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
render() { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<Container> |
|
|
|
<Container> |
|
|
@ -61,18 +107,67 @@ export class MyInfo extends React.Component<any, User>{ |
|
|
|
</Row> |
|
|
|
</Row> |
|
|
|
<Row> |
|
|
|
<Row> |
|
|
|
<Col className="border-info border p-3 text-center">{this.state.userId}</Col> |
|
|
|
<Col className="border-info border p-3 text-center">{this.state.userId}</Col> |
|
|
|
<Col className="border-info border p-3 text-center">{this.state.name}</Col> |
|
|
|
<Col className="border-info border p-3 text-center"> |
|
|
|
<Col className="border-info border p-3 text-center">{this.state.age}</Col> |
|
|
|
{this.state.contentEditable? |
|
|
|
|
|
|
|
<FormControl value={this.state.name} onChange={(e)=>this.setState({name:e.target.value})}/> |
|
|
|
|
|
|
|
:this.state.name}</Col> |
|
|
|
|
|
|
|
<Col className="border-info border p-3 text-center"> |
|
|
|
|
|
|
|
{this.state.contentEditable? |
|
|
|
|
|
|
|
<FormControl value={this.state.age} type={"number"} onChange={(e)=>this.setState({age:+e.target.value})}/> |
|
|
|
|
|
|
|
:this.state.age}</Col> |
|
|
|
|
|
|
|
</Row> |
|
|
|
|
|
|
|
<Row> |
|
|
|
|
|
|
|
<Col className="border-info border p-3 text-center"> |
|
|
|
|
|
|
|
{this.state.contentEditable? |
|
|
|
|
|
|
|
<FormControl value={this.state.mobile} type={"number"} onChange={(e)=>this.setState({mobile:+e.target.value})}/> |
|
|
|
|
|
|
|
:this.state.mobile} |
|
|
|
|
|
|
|
</Col> |
|
|
|
|
|
|
|
<Col className="border-info border p-3 text-center"> |
|
|
|
|
|
|
|
{this.state.contentEditable? |
|
|
|
|
|
|
|
<FormControl value={this.state.email} onChange={(e)=>this.setState({email:e.target.value})}/> |
|
|
|
|
|
|
|
:this.state.email} |
|
|
|
|
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
</Row> |
|
|
|
<Row> |
|
|
|
<Row> |
|
|
|
<Col className="border-info border p-3 text-center">{this.state.mobile}</Col> |
|
|
|
<Col className="border-info border p-3 text-center"> |
|
|
|
<Col className="border-info border p-3 text-center">{this.state.email}</Col> |
|
|
|
{this.state.contentEditable? |
|
|
|
|
|
|
|
<FormControl value={this.state.address} onChange={(e)=>this.setState({address:e.target.value})}/> |
|
|
|
|
|
|
|
:this.state.address} |
|
|
|
|
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
</Row> |
|
|
|
<Row> |
|
|
|
<Row> |
|
|
|
<Col className="border-info border p-3 text-center">{this.state.address}</Col> |
|
|
|
<Col className="border-info border p-3 text-center my-info-desc"> |
|
|
|
|
|
|
|
{this.state.contentEditable? |
|
|
|
|
|
|
|
<FormControl value={this.state.info} as={"textarea"} onChange={(e)=>this.setState({info:e.target.value})}/> |
|
|
|
|
|
|
|
:this.state.info} |
|
|
|
|
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
</Row> |
|
|
|
|
|
|
|
{this.state.modifyPassword? |
|
|
|
<Row> |
|
|
|
<Row> |
|
|
|
<Col className="border-info border p-3 text-center my-info-desc">{this.state.info}</Col> |
|
|
|
<Col> |
|
|
|
|
|
|
|
<Form> |
|
|
|
|
|
|
|
<Input name="oldPassword" type={"password"} desc="旧密码" onChange={(value:string)=>this.setState({oldPassword:value})}/> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Input name="newPassword" type={"password"} desc="新密码" onChange={(value:string)=>this.setState({newPassword:value})}/> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Input name="confirmNewPwd" type={"password"} placeholder="请确认新密码" desc="新密码" onChange={(value:string)=>this.setState({confirmNewPwd:value})}/> |
|
|
|
|
|
|
|
</Form> |
|
|
|
|
|
|
|
</Col> |
|
|
|
|
|
|
|
</Row> |
|
|
|
|
|
|
|
:null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Row className="p-3"> |
|
|
|
|
|
|
|
<Col className="text-center"> |
|
|
|
|
|
|
|
{this.state.contentEditable? |
|
|
|
|
|
|
|
<Button variant={"primary"} onClick={()=>this.doSave()}>保存信息</Button>: |
|
|
|
|
|
|
|
<Button variant={"info"} onClick={()=>this.openEdit()} disabled={this.state.modifyPassword}>编辑信息</Button>} |
|
|
|
|
|
|
|
</Col> |
|
|
|
|
|
|
|
<Col className="text-center"> |
|
|
|
|
|
|
|
{this.state.modifyPassword? |
|
|
|
|
|
|
|
<Button variant={"light"} onClick={()=>this.modifyPwd()}>确认</Button>: |
|
|
|
|
|
|
|
<Button variant={"light"} onClick={()=>this.openModifyPwd()} disabled={this.state.contentEditable}>修改密码</Button>} |
|
|
|
|
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
</Row> |
|
|
|
</Container> |
|
|
|
</Container> |
|
|
|
) |
|
|
|
) |
|
|
|