好友搜索优化

master
pan 5 years ago
parent 5061dd4a9f
commit 7fbbc9086d
  1. 21
      src/my/MyFriend.tsx
  2. 4
      src/public.tsx

@ -158,9 +158,10 @@ export class MyFriend extends React.Component<
queryFriend:e.target.value queryFriend:e.target.value
}) })
loadMyFriend(e.target.value,this,1) loadMyFriend(e.target.value,this,1)
this.queryUser(e.target.value,1)
}}/> }}/>
</ListGroup.Item> </ListGroup.Item>
{this.state.friendList?this.state.friendList.map((friend:User,index:number)=> {this.state.friendList?this.state.friendList.length>0?this.state.friendList.map((friend:User,index:number)=>
<ListGroup.Item key={"tooltip"+index} className={"d-flex justify-content-between "+(index===this.state.friendIndex?"text-success":"text-dark")} <ListGroup.Item key={"tooltip"+index} className={"d-flex justify-content-between "+(index===this.state.friendIndex?"text-success":"text-dark")}
style={{cursor:"pointer"}} variant={friend.chatStatus?"info":"secondary"}> style={{cursor:"pointer"}} variant={friend.chatStatus?"info":"secondary"}>
@ -171,7 +172,7 @@ export class MyFriend extends React.Component<
friendIndex:index friendIndex:index
}) })
this.loadMyChat(friend) this.loadMyChat(friend)
}}>{friend.name}</span> }}>{friend.userId}</span>
</Tooltip> </Tooltip>
<Tooltip title="查看用户信息" placement="right"> <Tooltip title="查看用户信息" placement="right">
<img src="user.svg" alt="查看用户信息" className="userIcon" onClick={()=>this.setState({userId:friend.userId})}/> <img src="user.svg" alt="查看用户信息" className="userIcon" onClick={()=>this.setState({userId:friend.userId})}/>
@ -179,8 +180,20 @@ export class MyFriend extends React.Component<
</ListGroup.Item> </ListGroup.Item>
):null} ):<div>
<ListGroup.Item></ListGroup.Item> <ListGroup.Item></ListGroup.Item>
{this.state.userList?this.state.userList.length>0?this.state.userList.map((user:User,index:number)=>
<ListGroup.Item className={"d-flex justify-content-between"}>
<span>{user.userId}</span>
<Tooltip title="查看用户信息" placement="right">
<img src="user.svg" alt="查看用户信息" className="userIcon" onClick={()=>this.setState({userId:user.userId})}/>
</Tooltip>
</ListGroup.Item>
):<ListGroup.Item></ListGroup.Item>:null}
</div>: null}
{this.state.scrollTip!==null?<SimpleSnackbar message={this.state.scrollTip} onClose={()=>this.setState({scrollTip:null})} duration={1000}/>:null} {this.state.scrollTip!==null?<SimpleSnackbar message={this.state.scrollTip} onClose={()=>this.setState({scrollTip:null})} duration={1000}/>:null}

@ -81,10 +81,10 @@ export function scrollBottom(e:any,that:React.Component<any,any>,callback:Functi
} }
//查找我的好友 //查找我的好友
export function loadMyFriend(name:string,that:React.Component<any,any>,page:number){ export function loadMyFriend(targetUserId:string,that:React.Component<any,any>,page:number){
request(Api.account.myFriend,Method.GET, { request(Api.account.myFriend,Method.GET, {
currentPage:String(page), currentPage:String(page),
name:name targetUserId:targetUserId
},new UserTransform(),function (res:UserRes) { },new UserTransform(),function (res:UserRes) {
switch (res.customResult) { switch (res.customResult) {
case PageDataMessage.ok: case PageDataMessage.ok:

Loading…
Cancel
Save