1. 只显示没有报名的并且不是自己发布的活动,已报名,已参加的活动只能从我的帮助处找到

2. 求助者只能查看别人的活动,无法做报名操作
master
pan 5 years ago
parent 0a23d09ce4
commit ac6eda8115
  1. 13
      src/App.tsx
  2. 18
      src/Main.tsx
  3. 2
      src/account/Login.tsx
  4. 1
      src/account/PropCookie.ts
  5. 2
      src/result.ts
  6. 23
      src/sub/IndexMenu.tsx

@ -5,8 +5,8 @@ import {Login} from './account/Login';
import {Cookies, withCookies} from 'react-cookie';
import {Main} from "./Main";
import {Register} from "./account/Register";
import {user_cookie, user_type_cookie, welcome_cookie} from "./account/PropCookie";
import {UserType} from "./entity";
import {time_score, user_cookie, user_type_cookie, welcome_cookie} from "./account/PropCookie";
import {LoginRes} from "./result";
class App extends React.Component<
{
@ -61,10 +61,11 @@ class App extends React.Component<
*/
toLogin(){
this.setState({
page:<Login toRegister={()=>this.toRegister()} onLoginSuccess={(userId:string,userType:UserType)=> {
this.props.cookies.set(user_cookie,userId)
this.props.cookies.set(user_type_cookie,userType)
this.props.cookies.set(welcome_cookie,userId)
page:<Login toRegister={()=>this.toRegister()} onLoginSuccess={(res:LoginRes)=> {
this.props.cookies.set(user_cookie,res.userId)
this.props.cookies.set(user_type_cookie,res.userType)
this.props.cookies.set(welcome_cookie,res.userId)
this.props.cookies.set(time_score,res.timeScore)
this.setState({
page:<Main logout={()=>this.logout()} cookies={this.props.cookies}/>
})

@ -9,7 +9,7 @@ import {MyLeaveWord} from "./my/MyLeaveWord";
import {MyMessage} from "./my/MyMessage";
import {User, UserEdit, UserType} from "./entity";
import {Cookies} from "react-cookie";
import {user_cookie, user_type_cookie, welcome_cookie} from "./account/PropCookie";
import {time_score, user_cookie, user_type_cookie, welcome_cookie} from "./account/PropCookie";
/**
*
@ -65,12 +65,13 @@ export class Main extends React.Component<
//一级菜单
menu:Menu.index,
//二级菜单
subMenu:<IndexMenu user={this.props.cookies.get(user_cookie)}/>,
subMenu:<IndexMenu cookies={this.props.cookies}/>,
//我的好友信息
friendList:[],
//我的菜单
my:{menuName: "",content:null,open:false},
result:Boolean(this.props.cookies.get(welcome_cookie))
result:Boolean(this.props.cookies.get(welcome_cookie)),
userType:this.props.cookies.get(user_type_cookie)
}
}
@ -101,7 +102,7 @@ export class Main extends React.Component<
switch (menu) {
case Menu.index:
this.setState({
subMenu:<IndexMenu user={this.props.cookies.get(user_cookie)}/>
subMenu:<IndexMenu cookies={this.props.cookies}/>
});break;
case Menu.volunteer:
this.setState({
@ -146,7 +147,10 @@ export class Main extends React.Component<
break;
case DialogType.message:
this.setState({
my:{menuName:dialogType,content:<MyMessage onUserUpdate={(user:UserEdit)=>this.setState({userType:user.userType})}
my:{menuName:dialogType,content:<MyMessage onUserUpdate={(user:UserEdit)=>{
this.setState({userType:user.userType})
this.props.cookies.set(user_type_cookie,user.userType)
}}
user={this.props.cookies.get(user_cookie)}/>,open:true}
})
break;
@ -176,7 +180,7 @@ export class Main extends React.Component<
</Dropdown.Toggle>
<Dropdown.Menu>
<Dropdown.Item></Dropdown.Item>
<Dropdown.Item>:<span className="text-center text-info">{this.props.cookies.get(time_score)}</span></Dropdown.Item>
{[DialogType.friend,DialogType.leaveWord,DialogType.message].map((type:DialogType,index:number)=><Dropdown.Item disabled={this.state.my.open} key={"dropdown"+index} onClick={()=>this.openDialog(type)}>{type}</Dropdown.Item>)}
<Dropdown.Item onClick={()=>this.props.logout()}></Dropdown.Item>
</Dropdown.Menu>
@ -184,7 +188,7 @@ export class Main extends React.Component<
{(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}
{this.state.userType?<Navbar.Brand className="ml-3">{this.state.userType===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()}/>

@ -33,7 +33,7 @@ export class Login extends React.Component<LoginProps, LoginState>{
let message
switch (res.customResult) {
case LoginResMessage.ok:
that.props.onLoginSuccess(res.userId,res.userType);break
that.props.onLoginSuccess(res);break
case LoginResMessage.form_error:message="表单不合法,请联系管理员"
// eslint-disable-next-line no-fallthrough
case LoginResMessage.valid_error:message="账号或密码错误"

@ -5,3 +5,4 @@
export const user_cookie="user_cookie"
export const user_type_cookie="user_type_cookie"
export const welcome_cookie="welcome_cookie"
export const time_score="time_score"

@ -67,6 +67,7 @@ export enum LoginResMessage {
export class LoginRes implements JSONResponse<LoginResMessage>{
userId?:string
userType?:UserType
timeScore?:number
customResult?: LoginResMessage;
result?: Result;
}
@ -83,6 +84,7 @@ export class LoginTransform extends TransformData<LoginResMessage,LoginRes>{
if(data.body!==null) {
this.target.userId = data.body.userId
this.target.userType = data.body.userType
this.target.timeScore = data.body.timeScore
}
}
}

@ -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, VolunteerStatus} from "../entity";
import {ActivityDetail, PageProps, UserType, VolunteerStatus} from "../entity";
import {MyDialog} from "../ui/MyDialog";
import {Activity} from "../ui/Activity";
import {Input} from "../ui/InputGroup";
@ -16,11 +16,13 @@ import {
PageDataMessage,
SimpleMessage
} from "../result";
import {Cookies} from "react-cookie";
import {user_type_cookie} from "../account/PropCookie";
/**
*
*/
export class IndexMenu extends React.Component<{ user:string },
export class IndexMenu extends React.Component<{ cookies:Cookies },
{
//活动数据
activityList?:Array<Array<ActivityDetail>>;
@ -50,14 +52,6 @@ export class IndexMenu extends React.Component<{ user:string },
this.loadActivity(1)
}
/**
*
* @param activityId
*/
applyActivity(activityId:number){
console.debug("报名活动"+activityId)
}
/**
*
* @param activityId id
@ -73,6 +67,7 @@ export class IndexMenu extends React.Component<{ user:string },
},new EmptyBodyTransform(),function (res:JSONResponse<SimpleMessage>) {
switch (res.customResult) {
case SimpleMessage.ok:
that.loadActivity(1)
that.setState({
result:<h3 className="text-info text-center"></h3>
});break
@ -129,6 +124,7 @@ export class IndexMenu extends React.Component<{ user:string },
});break
case PageDataMessage.empty:
that.setState({
activityList:[],
page:res.page,
result:<h3 className="text-info text-center"></h3>
});break;
@ -157,7 +153,7 @@ export class IndexMenu extends React.Component<{ user:string },
</Card.Body>
<Card.Footer>
<Button variant={"info"} onClick={()=>this.loadActivityWithId(activity.activityId)} className="mr-2"></Button>
<Button variant="primary" onClick={()=>this.apply(activity.activityId)}></Button>
{this.props.cookies.get(user_type_cookie)===UserType.help?<Button variant="primary" onClick={()=>this.apply(activity.activityId)}></Button>:null}
</Card.Footer>
</Card>
</Col>)}
@ -179,7 +175,10 @@ export class IndexMenu extends React.Component<{ user:string },
{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)} />}
{this.state.activity?<MyDialog content={<Activity activity={this.state.activity} showButton={true} applyFunction={(activeId:number)=>{
this.apply(activeId)
this.setState({activity:undefined,openActivity:false})
}} />}
open={this.state.openActivity} titleId="view-active" menuName="活动详情"
onClose={()=>this.setState({activity:undefined,openActivity:false})}/>:null}

Loading…
Cancel
Save