对接服务端

1.我的留言-添加、拒绝好友邀请
master
pan 5 years ago
parent 64d4e98477
commit 83401e7396
  1. 2
      src/entity.ts
  2. 8
      src/interface.ts
  3. 14
      src/my/MyInfo.tsx
  4. 67
      src/my/MyLeaveWord.tsx

@ -343,6 +343,8 @@ export enum ActivityStatus {
export interface LeaveWord { export interface LeaveWord {
// 留言用户id // 留言用户id
userId:string; userId:string;
//留言id
leaveWordId:number;
// 留言用户姓名 // 留言用户姓名
name:string; name:string;
// 留言用户头像 // 留言用户头像

@ -21,7 +21,13 @@ export const API={
//更新密码 //更新密码
updatePwd:prefix.user+"/updatePwd", updatePwd:prefix.user+"/updatePwd",
//查看留言 //查看留言
leaveWord:prefix.user+"/find/leaveWord" leaveWord:prefix.user+"/find/leaveWord",
//发送好友邀请
friend:prefix.user+"/friend",
//拒绝好友邀请
refuse:prefix.user+"/refuse",
//同意好友邀请
agree:prefix.user+"/agree"
}, },
main:{ main:{
activity: { activity: {

@ -188,7 +188,19 @@ export class MyInfo extends React.Component<
* *
*/ */
addFriend(){ addFriend(){
let that=this
request(API.account.friend,Method.POST, {targetUserId:this.props.userId},new EmptyBodyTransform(),function (res:JSONResponse<SimpleMessage>) {
switch (res.customResult) {
case SimpleMessage.ok:
that.setState({
result:<h3 className="text-info text-center"></h3>
});break
case SimpleMessage.fail:
that.setState({
result:<h3 className="text-danger text-center">,</h3>
});break
}
})
} }
/** /**

@ -5,8 +5,8 @@ import {Tooltip} from "@material-ui/core";
import {MyDialog} from "../ui/MyDialog"; import {MyDialog} from "../ui/MyDialog";
import {MyInfo} from "./MyInfo"; import {MyInfo} from "./MyInfo";
import {Activity} from "../ui/Activity"; import {Activity} from "../ui/Activity";
import {API, Method, prefix, request} from "../interface"; import {API, JSONResponse, Method, prefix, request} from "../interface";
import {LeaveWordRes, LeaveWordTransform, PageDataMessage} from "../result"; import {EmptyBodyTransform, LeaveWordRes, LeaveWordTransform, PageDataMessage, SimpleMessage} from "../result";
/** /**
* *
@ -33,7 +33,7 @@ export class MyLeaveWord extends React.Component<
super(props); super(props);
this.state={ this.state={
result: <h3 className="text-info text-center"></h3>, result: null,
activityId: null, activityId: null,
data:[], data:[],
openUserInfo:false openUserInfo:false
@ -61,6 +61,7 @@ export class MyLeaveWord extends React.Component<
that.setState({ that.setState({
result:<h3 className="text-danger text-center"></h3> result:<h3 className="text-danger text-center"></h3>
}) })
break
} }
}) })
} }
@ -79,6 +80,55 @@ export class MyLeaveWord extends React.Component<
} }
} }
/**
*
* @param id
*/
doRefuse(id:number){
let that=this
request(API.account.refuse+"/"+id,Method.POST, {},new EmptyBodyTransform(),function (res:JSONResponse<SimpleMessage>) {
switch (res.customResult) {
case SimpleMessage.ok:
that.setState({
result:<h3 className="text-info text-center"></h3>
})
that.loadLeaveWord(1)
break
case SimpleMessage.fail:
that.setState({
result:<h3 className="text-danger text-center"></h3>
})
break
}
})
}
/**
*
* @param data
*/
doAgree(data:LeaveWord){
let that=this
request(API.account.agree,Method.POST, {
leaveWordId:data.leaveWordId+"",
sourceUserId:data.userId
},new EmptyBodyTransform(),function (res:JSONResponse<SimpleMessage>) {
switch (res.customResult) {
case SimpleMessage.ok:
that.setState({
result:<h3 className="text-info text-center"></h3>
})
break
case SimpleMessage.fail:
that.loadLeaveWord(1)
that.setState({
result:<h3 className="text-danger text-center"></h3>
})
break
}
})
}
/** /**
* *
* @param data * @param data
@ -108,8 +158,8 @@ export class MyLeaveWord extends React.Component<
<p className="text-ellipsis leave-word-height">{data.info}</p> <p className="text-ellipsis leave-word-height">{data.info}</p>
</div> </div>
<div className="text-center"> <div className="text-center">
<Button variant={"primary"} className="mr-2"></Button> <Button variant={"primary"} className="mr-2" onClick={()=>this.doAgree(data)}></Button>
<Button variant={"danger"}></Button> <Button variant={"danger"} onClick={()=>this.doRefuse(data.leaveWordId)}></Button>
</div> </div>
</Col> </Col>
} }
@ -142,7 +192,7 @@ export class MyLeaveWord extends React.Component<
render() { render() {
return ( return (
<div className="overflow-auto my-leave-world-height"> <div className="overflow-auto my-leave-world-height">
{this.state.data?this.state.data.map((data,index) =>this.getData(data,index)):this.state.result} {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} isMyFriend={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})}/>
@ -150,6 +200,11 @@ export class MyLeaveWord extends React.Component<
<MyDialog content={<Activity activityId={this.state.activityId} showButton={false} />} <MyDialog content={<Activity activityId={this.state.activityId} showButton={false} />}
open={this.state.activityId!=null} titleId="view-activity" menuName="活动详情" open={this.state.activityId!=null} titleId="view-activity" menuName="活动详情"
onClose={()=>this.setState({activityId:null})}/> onClose={()=>this.setState({activityId:null})}/>
<MyDialog content={this.state.result} open={this.state.result!==null} titleId="my_leave_word_dialog" menuName="提示" onClose={()=>this.setState({
result:null
})}/>
</div> </div>
) )
} }

Loading…
Cancel
Save