|
|
|
@ -2,10 +2,13 @@ import React from "react"; |
|
|
|
|
import {Button, Card, Col, Container, ListGroup, Row} from "react-bootstrap"; |
|
|
|
|
|
|
|
|
|
import {Page} from "../ui/Page"; |
|
|
|
|
import {ActivityDetail, BaseHelp, PageProps} from "../entity"; |
|
|
|
|
import {ActivityDetail, PageProps} from "../entity"; |
|
|
|
|
import {MyDialog} from "../ui/MyDialog"; |
|
|
|
|
import {Activity} from "../ui/Activity"; |
|
|
|
|
import {Input} from "../ui/InputGroup"; |
|
|
|
|
import {activityObj} from "../ui/TestData"; |
|
|
|
|
import {API, Method, request} from "../interface"; |
|
|
|
|
import {FindActivityMessage, FindActivityRes, FindActivityTransform} from "../result"; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 首页 |
|
|
|
@ -13,15 +16,16 @@ import {Input} from "../ui/InputGroup"; |
|
|
|
|
export class IndexMenu extends React.Component<{ user:string }, |
|
|
|
|
{ |
|
|
|
|
//活动数据
|
|
|
|
|
activityList:Array<Array<BaseHelp>>; |
|
|
|
|
activityList?:Array<Array<ActivityDetail>>; |
|
|
|
|
//分页信息
|
|
|
|
|
page:PageProps; |
|
|
|
|
page?:PageProps; |
|
|
|
|
//活动
|
|
|
|
|
activity?:ActivityDetail; |
|
|
|
|
//打开活动
|
|
|
|
|
openActivity:boolean; |
|
|
|
|
//检索活动标题
|
|
|
|
|
title:string; |
|
|
|
|
result:JSX.Element|null; |
|
|
|
|
}>{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -30,13 +34,7 @@ export class IndexMenu extends React.Component<{ user:string }, |
|
|
|
|
super(props); |
|
|
|
|
|
|
|
|
|
this.state={ |
|
|
|
|
activityList:[], |
|
|
|
|
page:{ |
|
|
|
|
currentPage:1, |
|
|
|
|
totalPage:3, |
|
|
|
|
pageSize:9 |
|
|
|
|
}, |
|
|
|
|
openActivity:false, |
|
|
|
|
result: null,openActivity:false, |
|
|
|
|
title:"" |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -58,14 +56,8 @@ export class IndexMenu extends React.Component<{ user:string }, |
|
|
|
|
* @param activityId |
|
|
|
|
*/ |
|
|
|
|
loadActivityWithId(activityId:number):ActivityDetail{ |
|
|
|
|
return { |
|
|
|
|
activityId:123, |
|
|
|
|
activityImg:"logo512.png", |
|
|
|
|
content: "活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容", |
|
|
|
|
title: "标题标题标题标题标题标题标题", |
|
|
|
|
activityEndTime:new Date().getTime(), |
|
|
|
|
activityStartTime:new Date().getTime() |
|
|
|
|
} |
|
|
|
|
console.debug("activityId="+activityId) |
|
|
|
|
return activityObj |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -74,68 +66,35 @@ export class IndexMenu extends React.Component<{ user:string }, |
|
|
|
|
*/ |
|
|
|
|
loadActivity(page:number){ |
|
|
|
|
console.debug("检索活动关键字:"+this.state.title) |
|
|
|
|
|
|
|
|
|
this.setState({ |
|
|
|
|
activityList:[[{ |
|
|
|
|
activityId: 123, |
|
|
|
|
//活动标题
|
|
|
|
|
title: "活动标题", |
|
|
|
|
//活动内容
|
|
|
|
|
content: "活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容", |
|
|
|
|
//活动图片
|
|
|
|
|
activityImg: "/logo512.png" |
|
|
|
|
},{ |
|
|
|
|
activityId: 123, |
|
|
|
|
//活动标题
|
|
|
|
|
title: "活动标题", |
|
|
|
|
//活动内容
|
|
|
|
|
content: "活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容", |
|
|
|
|
//活动图片
|
|
|
|
|
activityImg: "/logo512.png" |
|
|
|
|
},{ |
|
|
|
|
activityId: 123, |
|
|
|
|
//活动标题
|
|
|
|
|
title: "活动标题", |
|
|
|
|
//活动内容
|
|
|
|
|
content: "活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容", |
|
|
|
|
//活动图片
|
|
|
|
|
activityImg: "/logo512.png" |
|
|
|
|
}],[{ |
|
|
|
|
activityId: 123, |
|
|
|
|
//活动标题
|
|
|
|
|
title: "活动标题", |
|
|
|
|
//活动内容
|
|
|
|
|
content: "活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容", |
|
|
|
|
//活动图片
|
|
|
|
|
activityImg: "/logo512.png" |
|
|
|
|
},{ |
|
|
|
|
activityId: 123, |
|
|
|
|
//活动标题
|
|
|
|
|
title: "活动标题", |
|
|
|
|
//活动内容
|
|
|
|
|
content: "活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容", |
|
|
|
|
//活动图片
|
|
|
|
|
activityImg: "/logo512.png" |
|
|
|
|
},{ |
|
|
|
|
activityId: 123, |
|
|
|
|
//活动标题
|
|
|
|
|
title: "活动标题", |
|
|
|
|
//活动内容
|
|
|
|
|
content: "活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容", |
|
|
|
|
//活动图片
|
|
|
|
|
activityImg: "/logo512.png" |
|
|
|
|
}]] |
|
|
|
|
let that=this |
|
|
|
|
request(API.main.activity.find,Method.GET,{ |
|
|
|
|
title:this.state.title, |
|
|
|
|
currentPage:page+"" |
|
|
|
|
},new FindActivityTransform(),function (res:FindActivityRes) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(res.customResult){ |
|
|
|
|
case FindActivityMessage.fail: |
|
|
|
|
that.setState({ |
|
|
|
|
result:<h3 className="text-danger text-center">活动加载失败,请联系管理员</h3> |
|
|
|
|
});break; |
|
|
|
|
case FindActivityMessage.ok: |
|
|
|
|
that.setState({ |
|
|
|
|
activityList:res.dataList, |
|
|
|
|
page:res.page |
|
|
|
|
});break |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
|
const rowList=this.state.activityList.map((activities:Array<BaseHelp>, index:number)=> |
|
|
|
|
<Row className="p-3" key={"row"+index}>{activities.map((activity:BaseHelp, subIndex:number)=> |
|
|
|
|
const rowList=this.state.activityList?this.state.activityList.map((activities:Array<ActivityDetail>, index:number)=> |
|
|
|
|
<Row className="p-3" key={"row"+index}>{activities.map((activity:ActivityDetail, subIndex:number)=> |
|
|
|
|
<Col className="col-4" key={"col"+subIndex}> |
|
|
|
|
<Card> |
|
|
|
|
<Card.Header> |
|
|
|
|
<img src={activity.activityImg} alt="活动图片" className="activityImage"/> |
|
|
|
|
<img src={"/image/"+activity.activityImg} alt="活动图片" className="activityImage"/> |
|
|
|
|
</Card.Header> |
|
|
|
|
<Card.Body> |
|
|
|
|
<ListGroup> |
|
|
|
@ -157,7 +116,7 @@ export class IndexMenu extends React.Component<{ user:string }, |
|
|
|
|
</Card> |
|
|
|
|
</Col>)} |
|
|
|
|
</Row> |
|
|
|
|
) |
|
|
|
|
):null |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
|
@ -172,13 +131,14 @@ export class IndexMenu extends React.Component<{ user:string }, |
|
|
|
|
|
|
|
|
|
{rowList} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Page onClick={(page:number)=>this.loadActivity(page)} currentPage={this.state.page.currentPage} totalPage={this.state.page.totalPage} pageSize={this.state.page.pageSize}/> |
|
|
|
|
{this.state.page?<Page onClick={(page:number)=>this.loadActivity(page)} currentPage={this.state.page.currentPage} totalPage={this.state.page.totalPage} pageSize={this.state.page.pageSize}/>:null} |
|
|
|
|
|
|
|
|
|
{this.state.activity?<MyDialog content={<Activity activity={this.state.activity} showButton={true} applyFunction={(activeId:number)=>this.applyActivity(activeId)} />} |
|
|
|
|
open={this.state.openActivity} titleId="view-active" menuName="活动详情" |
|
|
|
|
onClose={()=>this.setState({activity:undefined,openActivity:false})}/>:null} |
|
|
|
|
|
|
|
|
|
<MyDialog content={this.state.result} open={this.state.result!==null} titleId="find-activity-tip" menuName="发布求助信息反馈" onClose={()=>this.setState({result:null})}/> |
|
|
|
|
|
|
|
|
|
</Container> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|