|
|
|
@ -1,85 +1,67 @@ |
|
|
|
|
import React from "react"; |
|
|
|
|
import {Button, Col, Container, Image, Row} from "react-bootstrap"; |
|
|
|
|
import {ActivityDetail, User} from "../entity"; |
|
|
|
|
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 {activityObj, userObj} from "../ui/TestData"; |
|
|
|
|
|
|
|
|
|
enum LeaveWordType { |
|
|
|
|
//推荐
|
|
|
|
|
recommend="recommend", |
|
|
|
|
//报名
|
|
|
|
|
apply="apply", |
|
|
|
|
//参与
|
|
|
|
|
join="join", |
|
|
|
|
//完成
|
|
|
|
|
complete="complete", |
|
|
|
|
//好友验证
|
|
|
|
|
friend="friend" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
interface Type1{ |
|
|
|
|
activity:ActivityDetail; |
|
|
|
|
user:User; |
|
|
|
|
type:LeaveWordType; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
interface Type2 { |
|
|
|
|
user:User; |
|
|
|
|
type:LeaveWordType; |
|
|
|
|
} |
|
|
|
|
import {API, Method, prefix, request} from "../interface"; |
|
|
|
|
import {LeaveWordRes, LeaveWordTransform, PageDataMessage} from "../result"; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 我的留言 |
|
|
|
|
*/ |
|
|
|
|
export class MyLeaveWord extends React.Component<{ user:string }, |
|
|
|
|
export class MyLeaveWord extends React.Component< |
|
|
|
|
{ |
|
|
|
|
user:string |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
//留言信息
|
|
|
|
|
data:Array<Type1|Type2>; |
|
|
|
|
data?:Array<LeaveWord>; |
|
|
|
|
//打开用户信息弹框
|
|
|
|
|
openUserInfo:boolean; |
|
|
|
|
//用户id
|
|
|
|
|
userId?:string; |
|
|
|
|
//打开活动信息弹框
|
|
|
|
|
openActivity:boolean; |
|
|
|
|
//活动详情
|
|
|
|
|
activity?:ActivityDetail; |
|
|
|
|
activityId:number|null, |
|
|
|
|
//加载提示
|
|
|
|
|
result:JSX.Element|null |
|
|
|
|
}>{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(props: Readonly<any>) { |
|
|
|
|
super(props); |
|
|
|
|
|
|
|
|
|
this.state={data:[],openUserInfo:false,openActivity:false} |
|
|
|
|
this.state={ |
|
|
|
|
result: <h3 className="text-info text-center">留言列表加载中</h3>, |
|
|
|
|
activityId: null, |
|
|
|
|
data:[], |
|
|
|
|
openUserInfo:false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
componentDidMount() { |
|
|
|
|
this.loadLeaveWord() |
|
|
|
|
this.loadLeaveWord(1) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 加载留言 |
|
|
|
|
*/ |
|
|
|
|
loadLeaveWord(){ |
|
|
|
|
this.setState({ |
|
|
|
|
data:[ |
|
|
|
|
{ |
|
|
|
|
user:userObj, |
|
|
|
|
activity:activityObj, |
|
|
|
|
type:LeaveWordType.recommend |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
user:userObj, |
|
|
|
|
activity:activityObj, |
|
|
|
|
type:LeaveWordType.apply |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
user:userObj, |
|
|
|
|
type:LeaveWordType.friend |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
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> |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -102,18 +84,18 @@ export class MyLeaveWord extends React.Component<{ user:string }, |
|
|
|
|
* @param data |
|
|
|
|
* @param index |
|
|
|
|
*/ |
|
|
|
|
getData(data:Type1|Type2,index:number){ |
|
|
|
|
getData(data:LeaveWord,index:number){ |
|
|
|
|
let body |
|
|
|
|
if("activity" in data ){ |
|
|
|
|
if(data.activityId!=null){ |
|
|
|
|
body=<Col> |
|
|
|
|
<div> |
|
|
|
|
<h5 className="text-center">{data.activity.title}</h5> |
|
|
|
|
<h5 className="text-center">{data.title}</h5> |
|
|
|
|
</div> |
|
|
|
|
<div> |
|
|
|
|
<p className="text-ellipsis leave-word-height">{data.activity.content}</p> |
|
|
|
|
<p className="text-ellipsis leave-word-height">{data.content}</p> |
|
|
|
|
</div> |
|
|
|
|
<div className="text-center"> |
|
|
|
|
<Button variant={"primary"} onClick={()=>this.setState({openActivity:true,activity:data.activity})}>查看活动详情</Button> |
|
|
|
|
<Button variant={"primary"} onClick={()=>this.setState({activityId:data.activityId})}>查看活动详情</Button> |
|
|
|
|
</div> |
|
|
|
|
</Col> |
|
|
|
|
}else{ |
|
|
|
@ -123,7 +105,7 @@ export class MyLeaveWord extends React.Component<{ user:string }, |
|
|
|
|
<h5>~</h5> |
|
|
|
|
</div> |
|
|
|
|
<div> |
|
|
|
|
<p className="text-ellipsis leave-word-height">{data.user.info}</p> |
|
|
|
|
<p className="text-ellipsis leave-word-height">{data.info}</p> |
|
|
|
|
</div> |
|
|
|
|
<div className="text-center"> |
|
|
|
|
<Button variant={"primary"} className="mr-2">同意</Button> |
|
|
|
@ -141,12 +123,12 @@ export class MyLeaveWord extends React.Component<{ user:string }, |
|
|
|
|
</Row> |
|
|
|
|
<Row> |
|
|
|
|
<Col xs={3}> |
|
|
|
|
<Image src={data.user.headImg} className="leave-word-headImg"/> |
|
|
|
|
<span className="text-center user-name ml-3">{data.user.name}</span> |
|
|
|
|
<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.user.userId})}/> |
|
|
|
|
<Image src="user.svg" className="ml-1 mb-1 userIcon" onClick={()=>this.setState({openUserInfo:true,userId:data.userId})}/> |
|
|
|
|
</Tooltip>:null} |
|
|
|
|
</Col> |
|
|
|
|
{body} |
|
|
|
@ -160,14 +142,14 @@ export class MyLeaveWord extends React.Component<{ user:string }, |
|
|
|
|
render() { |
|
|
|
|
return ( |
|
|
|
|
<div className="overflow-auto my-leave-world-height"> |
|
|
|
|
{this.state.data.map((data,index) =>this.getData(data,index))} |
|
|
|
|
{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})}/> |
|
|
|
|
|
|
|
|
|
{this.state.activity?<MyDialog content={<Activity activity={this.state.activity} showButton={false} />} |
|
|
|
|
open={this.state.openActivity} titleId="view-activity" menuName="活动详情" |
|
|
|
|
onClose={()=>this.setState({activity:undefined,openActivity:false})}/>:null} |
|
|
|
|
<MyDialog content={<Activity activityId={this.state.activityId} showButton={false} />} |
|
|
|
|
open={this.state.activityId!=null} titleId="view-activity" menuName="活动详情" |
|
|
|
|
onClose={()=>this.setState({activityId:null})}/> |
|
|
|
|
</div> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|