对接服务端

1.个人信息-我的求助
master
pan 5 years ago
parent 372531e0c3
commit ad8d70634b
  1. 6
      src/Main.tsx
  2. 2
      src/account/Register.tsx
  3. 22
      src/entity.ts
  4. 2
      src/index.css
  5. 8
      src/interface.ts
  6. 2
      src/my/MyHelp.tsx
  7. 17
      src/my/MyInfo.tsx
  8. 8
      src/my/MyMessage.tsx
  9. 118
      src/my/SeekHelp.tsx
  10. 43
      src/result.ts
  11. 4
      src/sub/IndexMenu.tsx
  12. 2
      src/sub/Volunteer.tsx

@ -147,11 +147,7 @@ export class Main extends React.Component<
break;
case DialogType.message:
this.setState({
my:{menuName:dialogType,content:<MyMessage onUserUpdate={(user:User)=>{
this.setState({userType:user.userType})
this.props.cookies.set(user_type_cookie,user.userType)
}}
user={this.props.cookies.get(user_cookie)}/>,open:true}
my:{menuName:dialogType,content:<MyMessage cookies={this.props.cookies} user={this.props.cookies.get(user_cookie)}/>,open:true}
})
break;
}

@ -166,7 +166,7 @@ export class Register extends React.Component<RegisterProps, RegisterState>{
<Address value={this.state.serviceAddress} onChange={(value:string)=>this.setState({serviceAddress:value})}/>
<Input col={4} name="userType" desc="用户身份" as="select" onChange={(value:string)=>this.setState({userType:value})}
options={[<option value="" key={"userType0"}></option>,<option key={"userType1"} value={UserType.help}></option>,<option key={"userType2"} value={UserType.seekHelp}></option>]}/>
options={[<option value="" key={"userType0"}></option>,<option key={"userType1"} value={UserType.seekHelp}></option>,<option key={"userType2"} value={UserType.help}></option>]}/>
<Input col={4} name="mobile" desc="电话" onChange={(value:string)=>this.setState({mobile:value})} valid={{check:this.checkMobile()}}/>

@ -91,13 +91,13 @@ export interface MyHelpState extends ActivityDetail{
//我的求助信息
export interface SeekHelpState extends BaseHelp,ActivityId{
//求助时间
time:number;
//活动报名志愿者
applyVolunteerList:Array<User>;
//活动参加志愿者
joinVolunteerList:Array<User>;
//活动完成志愿者
completeVolunteerList:Array<User>;
seekHelpTime:number;
//报名人数
apply:number;
//参加人数
join:number;
//完成人数
complete:number;
}
@ -241,7 +241,9 @@ export interface UserEdit{
newPassword:string;
//确认新密码
confirmNewPwd:string;
result:JSX.Element|null
result:JSX.Element|null;
//缓存用户身份
oldUserType?:String;
}
@ -337,9 +339,9 @@ export interface LoginState{
}
/**
*
*
*/
export enum VolunteerStatus {
export enum ActivityStatus {
apply = "apply",
join = "join",
complete = "complete"

@ -110,7 +110,7 @@
}
/**
*求助信息高
*求助信息
*/
.seek-help-height{
height: 400px;

@ -19,7 +19,7 @@ export const API={
//更新
update:prefix.user+"/update",
//更新密码
updatePwd:prefix.user+"/updatePwd"
updatePwd:prefix.user+"/updatePwd",
},
main:{
activity: {
@ -28,7 +28,11 @@ export const API={
//查找活动列表
find: prefix.activity + "/find",
//报名活动
apply:prefix.activity+ "/apply"
apply:prefix.activity+ "/apply",
//求助信息统计
seekHelp:prefix.activity+"/seekHelp",
//求助信息志愿者
seekHelpUser:prefix.activity+"/seekHelpUser"
}
}
}

@ -7,7 +7,7 @@ import {myActivityObj} from "../ui/TestData";
const classList="border-info border d-flex justify-content-center align-items-center"
/**
*
*
*/
export class MyHelp extends React.Component<{ undefined?:undefined }, { data:Array<MyHelpState> }>{

@ -13,6 +13,8 @@ import {
} from "../result";
import {MyDialog} from "../ui/MyDialog";
import {Address} from "../ui/Address";
import {Cookies} from "react-cookie";
import {user_type_cookie} from "../account/PropCookie";
/**
*
@ -23,7 +25,7 @@ export class MyInfo extends React.Component<
isOwn:boolean;
isMyFriend:boolean;
isAdd:boolean;
onUserUpdate?:Function;
cookies?:Cookies;
}, UserEdit>{
private ages:Array<number>
@ -76,7 +78,8 @@ export class MyInfo extends React.Component<
serviceAddress:res.info?.serviceAddress,
info:res.info?.info,
userType:res.info?.userType,
sex:res.info?.sex
sex:res.info?.sex,
oldUserType:res.info?.userType
});break
}
@ -145,7 +148,10 @@ export class MyInfo extends React.Component<
})
let that=this
let isUpdateUserType=this.state.userType!==this.state.oldUserType
if(isUpdateUserType&&this.props.cookies){
this.props.cookies.set(user_type_cookie,this.state.userType)
}
request(API.account.update,Method.POST, {
headImg:this.state.headImg||"",
name:this.state.name||"",
@ -166,7 +172,10 @@ export class MyInfo extends React.Component<
that.loadInfo();
//TODO 更新用户身份
that.setState({
result:<h3 className="text-info text-center"></h3>
result:<div className="text-center">
<h3 className="text-info text-center"></h3>
{isUpdateUserType?<Button variant={"info"} onClick={()=>window.location.reload()}></Button>:null}
</div>
})
break
}

@ -3,7 +3,7 @@ import {Button, ButtonGroup, Col, Container, Row} from "react-bootstrap";
import {MyInfo} from "./MyInfo";
import {MyHelp} from "./MyHelp";
import {SeekHelp} from "./SeekHelp";
import {User} from "../entity";
import {Cookies} from "react-cookie";
enum Menu {
info="个人信息",
@ -14,7 +14,7 @@ enum Menu {
/**
*
*/
export class MyMessage extends React.Component<{ user:string,onUserUpdate:Function }, { subMenu:Menu,page:JSX.Element }>{
export class MyMessage extends React.Component<{ user:string,cookies:Cookies }, { subMenu:Menu,page:JSX.Element }>{
constructor(props: Readonly<any>) {
@ -22,7 +22,7 @@ export class MyMessage extends React.Component<{ user:string,onUserUpdate:Functi
this.state={
subMenu:Menu.info,
page:<MyInfo onUserUpdate={(user:User)=>this.props.onUserUpdate(user)} userId={this.props.user} isMyFriend={false} isOwn={true} isAdd={false}/>
page:<MyInfo cookies={this.props.cookies} userId={this.props.user} isMyFriend={false} isOwn={true} isAdd={false}/>
}
}
@ -31,7 +31,7 @@ export class MyMessage extends React.Component<{ user:string,onUserUpdate:Functi
this.setState({subMenu:menu})
switch (menu) {
case Menu.info:
this.setState({page:<MyInfo onUserUpdate={(user:User)=>this.props.onUserUpdate(user)} userId={this.props.user} isMyFriend={false} isOwn={true} isAdd={false}/>})
this.setState({page:<MyInfo cookies={this.props.cookies} userId={this.props.user} isMyFriend={false} isOwn={true} isAdd={false}/>})
break
case Menu.help:
this.setState({page:<MyHelp/>})

@ -1,6 +1,6 @@
import React from "react";
import {Button, ButtonGroup, Col, Container, Image, ListGroup, Row} from "react-bootstrap";
import {SeekHelpState, User, VolunteerStatus} from "../entity";
import {ActivityStatus, SeekHelpState, User} from "../entity";
import moment from "moment";
import Dialog from "@material-ui/core/Dialog";
import {CloseDialog} from "../ui/CloseDialog";
@ -8,21 +8,30 @@ import {Paper, Tooltip} from "@material-ui/core";
import Draggable from "react-draggable";
import {MyDialog} from "../ui/MyDialog";
import {MyInfo} from "./MyInfo";
import {userObj} from "../ui/TestData";
import {API, Method, prefix, request} from "../interface";
import {SeekHelpInfoRes, SeekHelpInfoTransform, SeekHelpUser, SeekHelpUserTransform, SimpleMessage} from "../result";
const titleId="seek-help-dialog"
/**
*
*
*/
export class SeekHelp extends React.Component<{ user:string },
{
data:Array<SeekHelpState>;
//求助信息
data?:Array<SeekHelpState>;
//志愿者列表弹框打开状态
open:boolean;
//筛选的活动状态
status?:string;
//志愿者列表
volunteerList?:Array<User>;
//打开用户信息弹框
openUserInfo:boolean;
//查看用户信息用户id
userId?:string;
//操作反馈弹窗
result:JSX.Element|null;
}>{
@ -32,7 +41,8 @@ export class SeekHelp extends React.Component<{ user:string },
this.state={
data:[],
open:false,
openUserInfo:false
openUserInfo:false,
result:null
}
}
@ -44,63 +54,64 @@ export class SeekHelp extends React.Component<{ user:string },
*
*/
loadHelp(){
this.setState({data:[
{
applyVolunteerList: [userObj,userObj],
completeVolunteerList: [],
joinVolunteerList: [],
activityImg: "logo512.png",
content: "活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容",
time: new Date().getTime(),
title:"活动标题",
//活动Id
activityId:123,
},
{
applyVolunteerList: [],
completeVolunteerList: [],
joinVolunteerList: [],
activityImg: "logo512.png",
content: "活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容",
time: new Date().getTime(),
title:"活动标题",
//活动Id
activityId:123,
},
{
applyVolunteerList: [],
completeVolunteerList: [],
joinVolunteerList: [],
activityImg: "logo512.png",
content: "活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容活动内容",
time: new Date().getTime(),
title:"活动标题",
//活动Id
activityId:123,
let that=this
request(API.main.activity.seekHelp,Method.GET, {},new SeekHelpInfoTransform(),function (res:SeekHelpInfoRes) {
switch (res.customResult) {
case SimpleMessage.fail:
that.setState({
result:<h3 className="text-danger text-center"></h3>
});
break
case SimpleMessage.ok:
console.debug("求助信息"+res.dataList)
that.setState({
data:res.dataList
})
}
]})
})
console.debug(this.state)
}
//打开志愿者列表
openVolunteerList(activityId:number,status:ActivityStatus){
let that=this
request(API.main.activity.seekHelpUser+"?activityId="+activityId+"&activityStatus="+status,Method.GET,{},
new SeekHelpUserTransform(),function (res:SeekHelpUser) {
switch (res.customResult) {
case SimpleMessage.fail:
that.setState({
result:<h3 className="text-danger text-center"></h3>
});
break
case SimpleMessage.ok:
that.setState({
volunteerList:res.dataList,
open:true,
status:that.getStatus(status)
})
break
}
})
}
getStatus(status:VolunteerStatus){
//活动状态转换
getStatus(status:ActivityStatus){
switch (status) {
case VolunteerStatus.apply:return "报名"
case VolunteerStatus.join:return "参加"
case VolunteerStatus.complete:return "完成"
case ActivityStatus.apply:return "报名"
case ActivityStatus.join:return "参与"
case ActivityStatus.complete:return "完成"
}
}
render() {
return (
<div className="overflow-auto seek-help-height">
{this.state.data.map((help:SeekHelpState, index:number)=>
<div className="overflow-auto seek-help-height w-100">
{this.state.data?this.state.data.map((help:SeekHelpState, 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={help.activityImg?prefix.image+help.activityImg:""} className="activityImage"/>
</Col>
<Col>
<h5>{help.title}</h5>
@ -109,20 +120,20 @@ export class SeekHelp extends React.Component<{ user:string },
</Row>
<Row>
<Col xs={4} className="mt-auto mb-auto">
<span>{moment(help.time).format("YYYY-MM-DD HH:mm:ss")}</span>
<span>{moment(help.seekHelpTime).format("YYYY-MM-DD HH:mm:ss")}</span>
</Col>
<Col>
<ButtonGroup>
<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: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:this.getStatus(VolunteerStatus.complete),volunteerList:help.completeVolunteerList})}>:{help.completeVolunteerList.length}</Button>
<Button variant={"primary"} disabled={help.apply===0} onClick={()=>this.openVolunteerList(help.activityId,ActivityStatus.apply)}>:{help.apply}</Button>
<Button variant={"success"} disabled={help.join===0} onClick={()=>this.openVolunteerList(help.activityId,ActivityStatus.join)}>:{help.join}</Button>
<Button variant={"light"} disabled={help.complete===0} onClick={()=>this.openVolunteerList(help.activityId,ActivityStatus.complete)}>:{help.complete}</Button>
</ButtonGroup>
</Col>
</Row>
</Container>
</div>
)}
):null}
<Dialog hideBackdrop={true} open={this.state.open}
PaperComponent={(props)=>
@ -146,6 +157,9 @@ export class SeekHelp extends React.Component<{ user:string },
<MyDialog titleId="view-user" menuName="用户信息"
content={<MyInfo isOwn={false} isMyFriend={false} isAdd={true} userId={this.state.userId?this.state.userId:""}/>}
open={this.state.openUserInfo} onClose={()=>this.setState({openUserInfo:false})}/>
<MyDialog content={this.state.result} open={this.state.result!==null} titleId="seek-help-dialog"
menuName="求助信息提示" onClose={()=>this.setState({result:null})} />
</div>
)
}

@ -2,7 +2,7 @@
*
*/
import {JSONResponse, Result, TransformData} from "./interface";
import {ActivityDetail, PageProps, User, UserEdit, UserType} from "./entity";
import {ActivityDetail, PageProps, SeekHelpState, User, UserEdit, UserType} from "./entity";
/**
* body响应
@ -160,7 +160,7 @@ export class FindUserTransform extends PageDataTransform<FindUserRes>{
export class ActivityDetailRes extends JSONResponse<SimpleMessage>{
activity?:ActivityDetail
}
//活动详情转换
export class ActivityDetailTransform extends TransformData<SimpleMessage, ActivityDetailRes>{
protected newObject(): ActivityDetailRes {
return new ActivityDetailRes();
@ -174,7 +174,7 @@ export class ActivityDetailTransform extends TransformData<SimpleMessage, Activi
export class FindUserInfo extends JSONResponse<SimpleMessage>{
info?:UserEdit
}
//查找用户信息转换
export class FindUserInfoTransform extends TransformData<SimpleMessage, FindUserInfo>{
protected newObject(): FindUserInfo {
return new FindUserInfo();
@ -192,13 +192,50 @@ export enum ModifyPwdMessage {
fail='fail'
}
/**
*
*/
export class ModifyPwdTransform extends EmptyBodyDiffMsg<ModifyPwdMessage>{
protected newObject(): JSONResponse<ModifyPwdMessage> {
return new JSONResponse<ModifyPwdMessage>();
}
}
export class SeekHelpInfoRes extends JSONResponse<SimpleMessage>{
dataList?:Array<SeekHelpState>
}
/**
*
*/
export class SeekHelpInfoTransform extends TransformData<SimpleMessage, SeekHelpInfoRes>{
protected newObject(): SeekHelpInfoRes {
return new SeekHelpInfoRes();
}
protected transformBody(data: any) {
this.target.dataList=data.body
}
}
export class SeekHelpUser extends JSONResponse<SimpleMessage>{
dataList?:Array<User>
}
/**
*
*/
export class SeekHelpUserTransform extends TransformData<SimpleMessage, SeekHelpUser>{
protected newObject(): SeekHelpUser {
return new SeekHelpUser();
}
protected transformBody(data: any) {
this.target.dataList=data.body
}
}

@ -2,7 +2,7 @@ import React from "react";
import {Button, Card, Col, Container, Image, ListGroup, Row} from "react-bootstrap";
import {Page} from "../ui/Page";
import {ActivityDetail, PageProps, UserType, VolunteerStatus} from "../entity";
import {ActivityDetail, ActivityStatus, PageProps, UserType} from "../entity";
import {MyDialog} from "../ui/MyDialog";
import {Activity} from "../ui/Activity";
import {Input} from "../ui/InputGroup";
@ -63,7 +63,7 @@ export class IndexMenu extends React.Component<{ cookies:Cookies },
request(API.main.activity.apply,Method.POST,{
activityId:activityId+"",
activityStatus:VolunteerStatus.join.toString()
activityStatus:ActivityStatus.apply.toString()
},new EmptyBodyTransform(),function (res:JSONResponse<SimpleMessage>) {
switch (res.customResult) {
case SimpleMessage.ok:

@ -84,12 +84,14 @@ export class Volunteer extends React.Component<{ undefined?:undefined },
serviceAddress:this.state.form.serviceAddress
}})}/>
<div className="mt-3">
<Address onChange={(value:string)=>this.setState({
form:{
keyword:this.state.form.keyword,
serviceAddress:value
}
})}/>
</div>
<Button className="col-1 mt-3 mb-3" variant="info" onClick={()=>console.info(this.state.form)}></Button>

Loading…
Cancel
Save