对接服务端

1.我的好友-获取好友列表以及查找陌生人
master
pan 5 years ago
parent 83401e7396
commit b7e821a70f
  1. 5
      src/entity.ts
  2. 8
      src/interface.ts
  3. 161
      src/my/MyFriend.tsx
  4. 180
      src/my/MyInfo.tsx
  5. 4
      src/my/MyLeaveWord.tsx
  6. 4
      src/my/MyMessage.tsx
  7. 2
      src/my/SeekHelp.tsx
  8. 17
      src/result.ts

@ -191,7 +191,9 @@ export interface User{
//身份 //身份
userType:string; userType:string;
//用户状态 //用户状态
status?:boolean; chatStatus?:boolean;
//是否我的好友
isMyFriend?:boolean;
} }
/** /**
@ -230,7 +232,6 @@ export interface UserEdit{
newPassword:string; newPassword:string;
//确认新密码 //确认新密码
confirmNewPwd:string; confirmNewPwd:string;
result:JSX.Element|null;
//缓存用户身份 //缓存用户身份
oldUserType?:String; oldUserType?:String;
} }

@ -27,7 +27,13 @@ export const API={
//拒绝好友邀请 //拒绝好友邀请
refuse:prefix.user+"/refuse", refuse:prefix.user+"/refuse",
//同意好友邀请 //同意好友邀请
agree:prefix.user+"/agree" agree:prefix.user+"/agree",
//我的好友
myFriend:prefix.user+"/friend/list",
//刷新聊天室状态
refreshChat:prefix.user+"/chat/status",
//查找用户
findUser:prefix.user+"/find/name"
}, },
main:{ main:{
activity: { activity: {

@ -6,20 +6,25 @@ import moment from "moment";
import {MyInfo} from "./MyInfo"; import {MyInfo} from "./MyInfo";
import {MyDialog} from "../ui/MyDialog"; import {MyDialog} from "../ui/MyDialog";
import {userObj} from "../ui/TestData"; import {userObj} from "../ui/TestData";
import {API, JSONResponse, Method, request} from "../interface";
import {EmptyBodyTransform, PageDataMessage, SimpleMessage, UserRes, UserTransform} from "../result";
const maxLength=150 const maxLength=150
/** /**
* *
*/ */
export class MyFriend extends React.Component<{ user:string }, export class MyFriend extends React.Component<
{ user:string },
{ {
//好友列表 //好友列表
friendList:Array<User>; friendList?:Array<User>;
//查找好友关键字 //查找好友关键字
queryFriend:string; queryFriend:string;
//查找用户关键字
queryUser:string;
//用户列表 //用户列表
userList:Array<User>; userList?:Array<User>;
//聊天记录 //聊天记录
chatList:Array<Chat>; chatList:Array<Chat>;
//当前选中好友 //当前选中好友
@ -28,6 +33,9 @@ export class MyFriend extends React.Component<{ user:string },
sendContent:String; sendContent:String;
//查看用户ID //查看用户ID
userId:string|null; userId:string|null;
//操作反馈
result:JSX.Element|null;
//
} }
>{ >{
@ -40,37 +48,100 @@ export class MyFriend extends React.Component<{ user:string },
friendList:[], friendList:[],
//查找好友关键字 //查找好友关键字
queryFriend:"", queryFriend:"",
//用户列表 queryUser:"",
userList:[],
//聊天记录 //聊天记录
chatList:[], chatList:[],
//当前选中好友 //当前选中好友
friendIndex:null, friendIndex:null,
//发送内容 //发送内容
sendContent:'', sendContent:'',
userId:null userId:null,
result:null
} }
} }
componentDidMount() { componentDidMount() {
this.loadMyFriend("") this.loadMyFriend()
this.joinChat()
}
componentWillUnmount() {
this.leaveChat()
} }
/** /**
* *
* @param keyword
*/ */
queryUser(keyword:string){ joinChat(){
this.setState({ this.refreshStatus(true)
userList:[userObj,userObj,userObj] }
/**
*
*/
refreshStatus(chatStatus:boolean){
let that=this
request(API.account.refreshChat,Method.POST, {chatStatus:String(chatStatus)},new EmptyBodyTransform(),function (res:JSONResponse<SimpleMessage>) {
switch (res.customResult) {
case SimpleMessage.fail:
that.setState({
result:<h3 className="text-danger text-center">{chatStatus?"进入":"退出"}</h3>
})
break
}
}) })
} }
/**
*
*/
leaveChat(){
this.refreshStatus(false)
}
/**
*
*/
queryUser(name:string){
if(!name){
this.setState({
userList:[]
})
}else {
let that = this
request(API.account.findUser + "?name=" + name, Method.GET, {}, new UserTransform(), function (res: UserRes) {
switch (res.customResult) {
case PageDataMessage.ok:
that.setState({
userList: res.dataList
})
break
}
})
}
}
//查找我的好友 //查找我的好友
loadMyFriend(keyword:string){ loadMyFriend(){
this.setState({
friendList:[userObj,userObj,userObj] let that=this
request(API.account.myFriend+"?currentPage=1",Method.GET, {},new UserTransform(),function (res:UserRes) {
switch (res.customResult) {
case PageDataMessage.ok:
that.setState({
friendList:res.dataList
})
break
case PageDataMessage.fail:
that.setState({
result:<h3 className="text-danger text-center"></h3>
})
}
}) })
} }
//加载聊天记录 //加载聊天记录
@ -90,35 +161,51 @@ export class MyFriend extends React.Component<{ user:string },
<ListGroup className="overflow-auto bg-light friend-list"> <ListGroup className="overflow-auto bg-light friend-list">
<ListGroup.Item variant="primary"></ListGroup.Item> <ListGroup.Item variant="primary"></ListGroup.Item>
<ListGroup.Item> <ListGroup.Item>
<FormControl placeholder="查找好友" onChange={(e)=>this.loadMyFriend(e.target.value)}/> <FormControl placeholder="查找好友" onChange={(e)=>{
this.setState({
queryFriend:e.target.value
})
this.loadMyFriend()
}}/>
</ListGroup.Item> </ListGroup.Item>
{this.state.friendList.map((friend:User,index:number)=> {this.state.friendList?this.state.friendList.map((friend:User,index:number)=>
<Tooltip key={"tooltip"+index} title={"点击查看和"+friend.name+"的聊天记录"} placement={"right"}>
<ListGroup.Item onClick={()=> <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"}>
this.setState({ <Tooltip title={"点击查看和"+friend.name+"的聊天记录"} placement={"right"}>
friendIndex:index <span onClick={()=>
}) {
this.loadMyChat(friend) this.setState({
}} className={index===this.state.friendIndex?"text-success":"text-dark"} friendIndex:index
style={{cursor:"pointer"}} variant={friend.status?"info":"secondary"}>{friend.name} })
this.loadMyChat(friend)
}}>{friend.name}</span>
</Tooltip>
<Tooltip title="查看用户信息" placement="right">
<img src="user.svg" alt="查看用户信息" className="userIcon" onClick={()=>this.setState({userId:friend.userId})}/>
</Tooltip>
</ListGroup.Item> </ListGroup.Item>
</Tooltip>)} ):null}
</ListGroup> </ListGroup>
<ListGroup className="overflow-auto bg-light friend-list"> <ListGroup className="overflow-auto bg-light friend-list">
<ListGroup.Item variant="primary"></ListGroup.Item> <ListGroup.Item variant="primary"></ListGroup.Item>
<ListGroup.Item> <ListGroup.Item>
<FormControl placeholder="查找用户" onChange={(e)=>this.queryUser(e.target.value)}/> <FormControl placeholder="查找用户" onChange={(e)=>{
this.setState({
queryUser:e.target.value
})
this.queryUser(e.target.value)
}}/>
</ListGroup.Item> </ListGroup.Item>
{this.state.userList.map((user:User,index:number)=> {this.state.userList?this.state.userList.length>0?this.state.userList.map((user:User,index:number)=>
<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" onClick={()=>this.setState({userId:user.userId})}/> <img src="user.svg" alt="查看用户信息" className="userIcon" onClick={()=>this.setState({userId:user.userId})}/>
</Tooltip> </Tooltip>
</ListGroup.Item>)} </ListGroup.Item>):<ListGroup.Item></ListGroup.Item>:null}
</ListGroup> </ListGroup>
</Col> </Col>
@ -127,7 +214,7 @@ export class MyFriend extends React.Component<{ user:string },
<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)=>
this.props.user===chat.userId? this.props.user===chat.userId?
<Row> <Row key={"row"+index}>
<Col xs={4}> <Col xs={4}>
<Image roundedCircle={true} src={chat.headImg} className="chat-headImg"/> <Image roundedCircle={true} src={chat.headImg} className="chat-headImg"/>
<span className="d-block text-center user-name">{chat.name}</span> <span className="d-block text-center user-name">{chat.name}</span>
@ -137,7 +224,7 @@ export class MyFriend extends React.Component<{ user:string },
<p>{chat.content}</p> <p>{chat.content}</p>
</Col> </Col>
</Row>: </Row>:
<Row> <Row key={"row"+index}>
<Col xs={7}> <Col xs={7}>
<h6 className="text-center">{moment(chat.time).format("YYYY-MM-DD HH:mm:ss")}</h6> <h6 className="text-center">{moment(chat.time).format("YYYY-MM-DD HH:mm:ss")}</h6>
<p>{chat.content}</p> <p>{chat.content}</p>
@ -149,7 +236,7 @@ export class MyFriend extends React.Component<{ user:string },
</Row> </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!==null?"":"d-none")}>
<Row> <Row>
<Col xs={12} className="chat-send-content" contentEditable={true} onKeyPress={(e:any)=>{ <Col xs={12} className="chat-send-content" contentEditable={true} onKeyPress={(e:any)=>{
if(e.target.innerText.length>=maxLength){ if(e.target.innerText.length>=maxLength){
@ -174,8 +261,12 @@ export class MyFriend extends React.Component<{ user:string },
</Col> </Col>
</Row> </Row>
<MyDialog content={this.state.result} open={this.state.result!=null} titleId="my-friend-dialog" menuName="提示信息" onClose={()=>this.setState({
result:null
})}/>
<MyDialog titleId="view-user" menuName="用户信息" <MyDialog titleId="view-user" menuName="用户信息"
content={<MyInfo isOwn={false} isMyFriend={false} isAdd={true} userId={this.state.userId?this.state.userId:""}/>} content={<MyInfo isOwn={false} isAdd={true} userId={this.state.userId?this.state.userId:""}/>}
open={this.state.userId!==null} onClose={()=>this.setState({userId:null})}/> open={this.state.userId!==null} onClose={()=>this.setState({userId:null})}/>
</Container> </Container>
); );

@ -1,6 +1,6 @@
import React from "react"; import React from "react";
import {Button, Col, Container, Form, FormControl, Image, Row} from "react-bootstrap"; import {Button, Col, Container, Form, FormControl, Image, Row} from "react-bootstrap";
import {UserEdit, UserType} from "../entity"; import {User, UserEdit, UserType} from "../entity";
import {Input} from "../ui/InputGroup"; import {Input} from "../ui/InputGroup";
import {API, JSONResponse, Method, prefix, request} from "../interface"; import {API, JSONResponse, Method, prefix, request} from "../interface";
import { import {
@ -21,12 +21,14 @@ import {user_type_cookie} from "../account/PropCookie";
*/ */
export class MyInfo extends React.Component< export class MyInfo extends React.Component<
{ {
//查看用户id
userId:string; userId:string;
//查看本人
isOwn:boolean; isOwn:boolean;
isMyFriend:boolean; //是否添加好友
isAdd:boolean; isAdd:boolean;
cookies?:Cookies; cookies?:Cookies;
}, UserEdit>{ }, { userEdit:UserEdit,userInfo?:User,result:JSX.Element|null }>{
private ages:Array<number> private ages:Array<number>
@ -36,12 +38,14 @@ export class MyInfo extends React.Component<
this.ages=this.createAge() this.ages=this.createAge()
this.state={ this.state={
contentEditable:false, userEdit:{
modifyPassword:false, contentEditable:false,
oldPassword:"", modifyPassword:false,
newPassword:"", oldPassword:"",
confirmNewPwd:"", newPassword:"",
result:null confirmNewPwd:"",
},
result:null,
} }
} }
@ -59,6 +63,9 @@ export class MyInfo extends React.Component<
*/ */
loadInfo(){ loadInfo(){
if(!this.props.userId){
return
}
let that=this let that=this
request(API.account.find+"/"+this.props.userId,Method.GET, {},new FindUserInfoTransform(),function(res:FindUserInfo){ request(API.account.find+"/"+this.props.userId,Method.GET, {},new FindUserInfoTransform(),function(res:FindUserInfo){
@ -69,17 +76,26 @@ export class MyInfo extends React.Component<
});break });break
case SimpleMessage.ok: case SimpleMessage.ok:
that.setState({ that.setState({
headImg:res.info?.headImg, userInfo:res.info,
userId:res.info?.userId, userEdit: {
name:res.info?.name, headImg:res.info?.headImg,
age:res.info?.age, userId:res.info?.userId,
mobile:res.info?.mobile, name:res.info?.name,
email:res.info?.email, age:res.info?.age,
serviceAddress:res.info?.serviceAddress, mobile:+(res.info?.mobile||""),
info:res.info?.info, email:res.info?.email,
userType:res.info?.userType, serviceAddress:res.info?.serviceAddress,
sex:res.info?.sex, info:res.info?.info,
oldUserType:res.info?.userType userType:res.info?.userType,
sex:res.info?.sex,
oldUserType:res.info?.userType,
contentEditable:false,
modifyPassword:false,
oldPassword:"",
newPassword:"",
confirmNewPwd:"",
}
});break });break
} }
@ -95,7 +111,7 @@ export class MyInfo extends React.Component<
*/ */
openEdit(){ openEdit(){
this.setState({ this.setState({
contentEditable:true userEdit:{...this.state.userEdit,...{contentEditable:true}}
}) })
} }
@ -104,7 +120,7 @@ export class MyInfo extends React.Component<
*/ */
openModifyPwd(){ openModifyPwd(){
this.setState({ this.setState({
modifyPassword:true userEdit:{...this.state.userEdit,...{ modifyPassword:true}}
}) })
} }
@ -113,14 +129,14 @@ export class MyInfo extends React.Component<
*/ */
modifyPwd(){ modifyPwd(){
this.setState({ this.setState({
modifyPassword:false userEdit:{...this.state.userEdit,...{ modifyPassword:false}}
}) })
let that=this let that=this
request(API.account.updatePwd,Method.POST, { request(API.account.updatePwd,Method.POST, {
newPassword:this.state.newPassword, newPassword:this.state.userEdit.newPassword,
oldPassword:this.state.oldPassword oldPassword:this.state.userEdit.oldPassword
},new ModifyPwdTransform(),function (res:JSONResponse<ModifyPwdMessage>) { },new ModifyPwdTransform(),function (res:JSONResponse<ModifyPwdMessage>) {
switch (res.customResult) { switch (res.customResult) {
case ModifyPwdMessage.fail: case ModifyPwdMessage.fail:
@ -144,24 +160,24 @@ export class MyInfo extends React.Component<
*/ */
doSave(){ doSave(){
this.setState({ this.setState({
contentEditable:false userEdit:{...this.state.userEdit,...{ contentEditable:false}}
}) })
let that=this let that=this
let isUpdateUserType=this.state.userType!==this.state.oldUserType let isUpdateUserType=this.state.userEdit.userType!==this.state.userEdit.oldUserType
if(isUpdateUserType&&this.props.cookies){ if(isUpdateUserType&&this.props.cookies){
this.props.cookies.set(user_type_cookie,this.state.userType) this.props.cookies.set(user_type_cookie,this.state.userEdit.userType)
} }
request(API.account.update,Method.POST, { request(API.account.update,Method.POST, {
headImg:this.state.headImg||"", headImg:this.state.userEdit.headImg||"",
name:this.state.name||"", name:this.state.userEdit.name||"",
age:this.state.age+""||"", age:this.state.userEdit.age+""||"",
mobile:this.state.mobile+""||"", mobile:this.state.userEdit.mobile+""||"",
email:this.state.email||"", email:this.state.userEdit.email||"",
serviceAddress:this.state.serviceAddress||"", serviceAddress:this.state.userEdit.serviceAddress||"",
info:this.state.info||"", info:this.state.userEdit.info||"",
userType:this.state.userType||"", userType:this.state.userEdit.userType||"",
sex:this.state.sex||"" sex:this.state.userEdit.sex||""
},new EmptyBodyTransform(),function (res:JSONResponse<SimpleMessage>) { },new EmptyBodyTransform(),function (res:JSONResponse<SimpleMessage>) {
switch (res.customResult) { switch (res.customResult) {
case SimpleMessage.fail: case SimpleMessage.fail:
@ -217,74 +233,96 @@ export class MyInfo extends React.Component<
<Container className="overflow-auto"> <Container className="overflow-auto">
<Row> <Row>
<Col className="p-3 text-center"> <Col className="p-3 text-center">
<Image className="chat-headImg" src={this.state.headImg?prefix.image+this.state.headImg:""}/> <Image className="chat-headImg" src={this.state.userInfo?.headImg?prefix.image+this.state.userInfo.headImg:""}/>
</Col> </Col>
</Row> </Row>
{/*TODO 表单校验*/} {/*TODO 表单校验*/}
<Row> <Row>
<Col className="border-info border p-3 d-flex justify-content-center align-items-center"> <Col className="border-info border p-3 d-flex justify-content-center align-items-center">
{this.state.userId} {this.state.userInfo?.userId}
</Col> </Col>
<Col className="border-info border p-3 text-center"> <Col className="border-info border p-3 text-center">
{this.state.contentEditable? {this.state.userEdit.contentEditable?
<FormControl value={this.state.name} onChange={(e)=>this.setState({name:e.target.value})}/> <FormControl value={this.state.userEdit.name} onChange={(e)=>this.setState({
:this.state.name}</Col> userEdit:{...this.state.userEdit,...{ name:e.target.value}}
})}/>
:this.state.userInfo?.name}</Col>
<Col className="border-info border p-3 text-center"> <Col className="border-info border p-3 text-center">
{this.state.contentEditable? {this.state.userEdit.contentEditable?
<FormControl as={"select"} value={this.state.age} onChange={(e)=>this.setState({age:+e.target.value})}> <FormControl as={"select"} value={this.state.userEdit.age} onChange={(e)=>this.setState({
userEdit:{...this.state.userEdit,...{ age:+e.target.value}}
})}>
{this.ages.map(value=><option key={value} value={value}>{value}</option>)} {this.ages.map(value=><option key={value} value={value}>{value}</option>)}
</FormControl> </FormControl>
:this.state.age}</Col> :this.state.userInfo?.age}</Col>
</Row> </Row>
<Row> <Row>
<Col className="border-info border p-3 text-center"> <Col className="border-info border p-3 text-center">
{this.state.contentEditable? {this.state.userEdit.contentEditable?
<FormControl value={this.state.mobile} type={"number"} onChange={(e)=>this.setState({mobile:+e.target.value})}/> <FormControl value={this.state.userEdit.mobile} type={"number"} onChange={(e)=>this.setState({
:this.state.mobile} userEdit:{...this.state.userEdit,...{ mobile:+e.target.value}}
})}/>
:this.state.userInfo?.mobile}
</Col> </Col>
<Col className="border-info border p-3 text-center"> <Col className="border-info border p-3 text-center">
{this.state.contentEditable? {this.state.userEdit.contentEditable?
<FormControl value={this.state.email} onChange={(e)=>this.setState({email:e.target.value})}/> <FormControl value={this.state.userEdit.email} onChange={(e)=>this.setState({
:this.state.email} userEdit:{...this.state.userEdit,...{ email:e.target.value}}
})}/>
:this.state.userInfo?.email}
</Col> </Col>
<Col className="border-info border p-3 text-center"> <Col className="border-info border p-3 text-center">
{this.state.contentEditable? {this.state.userEdit.contentEditable?
<FormControl value={this.state.sex} as={"select"} onChange={event => this.setState({sex:event.target.value})}> <FormControl value={this.state.userEdit.sex} as={"select"} onChange={event => this.setState({
userEdit:{...this.state.userEdit,...{ sex:event.target.value}}
})}>
<option value={"man"}></option> <option value={"man"}></option>
<option value={"women"}></option> <option value={"women"}></option>
</FormControl>:this.state.sex==='man'?"男":"女"} </FormControl>:this.state.userInfo?.sex==='man'?"男":"女"}
</Col> </Col>
</Row> </Row>
<Row> <Row>
<Col className="border-info border p-3 text-center"> <Col className="border-info border p-3 text-center">
{this.state.contentEditable? {this.state.userEdit.contentEditable?
<Address col={12} value={this.state.serviceAddress} onChange={(value:string)=>this.setState({serviceAddress:value})}/>:this.state.serviceAddress} <Address col={12} value={this.state.userEdit.serviceAddress} onChange={(value:string)=>this.setState({
userEdit:{...this.state.userEdit,...{ serviceAddress:value}}
})}/>:this.state.userInfo?.serviceAddress}
</Col> </Col>
<Col className="border-info border p-3 text-center"> <Col className="border-info border p-3 text-center">
{this.state.contentEditable? {this.state.userEdit.contentEditable?
<FormControl value={this.state.userType} as={"select"} onChange={(e)=>this.setState({userType:e.target.value})}> <FormControl value={this.state.userEdit.userType} as={"select"} onChange={(e)=>this.setState({
userEdit:{...this.state.userEdit,...{ userType:e.target.value}}
})}>
<option value={UserType.seekHelp}></option> <option value={UserType.seekHelp}></option>
<option value={UserType.help}></option> <option value={UserType.help}></option>
</FormControl>: </FormControl>:
this.state.userType===UserType.help?"等待前往帮助":"等待接受帮助"} this.state.userInfo?.userType===UserType.help?"等待前往帮助":"等待接受帮助"}
</Col> </Col>
</Row> </Row>
<Row> <Row>
<Col className="border-info border p-3 text-center my-info-desc"> <Col className="border-info border p-3 text-center my-info-desc">
{this.state.contentEditable? {this.state.userEdit.contentEditable?
<FormControl value={this.state.info} as={"textarea"} onChange={(e)=>this.setState({info:e.target.value})}/> <FormControl value={this.state.userEdit.info} as={"textarea"} onChange={(e)=>this.setState({
:this.state.info} userEdit:{...this.state.userEdit,...{ info:e.target.value}}
})}/>
:this.state.userInfo?.info}
</Col> </Col>
</Row> </Row>
{this.state.modifyPassword? {this.state.userEdit.modifyPassword?
<Row> <Row>
<Col> <Col>
<Form> <Form>
<Input name="oldPassword" type={"password"} desc="旧密码" onChange={(value:string)=>this.setState({oldPassword:value})}/> <Input name="oldPassword" type={"password"} desc="旧密码" onChange={(value:string)=>this.setState({
userEdit:{...this.state.userEdit,...{ oldPassword:value}}
})}/>
<Input name="newPassword" type={"password"} desc="新密码" onChange={(value:string)=>this.setState({newPassword:value})}/> <Input name="newPassword" type={"password"} desc="新密码" onChange={(value:string)=>this.setState({
userEdit:{...this.state.userEdit,...{newPassword:value}}
})}/>
<Input name="confirmNewPwd" type={"password"} placeholder="请确认新密码" desc="新密码" onChange={(value:string)=>this.setState({confirmNewPwd:value})}/> <Input name="confirmNewPwd" type={"password"} placeholder="请确认新密码" desc="新密码" onChange={(value:string)=>this.setState({
userEdit:{...this.state.userEdit,...{confirmNewPwd:value}}
})}/>
</Form> </Form>
</Col> </Col>
</Row> </Row>
@ -294,19 +332,19 @@ export class MyInfo extends React.Component<
{this.props.isOwn? {this.props.isOwn?
<Row className="p-3"> <Row className="p-3">
<Col className="text-center"> <Col className="text-center">
{this.state.contentEditable? {this.state.userEdit.contentEditable?
<Button variant={"primary"} onClick={()=>this.doSave()}></Button>: <Button variant={"primary"} onClick={()=>this.doSave()}></Button>:
<Button variant={"info"} onClick={()=>this.openEdit()} disabled={this.state.modifyPassword}></Button>} <Button variant={"info"} onClick={()=>this.openEdit()} disabled={this.state.userEdit.modifyPassword}></Button>}
</Col> </Col>
<Col className="text-center"> <Col className="text-center">
{this.state.modifyPassword? {this.state.userEdit.modifyPassword?
<Button variant={"light"} onClick={()=>this.modifyPwd()}></Button>: <Button variant={"light"} onClick={()=>this.modifyPwd()}></Button>:
<Button variant={"light"} onClick={()=>this.openModifyPwd()} disabled={this.state.contentEditable}></Button>} <Button variant={"light"} onClick={()=>this.openModifyPwd()} disabled={this.state.userEdit.contentEditable}></Button>}
</Col> </Col>
</Row>: </Row>:
<Row className="p-3"> <Row className="p-3">
<Col className="text-center"> <Col className="text-center">
{this.props.isMyFriend?null:this.props.isAdd? {this.state.userInfo?.isMyFriend===undefined||this.state.userInfo.isMyFriend?null:this.props.isAdd?
<Button variant={"primary"} onClick={()=>this.addFriend()}></Button> <Button variant={"primary"} onClick={()=>this.addFriend()}></Button>
: :
<Button variant={"primary"} onClick={()=>this.agreeFriend()}></Button> <Button variant={"primary"} onClick={()=>this.agreeFriend()}></Button>

@ -115,12 +115,12 @@ export class MyLeaveWord extends React.Component<
},new EmptyBodyTransform(),function (res:JSONResponse<SimpleMessage>) { },new EmptyBodyTransform(),function (res:JSONResponse<SimpleMessage>) {
switch (res.customResult) { switch (res.customResult) {
case SimpleMessage.ok: case SimpleMessage.ok:
that.loadLeaveWord(1)
that.setState({ that.setState({
result:<h3 className="text-info text-center"></h3> result:<h3 className="text-info text-center"></h3>
}) })
break break
case SimpleMessage.fail: case SimpleMessage.fail:
that.loadLeaveWord(1)
that.setState({ that.setState({
result:<h3 className="text-danger text-center"></h3> result:<h3 className="text-danger text-center"></h3>
}) })
@ -194,7 +194,7 @@ export class MyLeaveWord extends React.Component<
<div className="overflow-auto my-leave-world-height"> <div className="overflow-auto my-leave-world-height">
{this.state.data?this.state.data.length===0?<h3 className="text-info text-center"></h3>:this.state.data.map((data,index) =>this.getData(data,index)):<h3 className="text-info text-center"></h3>} {this.state.data?this.state.data.length===0?<h3 className="text-info text-center"></h3>:this.state.data.map((data,index) =>this.getData(data,index)):<h3 className="text-info text-center"></h3>}
<MyDialog titleId="view-user" menuName="用户信息" <MyDialog titleId="view-user" menuName="用户信息"
content={<MyInfo isOwn={false} isMyFriend={false} isAdd={false} userId={this.state.userId?this.state.userId:""}/>} content={<MyInfo isOwn={false} isAdd={false} userId={this.state.userId?this.state.userId:""}/>}
open={this.state.openUserInfo} onClose={()=>this.setState({openUserInfo:false})}/> open={this.state.openUserInfo} onClose={()=>this.setState({openUserInfo:false})}/>
<MyDialog content={<Activity activityId={this.state.activityId} showButton={false} />} <MyDialog content={<Activity activityId={this.state.activityId} showButton={false} />}

@ -22,7 +22,7 @@ export class MyMessage extends React.Component<{ user:string,cookies:Cookies },
this.state={ this.state={
subMenu:Menu.info, subMenu:Menu.info,
page:<MyInfo cookies={this.props.cookies} userId={this.props.user} isMyFriend={false} isOwn={true} isAdd={false}/> page:<MyInfo cookies={this.props.cookies} userId={this.props.user} isOwn={true} isAdd={false}/>
} }
} }
@ -31,7 +31,7 @@ export class MyMessage extends React.Component<{ user:string,cookies:Cookies },
this.setState({subMenu:menu}) this.setState({subMenu:menu})
switch (menu) { switch (menu) {
case Menu.info: case Menu.info:
this.setState({page:<MyInfo cookies={this.props.cookies} userId={this.props.user} isMyFriend={false} isOwn={true} isAdd={false}/>}) this.setState({page:<MyInfo cookies={this.props.cookies} userId={this.props.user} isOwn={true} isAdd={false}/>})
break break
case Menu.help: case Menu.help:
this.setState({page:<MyHelp/>}) this.setState({page:<MyHelp/>})

@ -149,7 +149,7 @@ export class SeekHelp extends React.Component<{ user:string },
</Dialog> </Dialog>
<MyDialog titleId="view-user" menuName="用户信息" <MyDialog titleId="view-user" menuName="用户信息"
content={<MyInfo isOwn={false} isMyFriend={false} isAdd={true} userId={this.state.userId?this.state.userId:""}/>} content={<MyInfo isOwn={false} isAdd={true} userId={this.state.userId?this.state.userId:""}/>}
open={this.state.openUserInfo} onClose={()=>this.setState({openUserInfo:false})}/> open={this.state.openUserInfo} onClose={()=>this.setState({openUserInfo:false})}/>
<MyDialog content={this.state.result} open={this.state.result!==null} titleId="seek-help-dialog" <MyDialog content={this.state.result} open={this.state.result!==null} titleId="seek-help-dialog"

@ -2,7 +2,7 @@
* *
*/ */
import {JSONResponse, Result, TransformData} from "./interface"; import {JSONResponse, Result, TransformData} from "./interface";
import {ActivityDetail, HelpEntity, LeaveWord, PageProps, SeekHelpState, User, UserEdit, UserType} from "./entity"; import {ActivityDetail, HelpEntity, LeaveWord, PageProps, SeekHelpState, User, UserType} from "./entity";
/** /**
* body响应 * body响应
@ -170,7 +170,7 @@ export class ActivityDetailTransform extends TransformData<SimpleMessage, Activi
} }
export class FindUserInfo extends JSONResponse<SimpleMessage>{ export class FindUserInfo extends JSONResponse<SimpleMessage>{
info?:UserEdit info?:User
} }
//查找用户信息转换 //查找用户信息转换
export class FindUserInfoTransform extends TransformData<SimpleMessage, FindUserInfo>{ export class FindUserInfoTransform extends TransformData<SimpleMessage, FindUserInfo>{
@ -262,3 +262,16 @@ export class HelpTransform extends PageDataTransform<HelpRes>{
} }
/**
*
*/
export class UserRes extends PageDataRes{
dataList?:Array<User>
}
export class UserTransform extends PageDataTransform<UserRes>{
protected newObject(): UserRes {
return new UserRes();
}
}

Loading…
Cancel
Save