|
|
@ -3,61 +3,34 @@ import {Button, Col, Container, FormControl, Image, ListGroup, Row,} from "react |
|
|
|
import {Chat, User} from "../entity"; |
|
|
|
import {Chat, User} from "../entity"; |
|
|
|
import {Tooltip} from "@material-ui/core"; |
|
|
|
import {Tooltip} from "@material-ui/core"; |
|
|
|
import moment from "moment"; |
|
|
|
import moment from "moment"; |
|
|
|
|
|
|
|
import {MyInfo} from "./MyInfo"; |
|
|
|
|
|
|
|
import {MyDialog} from "./MyDialog"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 聊天窗头像名字 |
|
|
|
|
|
|
|
* @param props |
|
|
|
|
|
|
|
* @constructor |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
function UserPart(props:Readonly<any>) { |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<Col xs={4}> |
|
|
|
|
|
|
|
<Image roundedCircle={true} src={props.headImg} className="chat-headImg"/> |
|
|
|
|
|
|
|
<span className="d-block text-center user-name">{props.name}</span> |
|
|
|
|
|
|
|
</Col> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 聊天窗内容 |
|
|
|
|
|
|
|
* @param props |
|
|
|
|
|
|
|
* @constructor |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
function ContentPart(props:Readonly<any>) { |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<Col xs={7}> |
|
|
|
|
|
|
|
<h6 className="text-center">{moment(props.time).format("YYYY-MM-DD HH:mm:ss")}</h6> |
|
|
|
|
|
|
|
<p>{props.content}</p> |
|
|
|
|
|
|
|
</Col> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 一组信息 |
|
|
|
|
|
|
|
* @param props |
|
|
|
|
|
|
|
* @constructor |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
function GroupPart(props:Readonly<any>) { |
|
|
|
|
|
|
|
if(props.flag){ |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<Row> |
|
|
|
|
|
|
|
<UserPart name={props.name} headImg={props.headImg}/> |
|
|
|
|
|
|
|
<ContentPart content={props.content}/> |
|
|
|
|
|
|
|
</Row>) |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<Row> |
|
|
|
|
|
|
|
<ContentPart content={props.content}/> |
|
|
|
|
|
|
|
<UserPart name={props.name} headImg={props.headImg}/> |
|
|
|
|
|
|
|
</Row>) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const maxLength=150 |
|
|
|
const maxLength=150 |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 我的好友 |
|
|
|
* 我的好友 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
export class MyFriend extends React.Component<any,any>{ |
|
|
|
export class MyFriend extends React.Component<{ user:string }, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//好友列表
|
|
|
|
|
|
|
|
friendList:Array<User>; |
|
|
|
|
|
|
|
//查找好友关键字
|
|
|
|
|
|
|
|
queryFriend:string; |
|
|
|
|
|
|
|
//用户列表
|
|
|
|
|
|
|
|
userList:Array<User>; |
|
|
|
|
|
|
|
//聊天记录
|
|
|
|
|
|
|
|
chatList:Array<Chat>; |
|
|
|
|
|
|
|
//当前选中好友
|
|
|
|
|
|
|
|
friendIndex:number|null; |
|
|
|
|
|
|
|
//发送内容
|
|
|
|
|
|
|
|
sendContent:String; |
|
|
|
|
|
|
|
//查看用户信息
|
|
|
|
|
|
|
|
openUserInfo:boolean; |
|
|
|
|
|
|
|
//查看用户ID
|
|
|
|
|
|
|
|
userId?:string; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
>{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(props: Readonly<any>) { |
|
|
|
constructor(props: Readonly<any>) { |
|
|
@ -73,9 +46,11 @@ export class MyFriend extends React.Component<any,any>{ |
|
|
|
//聊天记录
|
|
|
|
//聊天记录
|
|
|
|
chatList:[], |
|
|
|
chatList:[], |
|
|
|
//当前选中好友
|
|
|
|
//当前选中好友
|
|
|
|
friendIndex:-1, |
|
|
|
friendIndex:null, |
|
|
|
//发送内容
|
|
|
|
//发送内容
|
|
|
|
sendContent:'' |
|
|
|
sendContent:'', |
|
|
|
|
|
|
|
//查看用户信息
|
|
|
|
|
|
|
|
openUserInfo:false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -90,34 +65,34 @@ export class MyFriend extends React.Component<any,any>{ |
|
|
|
queryUser(keyword:string){ |
|
|
|
queryUser(keyword:string){ |
|
|
|
this.setState({ |
|
|
|
this.setState({ |
|
|
|
userList:[{ |
|
|
|
userList:[{ |
|
|
|
//用户姓名
|
|
|
|
headImg:"logo512.png", |
|
|
|
|
|
|
|
userId:"admin", |
|
|
|
name:"张三", |
|
|
|
name:"张三", |
|
|
|
//用户年龄
|
|
|
|
age:Math.ceil(Math.random()*100)+1, |
|
|
|
age:Math.floor(Math.random()*100)+1, |
|
|
|
mobile:1234567879, |
|
|
|
//用户电话
|
|
|
|
email:"admin@qq.com", |
|
|
|
mobile:15920722180, |
|
|
|
address:"上海高新区", |
|
|
|
//发送时间
|
|
|
|
info:"个人简介", |
|
|
|
time:new Date().getTime() |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
//用户姓名
|
|
|
|
headImg:"logo512.png", |
|
|
|
name:"李四", |
|
|
|
userId:"admin", |
|
|
|
//用户年龄
|
|
|
|
name:"张三", |
|
|
|
age:Math.floor(Math.random()*100)+1, |
|
|
|
age:Math.ceil(Math.random()*100)+1, |
|
|
|
//用户电话
|
|
|
|
mobile:1234567879, |
|
|
|
mobile:15920722180, |
|
|
|
email:"admin@qq.com", |
|
|
|
//发送时间
|
|
|
|
address:"上海高新区", |
|
|
|
time:new Date().getTime() |
|
|
|
info:"个人简介", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
//用户姓名
|
|
|
|
headImg:"logo512.png", |
|
|
|
name:"王五", |
|
|
|
userId:"admin", |
|
|
|
//用户年龄
|
|
|
|
name:"张三", |
|
|
|
age:Math.floor(Math.random()*100)+1, |
|
|
|
age:Math.ceil(Math.random()*100)+1, |
|
|
|
//用户电话
|
|
|
|
mobile:1234567879, |
|
|
|
mobile:15920722180, |
|
|
|
email:"admin@qq.com", |
|
|
|
//发送时间
|
|
|
|
address:"上海高新区", |
|
|
|
time:new Date().getTime() |
|
|
|
info:"个人简介", |
|
|
|
}] |
|
|
|
}] |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -126,15 +101,36 @@ export class MyFriend extends React.Component<any,any>{ |
|
|
|
loadMyFriend(keyword:string){ |
|
|
|
loadMyFriend(keyword:string){ |
|
|
|
this.setState({ |
|
|
|
this.setState({ |
|
|
|
friendList:[{ |
|
|
|
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 |
|
|
|
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 |
|
|
|
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 |
|
|
|
status:false |
|
|
|
}] |
|
|
|
}] |
|
|
|
}) |
|
|
|
}) |
|
|
@ -149,7 +145,16 @@ export class MyFriend extends React.Component<any,any>{ |
|
|
|
//发送人头像
|
|
|
|
//发送人头像
|
|
|
|
headImg:"logo512.png", |
|
|
|
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<any,any>{ |
|
|
|
//发送人头像
|
|
|
|
//发送人头像
|
|
|
|
headImg:"logo512.png", |
|
|
|
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<any,any>{ |
|
|
|
//发送人头像
|
|
|
|
//发送人头像
|
|
|
|
headImg:"logo512.png", |
|
|
|
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<any,any>{ |
|
|
|
<ListGroup.Item key={"list"+index} className="d-flex justify-content-between" variant="info"> |
|
|
|
<ListGroup.Item key={"list"+index} className="d-flex justify-content-between" variant="info"> |
|
|
|
<span>{user.name}</span> |
|
|
|
<span>{user.name}</span> |
|
|
|
<Tooltip title="查看用户信息" placement="right"> |
|
|
|
<Tooltip title="查看用户信息" placement="right"> |
|
|
|
<img src="user.svg" alt="查看用户信息" className="userIcon"/> |
|
|
|
<img src="user.svg" alt="查看用户信息" className="userIcon" onClick={()=>this.setState({openUserInfo:true,userId:user.userId})}/> |
|
|
|
</Tooltip> |
|
|
|
</Tooltip> |
|
|
|
</ListGroup.Item>)} |
|
|
|
</ListGroup.Item>)} |
|
|
|
</ListGroup> |
|
|
|
</ListGroup> |
|
|
@ -215,7 +238,27 @@ export class MyFriend extends React.Component<any,any>{ |
|
|
|
<Col xs={8}> |
|
|
|
<Col xs={8}> |
|
|
|
<Container className="bg-light chat-history overflow-auto"> |
|
|
|
<Container className="bg-light chat-history overflow-auto"> |
|
|
|
{this.state.chatList.map((chat:Chat,index:number)=> |
|
|
|
{this.state.chatList.map((chat:Chat,index:number)=> |
|
|
|
<GroupPart key={"group"+index} name={chat.name} headImg={chat.headImg} content={chat.content} flag={this.props.user===chat.name}/> |
|
|
|
this.props.user===chat.userId? |
|
|
|
|
|
|
|
<Row> |
|
|
|
|
|
|
|
<Col xs={4}> |
|
|
|
|
|
|
|
<Image roundedCircle={true} src={chat.headImg} className="chat-headImg"/> |
|
|
|
|
|
|
|
<span className="d-block text-center user-name">{chat.name}</span> |
|
|
|
|
|
|
|
</Col> |
|
|
|
|
|
|
|
<Col xs={7}> |
|
|
|
|
|
|
|
<h6 className="text-center">{moment(chat.time).format("YYYY-MM-DD HH:mm:ss")}</h6> |
|
|
|
|
|
|
|
<p>{chat.content}</p> |
|
|
|
|
|
|
|
</Col> |
|
|
|
|
|
|
|
</Row>: |
|
|
|
|
|
|
|
<Row> |
|
|
|
|
|
|
|
<Col xs={7}> |
|
|
|
|
|
|
|
<h6 className="text-center">{moment(chat.time).format("YYYY-MM-DD HH:mm:ss")}</h6> |
|
|
|
|
|
|
|
<p>{chat.content}</p> |
|
|
|
|
|
|
|
</Col> |
|
|
|
|
|
|
|
<Col xs={4}> |
|
|
|
|
|
|
|
<Image roundedCircle={true} src={chat.headImg} className="chat-headImg"/> |
|
|
|
|
|
|
|
<span className="d-block text-center user-name">{chat.name}</span> |
|
|
|
|
|
|
|
</Col> |
|
|
|
|
|
|
|
</Row> |
|
|
|
)} |
|
|
|
)} |
|
|
|
</Container> |
|
|
|
</Container> |
|
|
|
<Container className={"bg-white chat-send p-3 border-info border "+(this.state.friendIndex!==-1?"":"d-none")}> |
|
|
|
<Container className={"bg-white chat-send p-3 border-info border "+(this.state.friendIndex!==-1?"":"d-none")}> |
|
|
@ -242,6 +285,10 @@ export class MyFriend extends React.Component<any,any>{ |
|
|
|
</Container> |
|
|
|
</Container> |
|
|
|
</Col> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
</Row> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<MyDialog titleId="view-user" menuName="用户信息" |
|
|
|
|
|
|
|
content={<MyInfo ownUserId={this.props.user} isOwn={false} isMyFriend={false} isAdd={true} userId={this.state.userId}/>} |
|
|
|
|
|
|
|
open={this.state.openUserInfo} onClose={()=>this.setState({openUserInfo:false})}/> |
|
|
|
</Container> |
|
|
|
</Container> |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|