From ad8d70634b6a66c84eed29f494a9d9fdfcab333c Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Thu, 28 May 2020 08:12:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E6=9C=8D=E5=8A=A1=E7=AB=AF?= =?UTF-8?q?=201.=E4=B8=AA=E4=BA=BA=E4=BF=A1=E6=81=AF-=E6=88=91=E7=9A=84?= =?UTF-8?q?=E6=B1=82=E5=8A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Main.tsx | 6 +- src/account/Register.tsx | 2 +- src/entity.ts | 22 +++---- src/index.css | 2 +- src/interface.ts | 8 ++- src/my/MyHelp.tsx | 2 +- src/my/MyInfo.tsx | 17 ++++-- src/my/MyMessage.tsx | 8 +-- src/my/SeekHelp.tsx | 120 ++++++++++++++++++++++----------------- src/result.ts | 43 +++++++++++++- src/sub/IndexMenu.tsx | 4 +- src/sub/Volunteer.tsx | 14 +++-- 12 files changed, 156 insertions(+), 92 deletions(-) diff --git a/src/Main.tsx b/src/Main.tsx index d66b5eb..9d35b22 100644 --- a/src/Main.tsx +++ b/src/Main.tsx @@ -147,11 +147,7 @@ export class Main extends React.Component< break; case DialogType.message: this.setState({ - my:{menuName:dialogType,content:{ - 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:,open:true} }) break; } diff --git a/src/account/Register.tsx b/src/account/Register.tsx index 5530fbe..115b658 100644 --- a/src/account/Register.tsx +++ b/src/account/Register.tsx @@ -166,7 +166,7 @@ export class Register extends React.Component{
this.setState({serviceAddress:value})}/> this.setState({userType:value})} - options={[,,]}/> + options={[,,]}/> this.setState({mobile:value})} valid={{check:this.checkMobile()}}/> diff --git a/src/entity.ts b/src/entity.ts index eb9c277..703b246 100644 --- a/src/entity.ts +++ b/src/entity.ts @@ -91,13 +91,13 @@ export interface MyHelpState extends ActivityDetail{ //我的求助信息 export interface SeekHelpState extends BaseHelp,ActivityId{ //求助时间 - time:number; - //活动报名志愿者 - applyVolunteerList:Array; - //活动参加志愿者 - joinVolunteerList:Array; - //活动完成志愿者 - completeVolunteerList:Array; + 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" diff --git a/src/index.css b/src/index.css index 9984eb2..bac692b 100644 --- a/src/index.css +++ b/src/index.css @@ -110,7 +110,7 @@ } /** -*求助信息高度 +*求助信息宽高 */ .seek-help-height{ height: 400px; diff --git a/src/interface.ts b/src/interface.ts index 4c8d531..9a5f6c9 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -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" } } } diff --git a/src/my/MyHelp.tsx b/src/my/MyHelp.tsx index 34ad1ea..a026ad9 100644 --- a/src/my/MyHelp.tsx +++ b/src/my/MyHelp.tsx @@ -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 }>{ diff --git a/src/my/MyInfo.tsx b/src/my/MyInfo.tsx index 205ed9f..039219d 100644 --- a/src/my/MyInfo.tsx +++ b/src/my/MyInfo.tsx @@ -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 @@ -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:

更新信息成功

+ result:
+

更新信息成功

+ {isUpdateUserType?:null} +
}) break } diff --git a/src/my/MyMessage.tsx b/src/my/MyMessage.tsx index 98970b3..f49c283 100644 --- a/src/my/MyMessage.tsx +++ b/src/my/MyMessage.tsx @@ -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) { @@ -22,7 +22,7 @@ export class MyMessage extends React.Component<{ user:string,onUserUpdate:Functi this.state={ subMenu:Menu.info, - page:this.props.onUserUpdate(user)} userId={this.props.user} isMyFriend={false} isOwn={true} isAdd={false}/> + page: } } @@ -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:this.props.onUserUpdate(user)} userId={this.props.user} isMyFriend={false} isOwn={true} isAdd={false}/>}) + this.setState({page:}) break case Menu.help: this.setState({page:}) diff --git a/src/my/SeekHelp.tsx b/src/my/SeekHelp.tsx index 8ba2925..b88d73c 100644 --- a/src/my/SeekHelp.tsx +++ b/src/my/SeekHelp.tsx @@ -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; + //求助信息 + data?:Array; + //志愿者列表弹框打开状态 open:boolean; + //筛选的活动状态 status?:string; + //志愿者列表 volunteerList?:Array; + //打开用户信息弹框 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:

获取求助信息失败,请联系管理员

+ }); + 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:

获取志愿者信息失败,请联系管理员

+ }); + 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 ( -
- {this.state.data.map((help:SeekHelpState, index:number)=> +
+ {this.state.data?this.state.data.map((help:SeekHelpState, index:number)=>
- +
{help.title}
@@ -109,20 +120,20 @@ export class SeekHelp extends React.Component<{ user:string },
- {moment(help.time).format("YYYY-MM-DD HH:mm:ss")} + {moment(help.seekHelpTime).format("YYYY-MM-DD HH:mm:ss")} - - - + + +
- )} + ):null} @@ -146,6 +157,9 @@ export class SeekHelp extends React.Component<{ user:string }, } open={this.state.openUserInfo} onClose={()=>this.setState({openUserInfo:false})}/> + + this.setState({result:null})} />
) } diff --git a/src/result.ts b/src/result.ts index b5463f7..b170de7 100644 --- a/src/result.ts +++ b/src/result.ts @@ -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{ export class ActivityDetailRes extends JSONResponse{ activity?:ActivityDetail } - +//活动详情转换 export class ActivityDetailTransform extends TransformData{ protected newObject(): ActivityDetailRes { return new ActivityDetailRes(); @@ -174,7 +174,7 @@ export class ActivityDetailTransform extends TransformData{ info?:UserEdit } - +//查找用户信息转换 export class FindUserInfoTransform extends TransformData{ protected newObject(): FindUserInfo { return new FindUserInfo(); @@ -192,13 +192,50 @@ export enum ModifyPwdMessage { fail='fail' } +/** + * 修改密码数据转换 + */ export class ModifyPwdTransform extends EmptyBodyDiffMsg{ protected newObject(): JSONResponse { return new JSONResponse(); } +} + + +export class SeekHelpInfoRes extends JSONResponse{ + dataList?:Array +} + +/** + * 求助信息转换 + */ +export class SeekHelpInfoTransform extends TransformData{ + protected newObject(): SeekHelpInfoRes { + return new SeekHelpInfoRes(); + } + + protected transformBody(data: any) { + this.target.dataList=data.body + } } +export class SeekHelpUser extends JSONResponse{ + dataList?:Array +} + +/** + * 求助信息志愿者列表 + */ +export class SeekHelpUserTransform extends TransformData{ + protected newObject(): SeekHelpUser { + return new SeekHelpUser(); + } + + protected transformBody(data: any) { + this.target.dataList=data.body + } +} diff --git a/src/sub/IndexMenu.tsx b/src/sub/IndexMenu.tsx index 704c329..c2c12fb 100644 --- a/src/sub/IndexMenu.tsx +++ b/src/sub/IndexMenu.tsx @@ -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) { switch (res.customResult) { case SimpleMessage.ok: diff --git a/src/sub/Volunteer.tsx b/src/sub/Volunteer.tsx index 1dde750..715d46c 100644 --- a/src/sub/Volunteer.tsx +++ b/src/sub/Volunteer.tsx @@ -84,12 +84,14 @@ export class Volunteer extends React.Component<{ undefined?:undefined }, serviceAddress:this.state.form.serviceAddress }})}/> -
this.setState({ - form:{ - keyword:this.state.form.keyword, - serviceAddress:value - } - })}/> +
+
this.setState({ + form:{ + keyword:this.state.form.keyword, + serviceAddress:value + } + })}/> +