You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
156 lines
5.2 KiB
156 lines
5.2 KiB
import React from "react";
|
|
import {Button, Col, Container, Image, Row} from "react-bootstrap";
|
|
import {LeaveWord, LeaveWordType} from "../entity";
|
|
import {Tooltip} from "@material-ui/core";
|
|
import {MyDialog} from "../ui/MyDialog";
|
|
import {MyInfo} from "./MyInfo";
|
|
import {Activity} from "../ui/Activity";
|
|
import {API, Method, prefix, request} from "../interface";
|
|
import {LeaveWordRes, LeaveWordTransform, PageDataMessage} from "../result";
|
|
|
|
/**
|
|
* 我的留言
|
|
*/
|
|
export class MyLeaveWord extends React.Component<
|
|
{
|
|
user:string
|
|
},
|
|
{
|
|
//留言信息
|
|
data?:Array<LeaveWord>;
|
|
//打开用户信息弹框
|
|
openUserInfo:boolean;
|
|
//用户id
|
|
userId?:string;
|
|
//活动详情
|
|
activityId:number|null,
|
|
//加载提示
|
|
result:JSX.Element|null
|
|
}>{
|
|
|
|
|
|
constructor(props: Readonly<any>) {
|
|
super(props);
|
|
|
|
this.state={
|
|
result: <h3 className="text-info text-center">留言列表加载中</h3>,
|
|
activityId: null,
|
|
data:[],
|
|
openUserInfo:false
|
|
}
|
|
}
|
|
|
|
componentDidMount() {
|
|
this.loadLeaveWord(1)
|
|
}
|
|
|
|
/**
|
|
* 加载留言
|
|
*/
|
|
loadLeaveWord(page:number){
|
|
|
|
let that=this
|
|
|
|
request(API.account.leaveWord+"?currentPage="+page,Method.GET,{},new LeaveWordTransform(),function (res:LeaveWordRes) {
|
|
switch (res.customResult) {
|
|
case PageDataMessage.ok:
|
|
that.setState({
|
|
data:res.dataList
|
|
});break
|
|
case PageDataMessage.fail:
|
|
that.setState({
|
|
result:<h3 className="text-danger text-center">留言列表加载失败</h3>
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 解析留言类型
|
|
* @param type
|
|
*/
|
|
getType(type:LeaveWordType){
|
|
switch (type) {
|
|
case LeaveWordType.recommend:return "推荐提示"
|
|
case LeaveWordType.apply:return "报名提示"
|
|
case LeaveWordType.join:return "参加提示"
|
|
case LeaveWordType.complete:return "完成提示"
|
|
case LeaveWordType.friend:return "好友验证"
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 解析留言
|
|
* @param data
|
|
* @param index
|
|
*/
|
|
getData(data:LeaveWord,index:number){
|
|
let body
|
|
if(data.activityId!=null){
|
|
body=<Col>
|
|
<div>
|
|
<h5 className="text-center">{data.title}</h5>
|
|
</div>
|
|
<div>
|
|
<p className="text-ellipsis leave-word-height">{data.content}</p>
|
|
</div>
|
|
<div className="text-center">
|
|
<Button variant={"primary"} onClick={()=>this.setState({activityId:data.activityId})}>查看活动详情</Button>
|
|
</div>
|
|
</Col>
|
|
}else{
|
|
body=
|
|
<Col>
|
|
<div className="invisible">
|
|
<h5>~</h5>
|
|
</div>
|
|
<div>
|
|
<p className="text-ellipsis leave-word-height">{data.info}</p>
|
|
</div>
|
|
<div className="text-center">
|
|
<Button variant={"primary"} className="mr-2">同意</Button>
|
|
<Button variant={"danger"}>拒绝</Button>
|
|
</div>
|
|
</Col>
|
|
}
|
|
|
|
return (
|
|
<Container key={"Container"+index} className="mt-3 pt-2 pb-2 border-info border rounded-pill">
|
|
<Row>
|
|
<Col>
|
|
<h3 className="text-center">{this.getType(data.type)}</h3>
|
|
</Col>
|
|
</Row>
|
|
<Row>
|
|
<Col xs={3}>
|
|
<Image src={prefix.image+data.headImg} className="leave-word-headImg"/>
|
|
<span className="text-center user-name ml-3">{data.name}</span>
|
|
|
|
{data.type===LeaveWordType.friend?
|
|
<Tooltip title="查看用户信息" placement="right">
|
|
<Image src="user.svg" className="ml-1 mb-1 userIcon" onClick={()=>this.setState({openUserInfo:true,userId:data.userId})}/>
|
|
</Tooltip>:null}
|
|
</Col>
|
|
{body}
|
|
</Row>
|
|
|
|
</Container>
|
|
)
|
|
}
|
|
|
|
|
|
render() {
|
|
return (
|
|
<div className="overflow-auto my-leave-world-height">
|
|
{this.state.data?this.state.data.map((data,index) =>this.getData(data,index)):this.state.result}
|
|
<MyDialog titleId="view-user" menuName="用户信息"
|
|
content={<MyInfo isOwn={false} isMyFriend={false} isAdd={false} userId={this.state.userId?this.state.userId:""}/>}
|
|
open={this.state.openUserInfo} onClose={()=>this.setState({openUserInfo:false})}/>
|
|
|
|
<MyDialog content={<Activity activityId={this.state.activityId} showButton={false} />}
|
|
open={this.state.activityId!=null} titleId="view-activity" menuName="活动详情"
|
|
onClose={()=>this.setState({activityId:null})}/>
|
|
</div>
|
|
)
|
|
}
|
|
}
|
|
|