diff --git a/src/Address.tsx b/src/Address.tsx index 5e5f01d..7db4054 100644 --- a/src/Address.tsx +++ b/src/Address.tsx @@ -5,7 +5,7 @@ import React from "react"; /** * 加载服务地点信息 */ -export class Address extends React.Component{ +export class Address extends React.Component }>{ constructor(props: Readonly) { diff --git a/src/App.tsx b/src/App.tsx index cd30dae..255e9d3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,12 +2,12 @@ import React from 'react'; import './App.css'; import 'bootstrap/dist/css/bootstrap.min.css'; import {Login} from './account/Login'; -import {withCookies} from 'react-cookie'; +import {Cookies, withCookies} from 'react-cookie'; import {Main} from "./Main"; import {Register} from "./account/Register"; import {user_cookie} from "./account/PropCookie"; -class App extends React.Component { +class App extends React.Component<{ allCookies:any;cookies:Cookies }, { page?:JSX.Element }> { constructor(props: Readonly) { @@ -27,11 +27,9 @@ class App extends React.Component { } } - - //注销登录 +//注销登录 logout(){ - const { cookies } = this.props - cookies.remove(user_cookie) + this.props.cookies.remove(user_cookie) this.toLogin() } @@ -47,9 +45,8 @@ class App extends React.Component { //登录 login(user:string,password:string){ - const { cookies } = this.props console.debug("user_cookie="+user) - cookies.set(user_cookie,user) + this.props.cookies.set(user_cookie,user) this.setState({ page:
this.logout()}/> diff --git a/src/Main.tsx b/src/Main.tsx index 161d918..828421e 100644 --- a/src/Main.tsx +++ b/src/Main.tsx @@ -7,6 +7,7 @@ import {MyFriend} from "./my/MyFriend"; import {MyDialog} from "./my/MyDialog"; import {MyLeaveWord} from "./my/MyLeaveWord"; import {MyMessage} from "./my/MyMessage"; +import {User} from "./entity"; /** * 菜单标记 @@ -29,7 +30,18 @@ enum DialogType { /** * 主菜单 */ -export class Main extends React.Component{ +export class Main extends React.Component<{ user:string,logout:Function }, + { + menu:Menu; + subMenu:JSX.Element; + friendList:Array; + my:{ + menuName:string; + content:JSX.Element|null; + open:boolean; + } + } +>{ constructor(props: Readonly) { super(props); @@ -91,7 +103,7 @@ export class Main extends React.Component{ * 关闭弹窗 */ closeDialog(){ - this.setState({my:{...this.state.my,...{menuName: "",content:null,open:false}}}) + this.setState({ my:{...this.state.my,...{menuName:"",content:null,open:false}}}) console.debug(this.state.my) } @@ -108,12 +120,12 @@ export class Main extends React.Component{ break; case DialogType.leaveWord: this.setState({ - my:{menuName:dialogType,content:,open:true} + my:{menuName:dialogType,content:,open:true} }) break; case DialogType.message: this.setState({ - my:{menuName:dialogType,content:,open:true} + my:{menuName:dialogType,content:,open:true} }) break; } @@ -149,7 +161,7 @@ export class Main extends React.Component{ 等待接受帮助 - this.closeDialog()}/> + this.closeDialog()}/> diff --git a/src/Page.tsx b/src/Page.tsx index b09d7c4..9ec9986 100644 --- a/src/Page.tsx +++ b/src/Page.tsx @@ -5,7 +5,7 @@ import {Pagination} from "react-bootstrap"; /** * 分页组件 */ -export class Page extends React.Component{ +export class Page extends React.Component{ render() { return ( diff --git a/src/bootstrap/InputGroup.tsx b/src/bootstrap/InputGroup.tsx index c4b11df..d46fe5a 100644 --- a/src/bootstrap/InputGroup.tsx +++ b/src/bootstrap/InputGroup.tsx @@ -11,7 +11,7 @@ const defaultValid={ /** * bootstrap InputGroup组件封装 */ -export class Input extends React.Component{ +export class Input extends React.Component{ merge(){ return {...defaultValid,...this.props.valid} diff --git a/src/entity.ts b/src/entity.ts index 489e715..f9a3856 100644 --- a/src/entity.ts +++ b/src/entity.ts @@ -151,9 +151,9 @@ export interface CloseDialogProps extends BaseDialogProps{ /** * 我的弹窗 */ -export interface MyDialogProps extends BaseDialogProps{ +export interface MyDialogProps extends CloseDialogProps{ //弹窗内容 - content:React.Component; + content:JSX.Element|null; //弹窗状态 open:boolean; } @@ -203,14 +203,12 @@ export interface UserEdit extends User{ /** * 聊天信息 */ -export interface Chat { - //发送人名称 - name:string; - //发送人头像 - headImg:string; +export interface Chat extends User{ //发送内容 content:string; //发送时间 time:number; + //是否我发送的信息 + flag:boolean; } diff --git a/src/index.css b/src/index.css index 19cfb8e..2354f0b 100644 --- a/src/index.css +++ b/src/index.css @@ -122,3 +122,4 @@ .volunteer{ width: 1400px; } + diff --git a/src/my/CloseDialog.tsx b/src/my/CloseDialog.tsx index 8322062..6614fad 100644 --- a/src/my/CloseDialog.tsx +++ b/src/my/CloseDialog.tsx @@ -5,7 +5,8 @@ import {CloseDialogProps} from "../entity"; /** * 关闭弹窗 */ -export class CloseDialog extends React.Component{ +export class CloseDialog extends React.Component{ + render() { return ( diff --git a/src/my/MyDialog.tsx b/src/my/MyDialog.tsx index acefbad..121b946 100644 --- a/src/my/MyDialog.tsx +++ b/src/my/MyDialog.tsx @@ -8,30 +8,22 @@ import {CloseDialog} from "./CloseDialog"; /** * 我的弹窗 */ -export class MyDialog extends React.Component{ +export class MyDialog extends React.Component{ - constructor(props: Readonly) { - super(props); - - this.state={ - titleId:"my-dialog" - } - } - render() { return ( - + } - aria-labelledby={this.state.titleId} + aria-labelledby={this.props.titleId} classes={{paper:"w-100"}} > - this.props.onClose()} titleId={this.state.titleId}/> + this.props.onClose()} titleId={this.props.titleId}/>
{this.props.content} diff --git a/src/my/MyFriend.tsx b/src/my/MyFriend.tsx index b8ad616..e01e63a 100644 --- a/src/my/MyFriend.tsx +++ b/src/my/MyFriend.tsx @@ -3,61 +3,34 @@ import {Button, Col, Container, FormControl, Image, ListGroup, Row,} from "react import {Chat, User} from "../entity"; import {Tooltip} from "@material-ui/core"; import moment from "moment"; +import {MyInfo} from "./MyInfo"; +import {MyDialog} from "./MyDialog"; -/** - * 聊天窗头像名字 - * @param props - * @constructor - */ -function UserPart(props:Readonly) { - return ( - - - {props.name} - - ) -} - -/** - * 聊天窗内容 - * @param props - * @constructor - */ -function ContentPart(props:Readonly) { - return ( - -
{moment(props.time).format("YYYY-MM-DD HH:mm:ss")}
-

{props.content}

- - ) -} - -/** - * 一组信息 - * @param props - * @constructor - */ -function GroupPart(props:Readonly) { - if(props.flag){ - return ( - - - - ) - }else{ - return ( - - - - ) - } -} const maxLength=150 /** * 我的好友 */ -export class MyFriend extends React.Component{ +export class MyFriend extends React.Component<{ user:string }, + { + //好友列表 + friendList:Array; + //查找好友关键字 + queryFriend:string; + //用户列表 + userList:Array; + //聊天记录 + chatList:Array; + //当前选中好友 + friendIndex:number|null; + //发送内容 + sendContent:String; + //查看用户信息 + openUserInfo:boolean; + //查看用户ID + userId?:string; +} +>{ constructor(props: Readonly) { @@ -73,9 +46,11 @@ export class MyFriend extends React.Component{ //聊天记录 chatList:[], //当前选中好友 - friendIndex:-1, + friendIndex:null, //发送内容 - sendContent:'' + sendContent:'', + //查看用户信息 + openUserInfo:false } } @@ -90,34 +65,34 @@ export class MyFriend extends React.Component{ queryUser(keyword:string){ this.setState({ userList:[{ - //用户姓名 + headImg:"logo512.png", + userId:"admin", name:"张三", - //用户年龄 - age:Math.floor(Math.random()*100)+1, - //用户电话 - mobile:15920722180, - //发送时间 - time:new Date().getTime() + age:Math.ceil(Math.random()*100)+1, + mobile:1234567879, + email:"admin@qq.com", + address:"上海高新区", + info:"个人简介", }, { - //用户姓名 - name:"李四", - //用户年龄 - age:Math.floor(Math.random()*100)+1, - //用户电话 - mobile:15920722180, - //发送时间 - time:new Date().getTime() + headImg:"logo512.png", + userId:"admin", + name:"张三", + age:Math.ceil(Math.random()*100)+1, + mobile:1234567879, + email:"admin@qq.com", + address:"上海高新区", + info:"个人简介", }, { - //用户姓名 - name:"王五", - //用户年龄 - age:Math.floor(Math.random()*100)+1, - //用户电话 - mobile:15920722180, - //发送时间 - time:new Date().getTime() + headImg:"logo512.png", + userId:"admin", + name:"张三", + age:Math.ceil(Math.random()*100)+1, + mobile:1234567879, + email:"admin@qq.com", + address:"上海高新区", + info:"个人简介", }] }) } @@ -126,15 +101,36 @@ export class MyFriend extends React.Component{ loadMyFriend(keyword:string){ this.setState({ friendList:[{ - name:"好友1", + headImg:"logo512.png", + userId:"admin", + name:"张三", + age:Math.ceil(Math.random()*100)+1, + mobile:1234567879, + email:"admin@qq.com", + address:"上海高新区", + info:"个人简介", status:true }, { - name:"好友2", + headImg:"logo512.png", + userId:"admin", + name:"张三", + age:Math.ceil(Math.random()*100)+1, + mobile:1234567879, + email:"admin@qq.com", + address:"上海高新区", + info:"个人简介", status:false }, { - name:"好友3", + headImg:"logo512.png", + userId:"admin", + name:"张三", + age:Math.ceil(Math.random()*100)+1, + mobile:1234567879, + email:"admin@qq.com", + address:"上海高新区", + info:"个人简介", status:false }] }) @@ -149,7 +145,16 @@ export class MyFriend extends React.Component{ //发送人头像 headImg:"logo512.png", //发送内容 - content:"发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容" + content:"发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容", + //发送时间 + time:new Date().getTime(), + userId:"admin", + age:Math.ceil(Math.random()*100)+1, + mobile:1234567879, + email:"admin@qq.com", + address:"上海高新区", + info:"个人简介", + flag:false }, { //发送人名称 @@ -157,7 +162,16 @@ export class MyFriend extends React.Component{ //发送人头像 headImg:"logo512.png", //发送内容 - content:"发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容" + content:"发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容", + //发送时间 + time:new Date().getTime(), + userId:"admin", + age:Math.ceil(Math.random()*100)+1, + mobile:1234567879, + email:"admin@qq.com", + address:"上海高新区", + info:"个人简介", + flag:false }, { //发送人名称 @@ -165,7 +179,16 @@ export class MyFriend extends React.Component{ //发送人头像 headImg:"logo512.png", //发送内容 - content:"发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容" + content:"发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容", + //发送时间 + time:new Date().getTime(), + userId:"admin", + age:Math.ceil(Math.random()*100)+1, + mobile:1234567879, + email:"admin@qq.com", + address:"上海高新区", + info:"个人简介", + flag:true }] }) } @@ -205,7 +228,7 @@ export class MyFriend extends React.Component{ {user.name} - 查看用户信息 + 查看用户信息this.setState({openUserInfo:true,userId:user.userId})}/> )} @@ -215,7 +238,27 @@ export class MyFriend extends React.Component{ {this.state.chatList.map((chat:Chat,index:number)=> - + this.props.user===chat.userId? + + + + {chat.name} + + +
{moment(chat.time).format("YYYY-MM-DD HH:mm:ss")}
+

{chat.content}

+ +
: + + +
{moment(chat.time).format("YYYY-MM-DD HH:mm:ss")}
+

{chat.content}

+ + + + {chat.name} + +
)}
@@ -242,6 +285,10 @@ export class MyFriend extends React.Component{ + + } + open={this.state.openUserInfo} onClose={()=>this.setState({openUserInfo:false})}/> ); } diff --git a/src/my/MyHelp.tsx b/src/my/MyHelp.tsx index 91ed8b3..67f9523 100644 --- a/src/my/MyHelp.tsx +++ b/src/my/MyHelp.tsx @@ -8,7 +8,7 @@ const classList="border-info border d-flex justify-content-center align-items-ce /** * 我的求助 */ -export class MyHelp extends React.Component }>{ +export class MyHelp extends React.Component<{ undefined?:undefined }, { data:Array }>{ constructor(props: Readonly) { @@ -181,6 +181,7 @@ export class MyHelp extends React.Component }>{
)} + ) } diff --git a/src/my/MyInfo.tsx b/src/my/MyInfo.tsx index e77c991..7e5186a 100644 --- a/src/my/MyInfo.tsx +++ b/src/my/MyInfo.tsx @@ -3,10 +3,18 @@ import {Button, Col, Container, Form, FormControl, Image, Row} from "react-boots import {UserEdit} from "../entity"; import {Input} from "../bootstrap/InputGroup"; + /** * 个人信息 */ -export class MyInfo extends React.Component{ +export class MyInfo extends React.Component< + { + isOwn:boolean; + ownUserId:string; + userId?:string; + isMyFriend:boolean; + isAdd:boolean; + }, UserEdit>{ constructor(props: Readonly) { @@ -96,8 +104,23 @@ export class MyInfo extends React.Component{ } + /** + * 添加好友 + */ + addFriend(){ + + } + + /** + * 同意好友邀请 + */ + agreeFriend(){ + + } + render() { + return ( @@ -157,18 +180,30 @@ export class MyInfo extends React.Component{ :null } - - - {this.state.contentEditable? - : - } - - - {this.state.modifyPassword? - : - } - - + {this.props.isOwn? + + + {this.state.contentEditable? + : + } + + + {this.state.modifyPassword? + : + } + + : + + + {this.props.isMyFriend?null:this.props.isAdd? + + : + + } + + + } + ) } diff --git a/src/my/MyLeaveWord.tsx b/src/my/MyLeaveWord.tsx index a064162..3ac687b 100644 --- a/src/my/MyLeaveWord.tsx +++ b/src/my/MyLeaveWord.tsx @@ -1,6 +1,9 @@ import React from "react"; import {Button, Col, Container, Image, Row} from "react-bootstrap"; import {ActiveDetail, User} from "../entity"; +import {Tooltip} from "@material-ui/core"; +import {MyDialog} from "./MyDialog"; +import {MyInfo} from "./MyInfo"; enum LeaveWordType { recommend, @@ -24,15 +27,17 @@ interface Type2 { /** * 我的留言 */ -export class MyLeaveWord extends React.Component; + openUserInfo:boolean; + userId?:string; }>{ constructor(props: Readonly) { super(props); - this.state={data:[]} + this.state={data:[],openUserInfo:false} } componentDidMount() { @@ -115,8 +120,9 @@ export class MyLeaveWord extends React.Component @@ -147,7 +153,7 @@ export class MyLeaveWord extends React.Component +

{this.getType(data.type)}

@@ -156,10 +162,16 @@ export class MyLeaveWord extends React.Component - {data.user.name} + {data.user.name} + + {data.type===LeaveWordType.friend? + + this.setState({openUserInfo:true,userId:data.user.userId})}/> + :null} {body}
+
) } @@ -168,7 +180,10 @@ export class MyLeaveWord extends React.Component - {this.state.data.map(data =>this.getData(data))} + {this.state.data.map((data,index) =>this.getData(data,index))} + } + open={this.state.openUserInfo} onClose={()=>this.setState({openUserInfo:false})}/> ); } diff --git a/src/my/MyMessage.tsx b/src/my/MyMessage.tsx index 8323d35..e91ee70 100644 --- a/src/my/MyMessage.tsx +++ b/src/my/MyMessage.tsx @@ -13,7 +13,7 @@ enum Menu { /** * 个人信息 */ -export class MyMessage extends React.Component{ +export class MyMessage extends React.Component<{ user:string }, { subMenu:Menu,page:JSX.Element }>{ constructor(props: Readonly) { @@ -21,7 +21,7 @@ export class MyMessage extends React.Component{ this.state={ subMenu:Menu.info, - page: + page: } } @@ -30,13 +30,13 @@ export class MyMessage extends React.Component{ this.setState({subMenu:menu}) switch (menu) { case Menu.info: - this.setState({page:}) + this.setState({page:}) break case Menu.help: this.setState({page:}) break case Menu.seekHelp: - this.setState({page:}) + this.setState({page:}) break } } diff --git a/src/my/SeekHelp.tsx b/src/my/SeekHelp.tsx index 8873b21..ca3bfb4 100644 --- a/src/my/SeekHelp.tsx +++ b/src/my/SeekHelp.tsx @@ -6,6 +6,8 @@ import Dialog from "@material-ui/core/Dialog"; import {CloseDialog} from "./CloseDialog"; import {Paper, Tooltip} from "@material-ui/core"; import Draggable from "react-draggable"; +import {MyDialog} from "./MyDialog"; +import {MyInfo} from "./MyInfo"; /** * 志愿者状态 @@ -21,11 +23,15 @@ const titleId="seek-help-dialog" /** * 我的帮助 */ -export class SeekHelp extends React.Component, - open:boolean, - status?:VolunteerStatus, - volunteerList?:Array}>{ +export class SeekHelp extends React.Component<{ user:string }, + { + data:Array; + open:boolean; + status?:VolunteerStatus; + volunteerList?:Array; + openUserInfo:boolean; + userId?:string; + }>{ constructor(props: Readonly) { @@ -33,7 +39,8 @@ export class SeekHelp extends React.Component {user.name} - 查看用户信息 + 查看用户信息this.setState({openUserInfo:true,userId:user.userId})}/> )}
+ + } + open={this.state.openUserInfo} onClose={()=>this.setState({openUserInfo:false})}/> ) } diff --git a/src/sub/IndexMenu.tsx b/src/sub/IndexMenu.tsx index fb86b94..7c6377b 100644 --- a/src/sub/IndexMenu.tsx +++ b/src/sub/IndexMenu.tsx @@ -6,7 +6,7 @@ import {Page} from "../Page"; /** * 首页 */ -export class IndexMenu extends React.Component{ +export class IndexMenu extends React.Component<{ undefined?:undefined }, any>{ diff --git a/src/sub/SendHelp.tsx b/src/sub/SendHelp.tsx index 23eba7b..5e51d87 100644 --- a/src/sub/SendHelp.tsx +++ b/src/sub/SendHelp.tsx @@ -28,7 +28,7 @@ const recommendType=[RecommendType.no, RecommendType.choose,RecommendType.auto] /** * 我的求助 */ -export class SendHelp extends React.Component{ +export class SendHelp extends React.Component<{ undefined?:undefined }, SendHelpState>{ //存放活动背景图 private fileImg: RefObject; //当前选中的好友索引 diff --git a/src/sub/Volunteer.tsx b/src/sub/Volunteer.tsx index 3e19d6d..370f1e8 100644 --- a/src/sub/Volunteer.tsx +++ b/src/sub/Volunteer.tsx @@ -8,7 +8,19 @@ import {Address} from "../Address"; /** * 志愿者信息 */ -export class Volunteer extends React.Component{ +export class Volunteer extends React.Component<{ undefined?:undefined }, { + form:{ + keyword:string; + address:string; + }; + addressList:Array<{address:string}>; + volunteerList:Array>; + page:{ + currentPage:number; + totalPage:number; + pageSize:number; + } +}>{ constructor(props: Readonly) {