|
|
|
@ -1,88 +1,147 @@ |
|
|
|
|
import React from "react"; |
|
|
|
|
import {Button, Col, Container, Image, Row} from "react-bootstrap"; |
|
|
|
|
import {MyHelpState} from "../entity"; |
|
|
|
|
import {ActivityStatus, HelpEntity, PageProps} from "../entity"; |
|
|
|
|
import moment from "moment"; |
|
|
|
|
import {myActivityObj} from "../ui/TestData"; |
|
|
|
|
import {API, JSONResponse, Method, prefix, request} from "../interface"; |
|
|
|
|
import {EmptyBodyTransform, HelpRes, HelpTransform, PageDataMessage, SimpleMessage} from "../result"; |
|
|
|
|
import {MyDialog} from "../ui/MyDialog"; |
|
|
|
|
import {changeActivity} from "../public"; |
|
|
|
|
import {Input} from "../ui/InputGroup"; |
|
|
|
|
|
|
|
|
|
const classList="border-info border d-flex justify-content-center align-items-center" |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 我的帮助 |
|
|
|
|
*/ |
|
|
|
|
export class MyHelp extends React.Component<{ undefined?:undefined }, { data:Array<MyHelpState> }>{ |
|
|
|
|
export class MyHelp extends React.Component<{ undefined?:undefined }, |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
data?:Array<HelpEntity>, |
|
|
|
|
page?:PageProps , |
|
|
|
|
result:JSX.Element|null, |
|
|
|
|
//活动评价
|
|
|
|
|
activeScore:number, |
|
|
|
|
historyId:number|null; |
|
|
|
|
}>{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(props: Readonly<any>) { |
|
|
|
|
super(props); |
|
|
|
|
|
|
|
|
|
this.state= { |
|
|
|
|
data: [] |
|
|
|
|
activeScore: 5, |
|
|
|
|
result:null, |
|
|
|
|
historyId:null |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
componentDidMount() { |
|
|
|
|
this.loadMyHelp() |
|
|
|
|
this.loadMyHelp(1) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 完成活动 |
|
|
|
|
* @param help |
|
|
|
|
*/ |
|
|
|
|
complete(help:MyHelpState){ |
|
|
|
|
|
|
|
|
|
score(){ |
|
|
|
|
let that=this |
|
|
|
|
request(API.main.activity.score,Method.POST ,{ |
|
|
|
|
score:this.state.activeScore+"", |
|
|
|
|
historyId:this.state.historyId+"" |
|
|
|
|
},new EmptyBodyTransform(),function (res:JSONResponse<SimpleMessage>) { |
|
|
|
|
switch (res.customResult) { |
|
|
|
|
case SimpleMessage.ok: |
|
|
|
|
that.setState({ |
|
|
|
|
historyId:null, |
|
|
|
|
result:<h3 className="text-center text-info">活动评价成功</h3> |
|
|
|
|
}) |
|
|
|
|
that.loadMyHelp(1) |
|
|
|
|
break |
|
|
|
|
case SimpleMessage.fail: |
|
|
|
|
that.setState({ |
|
|
|
|
result:<h3 className="text-center text-danger">活动评价失败,请联系管理员</h3> |
|
|
|
|
}) |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 参与活动 |
|
|
|
|
* @param help |
|
|
|
|
*/ |
|
|
|
|
join(help:MyHelpState){ |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取操作布局 |
|
|
|
|
* @param help |
|
|
|
|
*/ |
|
|
|
|
getAction(help:MyHelpState){ |
|
|
|
|
if(help.joinTime&&help.completeTime){ |
|
|
|
|
getAction(help:HelpEntity){ |
|
|
|
|
if(help.activityScore){ |
|
|
|
|
return (<Row> |
|
|
|
|
<Col className={classList}>已评价</Col> |
|
|
|
|
<Col className={classList}/> |
|
|
|
|
<Col className={classList}>{help.activityScore}</Col> |
|
|
|
|
</Row>) |
|
|
|
|
} |
|
|
|
|
else if(help.joinTime&&help.completeTime){ |
|
|
|
|
return (<Row> |
|
|
|
|
<Col className={classList}>已完成</Col> |
|
|
|
|
<Col className={classList+" p-3"}> |
|
|
|
|
<Button className="w-100" onClick={()=>this.setState({historyId:help.historyId})}>评价活动</Button> |
|
|
|
|
</Col> |
|
|
|
|
<Col className={classList}/> |
|
|
|
|
<Col className={classList}>{help.score}</Col> |
|
|
|
|
</Row>) |
|
|
|
|
}else if(help.joinTime){ |
|
|
|
|
return (<Row> |
|
|
|
|
<Col className={classList}>待完成</Col> |
|
|
|
|
<Col className={classList+" p-3"}><Button className="w-100" onClick={()=>this.complete(help)} variant={"info"}>完成</Button></Col> |
|
|
|
|
<Col className={classList}>{help.hasEnd?"已超时":"待完成"}</Col> |
|
|
|
|
<Col className={classList+" p-3"}> |
|
|
|
|
{help.hasEnd?null: |
|
|
|
|
<Button className="w-100" onClick={()=>{ |
|
|
|
|
let that=this |
|
|
|
|
changeActivity(help.activityId,ActivityStatus.complete, this,function () { |
|
|
|
|
that.loadMyHelp(1) |
|
|
|
|
}) |
|
|
|
|
}} variant={"info"}>完成</Button>}</Col> |
|
|
|
|
<Col className={classList}/> |
|
|
|
|
</Row>) |
|
|
|
|
}else{ |
|
|
|
|
return ( |
|
|
|
|
<Row> |
|
|
|
|
<Col className={classList}>待参与</Col> |
|
|
|
|
<Col className={classList+" p-3"}><Button className="w-100" onClick={()=>this.join(help)} variant={"info"}>参与</Button></Col> |
|
|
|
|
<Col className={classList}>{help.hasStart?"待参与":"待活动开始"}</Col> |
|
|
|
|
<Col className={classList+" p-3"}> |
|
|
|
|
{help.hasStart? |
|
|
|
|
<Button className="w-100" onClick={()=> { |
|
|
|
|
let that=this |
|
|
|
|
changeActivity(help.activityId,ActivityStatus.join, this,function () { |
|
|
|
|
that.loadMyHelp(1) |
|
|
|
|
}) |
|
|
|
|
}} variant={"info"}>参与</Button>:null} |
|
|
|
|
</Col> |
|
|
|
|
<Col className={classList}/> |
|
|
|
|
</Row> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
loadMyHelp(){ |
|
|
|
|
this.setState({ |
|
|
|
|
data:[myActivityObj,myActivityObj,myActivityObj] |
|
|
|
|
loadMyHelp(page:number){ |
|
|
|
|
let that=this |
|
|
|
|
request(API.main.activity.myHelp+"?currentPage="+page,Method.GET,{},new HelpTransform(),function (res:HelpRes) { |
|
|
|
|
switch (res.customResult) { |
|
|
|
|
case PageDataMessage.ok: |
|
|
|
|
that.setState({ |
|
|
|
|
data:res.dataList |
|
|
|
|
}) |
|
|
|
|
break |
|
|
|
|
case PageDataMessage.fail: |
|
|
|
|
that.setState({ |
|
|
|
|
result:<h3 className="text-center text-danger">帮助信息加载失败,请联系管理员</h3> |
|
|
|
|
}) |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
|
return ( |
|
|
|
|
<div className="overflow-auto my-help-height"> |
|
|
|
|
{this.state.data.map((help:MyHelpState,index:number)=> |
|
|
|
|
<div className="overflow-auto my-help-height w-100"> |
|
|
|
|
{this.state.data?this.state.data.length===0?<h3 className="text-info text-center">没有找到帮助记录</h3>:this.state.data.map((help:HelpEntity,index:number)=> |
|
|
|
|
<div key={"list"+index} className="mt-3 mb-3 border-info border"> |
|
|
|
|
<Container> |
|
|
|
|
<Row> |
|
|
|
|
<Col xs={4}> |
|
|
|
|
<Image src={help.activityImg} className="activityImage"/> |
|
|
|
|
<Image src={prefix.image+help.activityImg} className="activityImage"/> |
|
|
|
|
</Col> |
|
|
|
|
<Col> |
|
|
|
|
<h5>{help.title}</h5> |
|
|
|
@ -117,7 +176,25 @@ export class MyHelp extends React.Component<{ undefined?:undefined }, { data:Arr |
|
|
|
|
{this.getAction(help)} |
|
|
|
|
</Container> |
|
|
|
|
</div> |
|
|
|
|
)} |
|
|
|
|
):<h3 className="text-center text-info">帮助信息加载中</h3>} |
|
|
|
|
|
|
|
|
|
<MyDialog content={this.state.result} open={this.state.result!==null} titleId="my_help_dialog" menuName="提示" onClose={()=>this.setState({ |
|
|
|
|
result:null |
|
|
|
|
})}/> |
|
|
|
|
|
|
|
|
|
<MyDialog content={ |
|
|
|
|
<div> |
|
|
|
|
<Input name="activeScore" type={"number"} value={this.state.activeScore+""} desc="评分" placeholder={"请输入评分(0-10)"} onChange={(value:string)=>{ |
|
|
|
|
if(+value<0||+value>10){ |
|
|
|
|
value="5" |
|
|
|
|
} |
|
|
|
|
this.setState({ |
|
|
|
|
activeScore:+value |
|
|
|
|
}) |
|
|
|
|
}}/> |
|
|
|
|
|
|
|
|
|
<Button variant={"info"} block={true} className="col-3 ml-auto mr-auto mt-3" onClick={()=>this.score()}>评价</Button> |
|
|
|
|
</div>} open={this.state.historyId!==null} titleId="score-dialog" menuName="评分" onClose={()=>this.setState({historyId:null})}/> |
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
|
) |
|
|
|
|