活动报名接口对接

master
pan 5 years ago
parent e91f3d26de
commit 0a23d09ce4
  1. 26
      src/App.tsx
  2. 37
      src/Main.tsx
  3. 1
      src/account/PropCookie.ts
  4. 6
      src/account/Register.tsx
  5. 11
      src/entity.ts
  6. 9
      src/interface.ts
  7. 73
      src/my/MyHelp.tsx
  8. 15
      src/my/MyLeaveWord.tsx
  9. 27
      src/my/SeekHelp.tsx
  10. 133
      src/result.ts
  11. 49
      src/sub/IndexMenu.tsx
  12. 10
      src/sub/SendHelp.tsx
  13. 8
      src/sub/Volunteer.tsx
  14. 27
      src/ui/TestData.ts

@ -5,11 +5,18 @@ import {Login} from './account/Login';
import {Cookies, withCookies} from 'react-cookie'; import {Cookies, withCookies} from 'react-cookie';
import {Main} from "./Main"; import {Main} from "./Main";
import {Register} from "./account/Register"; import {Register} from "./account/Register";
import {user_cookie, user_type_cookie} from "./account/PropCookie"; import {user_cookie, user_type_cookie, welcome_cookie} from "./account/PropCookie";
import {UserType} from "./entity"; import {UserType} from "./entity";
class App extends React.Component<{ allCookies:any;cookies:Cookies }, class App extends React.Component<
{ page?:JSX.Element;}> { {
allCookies:any;
cookies:Cookies
},
{
page?:JSX.Element;
welcome?:boolean;
}> {
constructor(props: Readonly<any>) { constructor(props: Readonly<any>) {
@ -20,10 +27,13 @@ class App extends React.Component<{ allCookies:any;cookies:Cookies },
} }
componentDidMount() { componentDidMount() {
const { cookies } = this.props if((this.props.cookies.get(user_cookie)||"").length>0){
if((cookies.get(user_cookie)||"").length>0){
this.setState({ this.setState({
page:<Main userType={cookies.get(user_type_cookie)} user={cookies.get(user_cookie)} logout={()=>this.logout()} /> welcome:this.props.cookies.get(welcome_cookie)!==undefined
})
this.setState({
page:<Main cookies={this.props.cookies} logout={()=>this.logout()}/>
}) })
}else{ }else{
this.toLogin() this.toLogin()
@ -33,6 +43,7 @@ class App extends React.Component<{ allCookies:any;cookies:Cookies },
//注销登录 //注销登录
logout(){ logout(){
this.props.cookies.remove(user_cookie) this.props.cookies.remove(user_cookie)
this.props.cookies.remove(user_type_cookie)
this.toLogin() this.toLogin()
} }
@ -53,8 +64,9 @@ class App extends React.Component<{ allCookies:any;cookies:Cookies },
page:<Login toRegister={()=>this.toRegister()} onLoginSuccess={(userId:string,userType:UserType)=> { page:<Login toRegister={()=>this.toRegister()} onLoginSuccess={(userId:string,userType:UserType)=> {
this.props.cookies.set(user_cookie,userId) this.props.cookies.set(user_cookie,userId)
this.props.cookies.set(user_type_cookie,userType) this.props.cookies.set(user_type_cookie,userType)
this.props.cookies.set(welcome_cookie,userId)
this.setState({ this.setState({
page:<Main logout={()=>this.logout()} user={userId} userType={userType}/> page:<Main logout={()=>this.logout()} cookies={this.props.cookies}/>
}) })
}}/> }}/>
}) })

@ -8,6 +8,8 @@ import {MyDialog} from "./ui/MyDialog";
import {MyLeaveWord} from "./my/MyLeaveWord"; import {MyLeaveWord} from "./my/MyLeaveWord";
import {MyMessage} from "./my/MyMessage"; import {MyMessage} from "./my/MyMessage";
import {User, UserEdit, UserType} from "./entity"; import {User, UserEdit, UserType} from "./entity";
import {Cookies} from "react-cookie";
import {user_cookie, user_type_cookie, welcome_cookie} from "./account/PropCookie";
/** /**
* *
@ -31,10 +33,12 @@ enum DialogType {
* *
*/ */
export class Main extends React.Component< export class Main extends React.Component<
{
logout:Function;
//
cookies:Cookies;
},
{ user:string;
userType?:string;
logout:Function;},
{ {
//菜单 //菜单
menu:Menu; menu:Menu;
@ -49,7 +53,8 @@ export class Main extends React.Component<
}, },
//用户身份 //用户身份
userType?:string; userType?:string;
result:boolean //显示欢迎信息
result:boolean;
} }
>{ >{
@ -57,15 +62,15 @@ export class Main extends React.Component<
super(props); super(props);
//默认菜单 //默认菜单
this.state={ this.state={
result: true,
//一级菜单 //一级菜单
menu:Menu.index, menu:Menu.index,
//二级菜单 //二级菜单
subMenu:<IndexMenu user={this.props.user}/>, subMenu:<IndexMenu user={this.props.cookies.get(user_cookie)}/>,
//我的好友信息 //我的好友信息
friendList:[], friendList:[],
//我的菜单 //我的菜单
my:{menuName: "",content:null,open:false} my:{menuName: "",content:null,open:false},
result:Boolean(this.props.cookies.get(welcome_cookie))
} }
} }
@ -96,7 +101,7 @@ export class Main extends React.Component<
switch (menu) { switch (menu) {
case Menu.index: case Menu.index:
this.setState({ this.setState({
subMenu:<IndexMenu user={this.props.user}/> subMenu:<IndexMenu user={this.props.cookies.get(user_cookie)}/>
});break; });break;
case Menu.volunteer: case Menu.volunteer:
this.setState({ this.setState({
@ -131,17 +136,18 @@ export class Main extends React.Component<
switch (dialogType) { switch (dialogType) {
case DialogType.friend: case DialogType.friend:
this.setState({ this.setState({
my:{menuName:dialogType,content:<MyFriend user={this.props.user}/>,open:true} my:{menuName:dialogType,content:<MyFriend user={this.props.cookies.get(user_cookie)}/>,open:true}
}) })
break; break;
case DialogType.leaveWord: case DialogType.leaveWord:
this.setState({ this.setState({
my:{menuName:dialogType,content:<MyLeaveWord user={this.props.user}/>,open:true} my:{menuName:dialogType,content:<MyLeaveWord user={this.props.cookies.get(user_cookie)}/>,open:true}
}) })
break; break;
case DialogType.message: case DialogType.message:
this.setState({ this.setState({
my:{menuName:dialogType,content:<MyMessage onUserUpdate={(user:UserEdit)=>this.setState({userType:user.userType})} user={this.props.user}/>,open:true} my:{menuName:dialogType,content:<MyMessage onUserUpdate={(user:UserEdit)=>this.setState({userType:user.userType})}
user={this.props.cookies.get(user_cookie)}/>,open:true}
}) })
break; break;
} }
@ -166,7 +172,7 @@ export class Main extends React.Component<
<Dropdown> <Dropdown>
<Dropdown.Toggle variant="secondary" id="dropdown-basic"> <Dropdown.Toggle variant="secondary" id="dropdown-basic">
{this.props.user} {this.props.cookies.get(user_cookie)}
</Dropdown.Toggle> </Dropdown.Toggle>
<Dropdown.Menu> <Dropdown.Menu>
@ -178,14 +184,17 @@ export class Main extends React.Component<
{(this.state.userType||this.props.userType)?<Navbar.Brand className="ml-3">{(this.state.userType||this.props.userType)===UserType.help.toString()?"等待接受帮助":"等待前往帮助"}</Navbar.Brand>:null} {(this.state.userType||this.props.cookies.get(user_type_cookie))?<Navbar.Brand className="ml-3">{(this.state.userType||this.props.cookies.get(user_type_cookie))===UserType.help.toString()?"等待接受帮助":"等待前往帮助"}</Navbar.Brand>:null}
<MyDialog titleId="my-dialog" menuName={this.state.my.menuName} content={this.state.my.content} open={this.state.my.open} onClose={()=>this.closeDialog()}/> <MyDialog titleId="my-dialog" menuName={this.state.my.menuName} content={this.state.my.content} open={this.state.my.open} onClose={()=>this.closeDialog()}/>
</Nav> </Nav>
</Navbar> </Navbar>
<MyDialog content={<h1 className="text-info text-center">{this.props.user}</h1>} open={this.state.result} titleId="login-tip" menuName="登录提示" onClose={()=>this.setState({result:false})}/> <MyDialog content={<h1 className="text-info text-center">{this.props.cookies.get(user_cookie)}</h1>} open={this.state.result} titleId="login-tip" menuName="登录提示" onClose={()=>{
this.setState({result:false})
this.props.cookies.remove(welcome_cookie)
}}/>
{this.state.subMenu} {this.state.subMenu}
</div> </div>

@ -4,3 +4,4 @@
*/ */
export const user_cookie="user_cookie" export const user_cookie="user_cookie"
export const user_type_cookie="user_type_cookie" export const user_type_cookie="user_type_cookie"
export const welcome_cookie="welcome_cookie"

@ -4,8 +4,8 @@ import {Button, Form} from 'react-bootstrap'
import {RegisterProps, RegisterState, UserType} from "../entity"; import {RegisterProps, RegisterState, UserType} from "../entity";
import {UploadImg} from "../ui/UploadImg"; import {UploadImg} from "../ui/UploadImg";
import {Address} from "../ui/Address"; import {Address} from "../ui/Address";
import {API, Method, request} from "../interface" import {API, JSONResponse, Method, request} from "../interface"
import {RegisterMessage, RegisterRes, RegisterTransform} from "../result"; import {RegisterMessage, RegisterTransform} from "../result";
import {MyDialog} from "../ui/MyDialog"; import {MyDialog} from "../ui/MyDialog";
/** /**
@ -57,7 +57,7 @@ export class Register extends React.Component<RegisterProps, RegisterState>{
email:this.state.email, email:this.state.email,
info:this.state.info info:this.state.info
},new RegisterTransform(),function(res:RegisterRes){ },new RegisterTransform(),function(res:JSONResponse<RegisterMessage>){
let message let message
switch (res.customResult) { switch (res.customResult) {
case RegisterMessage.ok:message="注册成功"; case RegisterMessage.ok:message="注册成功";

@ -63,6 +63,8 @@ export interface ActivityId {
//活动详情 //活动详情
export interface ActivityDetail extends BaseHelp,ActivityId{ export interface ActivityDetail extends BaseHelp,ActivityId{
//用户id
userId:string;
//活动开始时间 //活动开始时间
activityStartTime:number; activityStartTime:number;
//活动结束时间 //活动结束时间
@ -308,3 +310,12 @@ export interface LoginState{
// //
result:JSX.Element|null result:JSX.Element|null
} }
/**
*
*/
export enum VolunteerStatus {
apply = "apply",
join = "join",
complete = "complete"
}

@ -22,7 +22,9 @@ export const API={
//发布求助信息 //发布求助信息
help: prefix.activity + "/sendHelp", help: prefix.activity + "/sendHelp",
//查找活动列表 //查找活动列表
find: prefix.activity + "/find" find: prefix.activity + "/find",
//报名活动
apply:prefix.activity+ "/apply"
} }
} }
} }
@ -42,7 +44,7 @@ export enum Result {
/** /**
* *
*/ */
export abstract class JSONResponse<Q> { export class JSONResponse<Q> {
result?:Result result?:Result
customResult?:Q customResult?:Q
} }
@ -93,7 +95,8 @@ export function request<Q,E extends JSONResponse<Q>,T extends TransformData<Q,E>
} }
fetch(server+api,{ fetch(server+api,{
method:method, method:method,
body:formData body:formData,
credentials: 'include',
}) })
.then( .then(
response=>{if(response.status===200){ response=>{if(response.status===200){

@ -2,6 +2,7 @@ import React from "react";
import {Button, Col, Container, Image, Row} from "react-bootstrap"; import {Button, Col, Container, Image, Row} from "react-bootstrap";
import {MyHelpState} from "../entity"; import {MyHelpState} from "../entity";
import moment from "moment"; import moment from "moment";
import {myActivityObj} from "../ui/TestData";
const classList="border-info border d-flex justify-content-center align-items-center" const classList="border-info border d-flex justify-content-center align-items-center"
@ -69,77 +70,7 @@ export class MyHelp extends React.Component<{ undefined?:undefined }, { data:Arr
loadMyHelp(){ loadMyHelp(){
this.setState({ this.setState({
data:[{ data:[myActivityObj,myActivityObj,myActivityObj]
//活动Id
activityId:123,
//活动标题
title:"活动标题",
//活动内容
content:"活动内容",
//活动背景图
activityImg: "logo512.png",
//求助时间
seekHelpTime:new Date().getTime(),
//活动开始时间
activityStartTime:new Date().getTime(),
//活动结束时间
activityEndTime:new Date().getTime(),
//报名时间
applyTime:new Date().getTime(),
//参与时间
joinTime:new Date().getTime(),
//完成时间
completeTime:new Date().getTime(),
//活动评价分
score: Math.ceil(Math.random()*10),
},
{
//活动Id
activityId:123,
//活动标题
title:"活动标题",
//活动内容
content:"活动内容",
//活动背景图
activityImg: "logo512.png",
//求助时间
seekHelpTime:new Date().getTime(),
//活动开始时间
activityStartTime:new Date().getTime(),
//活动结束时间
activityEndTime:new Date().getTime(),
//报名时间
applyTime:new Date().getTime(),
//参与时间
joinTime:null,
//完成时间
completeTime:new Date().getTime(),
//活动评价分
score: Math.ceil(Math.random()*10),
},{
//活动Id
activityId:123,
//活动标题
title:"活动标题",
//活动内容
content:"活动内容",
//活动背景图
activityImg: "logo512.png",
//求助时间
seekHelpTime:new Date().getTime(),
//活动开始时间
activityStartTime:new Date().getTime(),
//活动结束时间
activityEndTime:new Date().getTime(),
//报名时间
applyTime:new Date().getTime(),
//参与时间
joinTime:new Date().getTime(),
//完成时间
completeTime:null,
//活动评价分
score: Math.ceil(Math.random()*10),
}]
}) })
} }

@ -8,11 +8,16 @@ import {Activity} from "../ui/Activity";
import {activityObj, userObj} from "../ui/TestData"; import {activityObj, userObj} from "../ui/TestData";
enum LeaveWordType { enum LeaveWordType {
recommend, //推荐
apply, recommend="recommend",
join, //报名
complete, apply="apply",
friend //参与
join="join",
//完成
complete="complete",
//好友验证
friend="friend"
} }
interface Type1{ interface Type1{

@ -1,6 +1,6 @@
import React from "react"; import React from "react";
import {Button, ButtonGroup, Col, Container, Image, ListGroup, Row} from "react-bootstrap"; import {Button, ButtonGroup, Col, Container, Image, ListGroup, Row} from "react-bootstrap";
import {SeekHelpState, User} from "../entity"; import {SeekHelpState, User, VolunteerStatus} from "../entity";
import moment from "moment"; import moment from "moment";
import Dialog from "@material-ui/core/Dialog"; import Dialog from "@material-ui/core/Dialog";
import {CloseDialog} from "../ui/CloseDialog"; import {CloseDialog} from "../ui/CloseDialog";
@ -10,15 +10,6 @@ import {MyDialog} from "../ui/MyDialog";
import {MyInfo} from "./MyInfo"; import {MyInfo} from "./MyInfo";
import {userObj} from "../ui/TestData"; import {userObj} from "../ui/TestData";
/**
*
*/
enum VolunteerStatus {
apply="报名",
join="参加",
complete="完成"
}
const titleId="seek-help-dialog" const titleId="seek-help-dialog"
/** /**
@ -28,7 +19,7 @@ export class SeekHelp extends React.Component<{ user:string },
{ {
data:Array<SeekHelpState>; data:Array<SeekHelpState>;
open:boolean; open:boolean;
status?:VolunteerStatus; status?:string;
volunteerList?:Array<User>; volunteerList?:Array<User>;
openUserInfo:boolean; openUserInfo:boolean;
userId?:string; userId?:string;
@ -93,6 +84,14 @@ export class SeekHelp extends React.Component<{ user:string },
} }
getStatus(status:VolunteerStatus){
switch (status) {
case VolunteerStatus.apply:return "报名"
case VolunteerStatus.join:return "参加"
case VolunteerStatus.complete:return "完成"
}
}
render() { render() {
return ( return (
<div className="overflow-auto seek-help-height"> <div className="overflow-auto seek-help-height">
@ -114,9 +113,9 @@ export class SeekHelp extends React.Component<{ user:string },
</Col> </Col>
<Col> <Col>
<ButtonGroup> <ButtonGroup>
<Button variant={"primary"} disabled={help.applyVolunteerList.length===0} onClick={()=>this.setState({open:true,status:VolunteerStatus.apply,volunteerList:help.applyVolunteerList})}>:{help.applyVolunteerList.length}</Button> <Button variant={"primary"} disabled={help.applyVolunteerList.length===0} onClick={()=>this.setState({open:true,status:this.getStatus(VolunteerStatus.apply),volunteerList:help.applyVolunteerList})}>:{help.applyVolunteerList.length}</Button>
<Button variant={"success"} disabled={help.joinVolunteerList.length===0} onClick={()=>this.setState({open:true,status:VolunteerStatus.join,volunteerList:help.joinVolunteerList})}>:{help.joinVolunteerList.length}</Button> <Button variant={"success"} disabled={help.joinVolunteerList.length===0} onClick={()=>this.setState({open:true,status:this.getStatus(VolunteerStatus.join),volunteerList:help.joinVolunteerList})}>:{help.joinVolunteerList.length}</Button>
<Button variant={"light"} disabled={help.completeVolunteerList.length===0} onClick={()=>this.setState({open:true,status:VolunteerStatus.complete,volunteerList:help.completeVolunteerList})}>:{help.completeVolunteerList.length}</Button> <Button variant={"light"} disabled={help.completeVolunteerList.length===0} onClick={()=>this.setState({open:true,status:this.getStatus(VolunteerStatus.complete),volunteerList:help.completeVolunteerList})}>:{help.completeVolunteerList.length}</Button>
</ButtonGroup> </ButtonGroup>
</Col> </Col>
</Row> </Row>

@ -4,6 +4,27 @@
import {JSONResponse, Result, TransformData} from "./interface"; import {JSONResponse, Result, TransformData} from "./interface";
import {ActivityDetail, PageProps, User, UserType} from "./entity"; import {ActivityDetail, PageProps, User, UserType} from "./entity";
/**
* body响应
*/
export enum SimpleMessage {
//操作失败
ok="ok",
//操作成功
fail="fail"
}
/**
* body响应
*/
export class EmptyBodyTransform extends TransformData<SimpleMessage, JSONResponse<SimpleMessage>>{
protected newObject(): JSONResponse<SimpleMessage> {
return new JSONResponse<SimpleMessage>();
}
}
export abstract class EmptyBodyDiffMsg<T> extends TransformData<T, JSONResponse<T>>{}
/** /**
* *
*/ */
@ -18,21 +39,13 @@ export enum RegisterMessage {
form_parse_error = "form_parse_error" form_parse_error = "form_parse_error"
} }
/**
*
*/
export class RegisterRes implements JSONResponse<RegisterMessage> {
customResult?: RegisterMessage;
result?: Result;
}
/** /**
* *
*/ */
export class RegisterTransform extends TransformData<RegisterMessage, RegisterRes> { export class RegisterTransform extends EmptyBodyDiffMsg<RegisterMessage>{
protected newObject(): RegisterRes { protected newObject(): JSONResponse<RegisterMessage> {
return new RegisterRes(); return new JSONResponse<RegisterMessage>();
} }
} }
@ -74,59 +87,24 @@ export class LoginTransform extends TransformData<LoginResMessage,LoginRes>{
} }
} }
/**
*
*/
export enum ActivityMessage {
//发布成功
ok="ok",
//发布失败请联系管理员
fail="fail"
}
/**
*
*/
export class SendHelpRes extends JSONResponse<ActivityMessage>{
}
/**
*
*/
export class SendHelpTransform extends TransformData<ActivityMessage, SendHelpRes>{
protected newObject(): SendHelpRes {
return new SendHelpRes();
}
}
/** /**
* *
*/ */
export enum FindActivityMessage { export enum PageDataMessage {
ok="ok", ok="ok",
fail="fail", fail="fail",
// 空数据 //空数据
empty="empty" empty="empty"
} }
/** export abstract class PageDataRes extends JSONResponse<PageDataMessage>{
* dataList?:any;
*/ page?:PageProps;
export class FindActivityRes extends JSONResponse<FindActivityMessage>{
dataList?:Array<Array<ActivityDetail>>
page?:PageProps
} }
/** export abstract class PageDataTransform<T extends PageDataRes> extends TransformData<PageDataMessage, T>{
*
*/
export class FindActivityTransform extends TransformData<FindActivityMessage, FindActivityRes>{
protected newObject(): FindActivityRes {
return new FindActivityRes();
}
protected transformBody(data: any) { protected transformBody(data: any) {
if(data.body!==null){ if(data.body!==null){
@ -141,19 +119,29 @@ export class FindActivityTransform extends TransformData<FindActivityMessage, Fi
} }
} }
/** /**
* *
*/ */
export enum FindUserMessage { export class FindActivityRes extends PageDataRes{
ok="ok", dataList?:Array<Array<ActivityDetail>>
fail="fail", page?:PageProps
empty="empty"
} }
/**
*
*/
export class FindActivityTransform extends PageDataTransform<FindActivityRes>{
protected newObject(): FindActivityRes {
return new FindActivityRes();
}
}
/** /**
* *
*/ */
export class FindUserRes extends JSONResponse<FindUserMessage>{ export class FindUserRes extends PageDataRes{
dataList?:Array<Array<User>> dataList?:Array<Array<User>>
page?:PageProps page?:PageProps
} }
@ -161,42 +149,27 @@ export class FindUserRes extends JSONResponse<FindUserMessage>{
/** /**
* *
*/ */
export class FindUserTransform extends TransformData<FindUserMessage, FindUserRes>{ export class FindUserTransform extends PageDataTransform<FindUserRes>{
protected newObject(): FindUserRes { protected newObject(): FindUserRes {
return new FindUserRes(); return new FindUserRes();
} }
protected transformBody(data: any) {
if(data.body!==null){
this.target.dataList=data.body.body
this.target.page={
currentPage:data.body.currentPage,
totalPage:data.body.totalPage,
pageSize:data.body.pageSize
}
}
}
}
export enum ActivityDetailMessage {
ok="ok",
fail="fail"
} }
export class ActivityDetailRes extends JSONResponse<ActivityDetailMessage>{ export class ActivityDetailRes extends JSONResponse<SimpleMessage>{
activity?:ActivityDetail activity?:ActivityDetail
} }
export class ActivityDetailTransform extends TransformData<ActivityDetailMessage, ActivityDetailRes>{ export class ActivityDetailTransform extends TransformData<SimpleMessage, ActivityDetailRes>{
protected newObject(): ActivityDetailRes { protected newObject(): ActivityDetailRes {
return new ActivityDetailRes(); return new ActivityDetailRes();
} }
protected transformBody(data: any) { protected transformBody(data: any) {
this.target.activity=data.body this.target.activity=data.body
} }
} }

@ -2,18 +2,19 @@ import React from "react";
import {Button, Card, Col, Container, Image, ListGroup, Row} from "react-bootstrap"; import {Button, Card, Col, Container, Image, ListGroup, Row} from "react-bootstrap";
import {Page} from "../ui/Page"; import {Page} from "../ui/Page";
import {ActivityDetail, PageProps} from "../entity"; import {ActivityDetail, PageProps, VolunteerStatus} from "../entity";
import {MyDialog} from "../ui/MyDialog"; import {MyDialog} from "../ui/MyDialog";
import {Activity} from "../ui/Activity"; import {Activity} from "../ui/Activity";
import {Input} from "../ui/InputGroup"; import {Input} from "../ui/InputGroup";
import {API, Method, prefix, request} from "../interface"; import {API, JSONResponse, Method, prefix, request} from "../interface";
import { import {
ActivityDetailMessage,
ActivityDetailRes, ActivityDetailRes,
ActivityDetailTransform, ActivityDetailTransform,
FindActivityMessage, EmptyBodyTransform,
FindActivityRes, FindActivityRes,
FindActivityTransform FindActivityTransform,
PageDataMessage,
SimpleMessage
} from "../result"; } from "../result";
/** /**
@ -57,6 +58,32 @@ export class IndexMenu extends React.Component<{ user:string },
console.debug("报名活动"+activityId) console.debug("报名活动"+activityId)
} }
/**
*
* @param activityId id
*/
apply(activityId:number){
console.debug("报名id"+activityId)
let that=this
request(API.main.activity.apply,Method.POST,{
activityId:activityId+"",
activityStatus:VolunteerStatus.join.toString()
},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
}
})
}
/** /**
* *
* @param activityId * @param activityId
@ -67,11 +94,11 @@ export class IndexMenu extends React.Component<{ user:string },
let that=this let that=this
request(API.main.activity.find+"/"+activityId,Method.GET,{},new ActivityDetailTransform(),function(res:ActivityDetailRes){ request(API.main.activity.find+"/"+activityId,Method.GET,{},new ActivityDetailTransform(),function(res:ActivityDetailRes){
switch (res.customResult) { switch (res.customResult) {
case ActivityDetailMessage.fail: case SimpleMessage.fail:
that.setState({ that.setState({
result:<h3 className="text-danger text-center"></h3> result:<h3 className="text-danger text-center"></h3>
});break; });break;
case ActivityDetailMessage.ok: case SimpleMessage.ok:
that.setState({ that.setState({
openActivity:true, openActivity:true,
activity:res.activity activity:res.activity
@ -91,16 +118,16 @@ export class IndexMenu extends React.Component<{ user:string },
switch(res.customResult){ switch(res.customResult){
case FindActivityMessage.fail: case PageDataMessage.fail:
that.setState({ that.setState({
result:<h3 className="text-danger text-center"></h3> result:<h3 className="text-danger text-center"></h3>
});break; });break;
case FindActivityMessage.ok: case PageDataMessage.ok:
that.setState({ that.setState({
activityList:res.dataList, activityList:res.dataList,
page:res.page page:res.page
});break });break
case FindActivityMessage.empty: case PageDataMessage.empty:
that.setState({ that.setState({
page:res.page, page:res.page,
result:<h3 className="text-info text-center"></h3> result:<h3 className="text-info text-center"></h3>
@ -130,7 +157,7 @@ export class IndexMenu extends React.Component<{ user:string },
</Card.Body> </Card.Body>
<Card.Footer> <Card.Footer>
<Button variant={"info"} onClick={()=>this.loadActivityWithId(activity.activityId)} className="mr-2"></Button> <Button variant={"info"} onClick={()=>this.loadActivityWithId(activity.activityId)} className="mr-2"></Button>
<Button variant="primary" ></Button> <Button variant="primary" onClick={()=>this.apply(activity.activityId)}></Button>
</Card.Footer> </Card.Footer>
</Card> </Card>
</Col>)} </Col>)}

@ -8,8 +8,8 @@ import moment from 'moment';
import {Address} from "../ui/Address"; import {Address} from "../ui/Address";
import {UploadImg} from "../ui/UploadImg"; import {UploadImg} from "../ui/UploadImg";
import {userObj} from "../ui/TestData"; import {userObj} from "../ui/TestData";
import {API, Method, request} from "../interface" import {API, JSONResponse, Method, request} from "../interface"
import {ActivityMessage, SendHelpRes, SendHelpTransform} from "../result"; import {EmptyBodyTransform, SimpleMessage} from "../result";
import {MyDialog} from "../ui/MyDialog"; import {MyDialog} from "../ui/MyDialog";
/** /**
@ -91,13 +91,13 @@ export class SendHelp extends React.Component<{ onSendActivityOK:Function }, Sen
activityEndTime:this.state.activityEndTime, activityEndTime:this.state.activityEndTime,
activityImgFile:this.state.activityImgFile, activityImgFile:this.state.activityImgFile,
serviceAddress:this.state.serviceAddress serviceAddress:this.state.serviceAddress
},new SendHelpTransform(),function (res:SendHelpRes) { },new EmptyBodyTransform(),function (res:JSONResponse<SimpleMessage>) {
switch (res.customResult) { switch (res.customResult) {
case ActivityMessage.ok: case SimpleMessage.ok:
that.setState({ that.setState({
result:<div className="text-center"><Button variant="info" onClick={()=>that.props.onSendActivityOK()}></Button></div> result:<div className="text-center"><Button variant="info" onClick={()=>that.props.onSendActivityOK()}></Button></div>
});break });break
case ActivityMessage.fail: case SimpleMessage.fail:
that.setState({ that.setState({
result:<h3 className="text-center text-danger"></h3> result:<h3 className="text-center text-danger"></h3>
});break });break

@ -5,7 +5,7 @@ import {PageProps, User} from "../entity";
import {Page} from "../ui/Page"; import {Page} from "../ui/Page";
import {Address} from "../ui/Address"; import {Address} from "../ui/Address";
import {API, Method, request} from "../interface" import {API, Method, request} from "../interface"
import {FindUserMessage, FindUserRes, FindUserTransform} from "../result"; import {FindUserRes, FindUserTransform, PageDataMessage} from "../result";
import {MyDialog} from "../ui/MyDialog"; import {MyDialog} from "../ui/MyDialog";
/** /**
@ -48,7 +48,7 @@ export class Volunteer extends React.Component<{ undefined?:undefined },
request(API.account.find+'?info='+this.state.form.keyword+'&serviceAddress='+this.state.form.serviceAddress request(API.account.find+'?info='+this.state.form.keyword+'&serviceAddress='+this.state.form.serviceAddress
+'&currentPage='+page+'&userTypes=seekHelp',Method.GET,{},new FindUserTransform(),function(res:FindUserRes){ +'&currentPage='+page+'&userTypes=seekHelp',Method.GET,{},new FindUserTransform(),function(res:FindUserRes){
switch (res.customResult) { switch (res.customResult) {
case FindUserMessage.ok: case PageDataMessage.ok:
that.setState({ that.setState({
volunteerList:res.dataList, volunteerList:res.dataList,
form:{ form:{
@ -57,7 +57,7 @@ export class Volunteer extends React.Component<{ undefined?:undefined },
} }
}) })
break break
case FindUserMessage.fail: case PageDataMessage.fail:
that.setState({ that.setState({
form:{ form:{
keyword:that.state.form.keyword, keyword:that.state.form.keyword,
@ -65,7 +65,7 @@ export class Volunteer extends React.Component<{ undefined?:undefined },
}, },
result:<h3 className="text-center text-danger"></h3> result:<h3 className="text-center text-danger"></h3>
});break });break
case FindUserMessage.empty: case PageDataMessage.empty:
that.setState({ that.setState({
result:<h3 className="text-center text-info"></h3> result:<h3 className="text-center text-info"></h3>
});break });break

@ -24,9 +24,36 @@ export const userObj={
export const activityObj={ export const activityObj={
activityId:0, activityId:0,
userId:"123",
title:"活动标题1", title:"活动标题1",
content:"活动内容活动内容活动活动内容活动内容活动活动内容活动内容活动活动内容活动内容活动活动内容活动内容活动活动内容活动内容活动活动内容活动内容活动活动内容活动内容活动活动内容活动内容活动", content:"活动内容活动内容活动活动内容活动内容活动活动内容活动内容活动活动内容活动内容活动活动内容活动内容活动活动内容活动内容活动活动内容活动内容活动活动内容活动内容活动活动内容活动内容活动",
activityImg:"logo512.png", activityImg:"logo512.png",
activityStartTime:new Date().getTime(), activityStartTime:new Date().getTime(),
activityEndTime:new Date().getTime() activityEndTime:new Date().getTime()
} }
export const myActivityObj={
//活动Id
activityId:123,
userId:"123",
//活动标题
title:"活动标题",
//活动内容
content:"活动内容",
//活动背景图
activityImg: "logo512.png",
//求助时间
seekHelpTime:new Date().getTime(),
//活动开始时间
activityStartTime:new Date().getTime(),
//活动结束时间
activityEndTime:new Date().getTime(),
//报名时间
applyTime:new Date().getTime(),
//参与时间
joinTime:new Date().getTime(),
//完成时间
completeTime:new Date().getTime(),
//活动评价分
score: Math.ceil(Math.random()*10),
}

Loading…
Cancel
Save