From db95a92aa17f0a7ffa5fec04ea0d3d92593f4640 Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Sat, 23 May 2020 04:21:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=B8=AA=E4=BA=BA=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bootstrap/InputGroup.tsx | 2 +- src/bootstrap/LoginFormDesc.ts | 2 + src/entity.ts | 20 +++++- src/my/MyHelp.tsx | 4 +- src/my/MyInfo.tsx | 119 +++++++++++++++++++++++++++++---- 5 files changed, 132 insertions(+), 15 deletions(-) diff --git a/src/bootstrap/InputGroup.tsx b/src/bootstrap/InputGroup.tsx index a3c600f..999a0cf 100644 --- a/src/bootstrap/InputGroup.tsx +++ b/src/bootstrap/InputGroup.tsx @@ -31,7 +31,7 @@ export class Input extends React.Component{ {this.props.desc} - 0?this.props.placeholder:"请输入"+this.props.desc} aria-describedby={this.props.name} value={this.props.value} onChange={(e)=>this.props.onChange(e.target.value)} maxLength={this.props.maxLength }/>
{this.merge().valid} diff --git a/src/bootstrap/LoginFormDesc.ts b/src/bootstrap/LoginFormDesc.ts index c9df9d3..778aed7 100644 --- a/src/bootstrap/LoginFormDesc.ts +++ b/src/bootstrap/LoginFormDesc.ts @@ -8,6 +8,8 @@ export interface FormInputProps { name: string //描述信息 desc: string + //提示信息 + placeholder?:string //表单值 value?: string //数据类型 diff --git a/src/entity.ts b/src/entity.ts index e5ef95d..30fcae2 100644 --- a/src/entity.ts +++ b/src/entity.ts @@ -122,7 +122,7 @@ export interface Friend { /** * 用户信息 */ -export interface User { +export interface User{ //用户ID userId:string; //用户姓名 @@ -141,6 +141,24 @@ export interface User { headImg:string; } +/** + * 个人信息 + */ +export interface UserEdit extends User{ + //编辑模式 + contentEditable:boolean; + //修改时间 + modifyPassword:boolean; + //原密码 + oldPassword:string; + //新密码 + newPassword:string; + //确认新密码 + confirmNewPwd:string; +} + + + /** * 聊天信息 */ diff --git a/src/my/MyHelp.tsx b/src/my/MyHelp.tsx index d720c44..6ae9267 100644 --- a/src/my/MyHelp.tsx +++ b/src/my/MyHelp.tsx @@ -10,7 +10,9 @@ export class MyHelp extends React.Component{ return ( - 我的求助 + + + ) diff --git a/src/my/MyInfo.tsx b/src/my/MyInfo.tsx index 78ac0be..e77c991 100644 --- a/src/my/MyInfo.tsx +++ b/src/my/MyInfo.tsx @@ -1,11 +1,12 @@ import React from "react"; -import {Col, Container, Image, Row} from "react-bootstrap"; -import {User} from "../entity"; +import {Button, Col, Container, Form, FormControl, Image, Row} from "react-bootstrap"; +import {UserEdit} from "../entity"; +import {Input} from "../bootstrap/InputGroup"; /** * 个人信息 */ -export class MyInfo extends React.Component{ +export class MyInfo extends React.Component{ constructor(props: Readonly) { @@ -17,9 +18,9 @@ export class MyInfo extends React.Component{ //用户姓名 name:"", //用户年龄 - age:NaN, + age:0, //用户电话 - mobile:NaN, + mobile:0, //用户邮箱 email:"", //地点 @@ -27,7 +28,12 @@ export class MyInfo extends React.Component{ //个人简介 info:"", //头像 - headImg:"" + headImg:"", + contentEditable:false, + modifyPassword:false, + oldPassword:"", + newPassword:"", + confirmNewPwd:"" } } @@ -51,6 +57,46 @@ export class MyInfo extends React.Component{ 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() { return ( @@ -61,18 +107,67 @@ export class MyInfo extends React.Component{ {this.state.userId} - {this.state.name} - {this.state.age} + + {this.state.contentEditable? + this.setState({name:e.target.value})}/> + :this.state.name} + + {this.state.contentEditable? + this.setState({age:+e.target.value})}/> + :this.state.age} - {this.state.mobile} - {this.state.email} + + {this.state.contentEditable? + this.setState({mobile:+e.target.value})}/> + :this.state.mobile} + + + {this.state.contentEditable? + this.setState({email:e.target.value})}/> + :this.state.email} + - {this.state.address} + + {this.state.contentEditable? + this.setState({address:e.target.value})}/> + :this.state.address} + - {this.state.info} + + {this.state.contentEditable? + this.setState({info:e.target.value})}/> + :this.state.info} + + + {this.state.modifyPassword? + + +
+ this.setState({oldPassword:value})}/> + + this.setState({newPassword:value})}/> + + this.setState({confirmNewPwd:value})}/> +
+ +
+ :null + } + + + + {this.state.contentEditable? + : + } + + + {this.state.modifyPassword? + : + } +
)