|
|
@ -6,39 +6,136 @@ import {JSONResponse, Method, request} from "./interface"; |
|
|
|
import {API, prefix} from "./api"; |
|
|
|
import {API, prefix} from "./api"; |
|
|
|
import {EmptyBodyTransform, FindUserRes, FindUserTransform, PageDataMessage, SimpleMessage} from "./result"; |
|
|
|
import {EmptyBodyTransform, FindUserRes, FindUserTransform, PageDataMessage, SimpleMessage} from "./result"; |
|
|
|
import {MyDialog} from "./ui/MyDialog"; |
|
|
|
import {MyDialog} from "./ui/MyDialog"; |
|
|
|
|
|
|
|
import {Address} from "./ui/Address"; |
|
|
|
|
|
|
|
|
|
|
|
class EditUser extends React.Component<{ |
|
|
|
class EditUser extends React.Component<{ |
|
|
|
user:UserEntity; |
|
|
|
user:UserEntity; |
|
|
|
modifyUser:Function; |
|
|
|
modifyUser:Function; |
|
|
|
}, { |
|
|
|
}, { |
|
|
|
user:UserEntity; |
|
|
|
user:UserEntity; |
|
|
|
tipContent:JSX.Element|null; |
|
|
|
|
|
|
|
}>{ |
|
|
|
}>{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ages:Array<number> |
|
|
|
|
|
|
|
|
|
|
|
constructor(props: Readonly<{ user: UserEntity ,modifyUser:Function;}>) { |
|
|
|
constructor(props: Readonly<{ user: UserEntity ,modifyUser:Function;}>) { |
|
|
|
super(props); |
|
|
|
super(props); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.ages=this.createAge() |
|
|
|
|
|
|
|
|
|
|
|
this.state={ |
|
|
|
this.state={ |
|
|
|
user:this.props.user, |
|
|
|
user:this.props.user |
|
|
|
tipContent:null |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
render() { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<Form> |
|
|
|
<Form> |
|
|
|
<Input name="name" desc="姓名" value={this.state.user.name} onChange={(value:string)=>this.setState({ |
|
|
|
<Input name="name" desc="姓名" value={this.state.user.name} onChange={(value:string)=> |
|
|
|
|
|
|
|
this.setState({ |
|
|
|
user:{...this.state.user,...{name:value}} |
|
|
|
user:{...this.state.user,...{name:value}} |
|
|
|
})}/> |
|
|
|
})} valid={{check:this.isNotEmpty(this.state.user.name)}}/> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Input col={4} name="age" desc="年龄" value={this.state.user.age+""} onChange={(value:string)=> |
|
|
|
|
|
|
|
this.setState({ |
|
|
|
|
|
|
|
user:{...this.state.user,...{age:+value}} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} as={"select"} options={this.ages.map(value=><option key={value} value={value}>{value}</option>)}/> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Input col={4} name="sex" desc="性别" as="select" value={this.state.user.sex} onChange={(value:string)=>{ |
|
|
|
|
|
|
|
this.setState({ |
|
|
|
|
|
|
|
user:{...this.state.user,...{sex:value}} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
options={[ |
|
|
|
|
|
|
|
<option value="" key={"sex"+0}>请选择性别</option>, |
|
|
|
|
|
|
|
<option value="man" key={"sex"+1}>男</option>, |
|
|
|
|
|
|
|
<option value="women" key={"sex"+2}>女</option>]}/> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Input name="address" desc="住址" value={this.state.user.address} onChange={(value:string)=>this.setState({ |
|
|
|
|
|
|
|
user:{...this.state.user,...{address:value}} |
|
|
|
|
|
|
|
})} valid={{check:this.isNotEmpty(this.state.user.address)}}/> |
|
|
|
|
|
|
|
|
|
|
|
<Button variant="info" block={true} className={"ml-auto mr-auto mt-3 col-3"} onClick={()=>this.props.modifyUser(this.state.user)}>提交</Button> |
|
|
|
<div className="mt-3"> |
|
|
|
|
|
|
|
<Address value={this.state.user.serviceAddress} onChange={(value:string)=> |
|
|
|
|
|
|
|
this.setState({ |
|
|
|
|
|
|
|
user:{...this.state.user,...{serviceAddress:value}} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}/> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Input col={4} name="userType" desc="用户身份" as="select" value={this.state.user.userType} onChange={(value:string)=> |
|
|
|
|
|
|
|
this.setState({ |
|
|
|
|
|
|
|
user:{...this.state.user,...{userType:value}} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
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="电话" value={this.state.user.mobile} onChange={(value:string)=> |
|
|
|
|
|
|
|
this.setState({ |
|
|
|
|
|
|
|
user:{...this.state.user,...{mobile:value}} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} valid={{check:this.checkMobile()}}/> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Input col={4} name="email" value={this.state.user.email} desc="邮箱" onChange={(value:string)=> |
|
|
|
|
|
|
|
this.setState({ |
|
|
|
|
|
|
|
user:{...this.state.user,...{email:value}} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} valid={{check:this.checkEmail()}}/> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Input col={7} name="info" desc="简介" value={this.state.user.info} as={"textarea"} onChange={(value:string)=> |
|
|
|
|
|
|
|
this.setState({ |
|
|
|
|
|
|
|
user:{...this.state.user,...{info:value}} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
valid={{check:this.isNotEmpty(this.state.user.info)}}/> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Button variant="info" block={true} disabled={!this.check()} className={"ml-auto mr-auto mt-3 col-3"} onClick={()=>this.props.modifyUser(this.state.user)}>确认修改</Button> |
|
|
|
|
|
|
|
|
|
|
|
</Form> |
|
|
|
</Form> |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private createAge(){ |
|
|
|
|
|
|
|
let age=[] |
|
|
|
|
|
|
|
for(let i=18;i<100;i++){ |
|
|
|
|
|
|
|
age.push(i) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return age |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 检查手机号 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
checkMobile(){ |
|
|
|
|
|
|
|
return /1[3456789]\d{9}/g.test(this.state.user.mobile.toString()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 检查邮箱 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private checkEmail() { |
|
|
|
|
|
|
|
return /[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}/g.test(this.state.user.email) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//检查是否为空
|
|
|
|
|
|
|
|
isNotEmpty(...value:(string | number)[]){ |
|
|
|
|
|
|
|
for(let index in value){ |
|
|
|
|
|
|
|
if(value[index].toString().length===0){ |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private check() { |
|
|
|
|
|
|
|
return this.isNotEmpty(this.state.user.userId,this.state.user.name,this.state.user.sex, |
|
|
|
|
|
|
|
this.state.user.serviceAddress,this.state.user.userType,this.state.user.info) |
|
|
|
|
|
|
|
&&this.checkMobile()&&this.checkEmail() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -107,14 +204,16 @@ export class User extends React.Component< |
|
|
|
<th>#</th> |
|
|
|
<th>#</th> |
|
|
|
<th>用户账号</th> |
|
|
|
<th>用户账号</th> |
|
|
|
<th>姓名</th> |
|
|
|
<th>姓名</th> |
|
|
|
<th>性别</th> |
|
|
|
|
|
|
|
<th>年龄</th> |
|
|
|
<th>年龄</th> |
|
|
|
|
|
|
|
<th>性别</th> |
|
|
|
|
|
|
|
<th>住址</th> |
|
|
|
<th>头像</th> |
|
|
|
<th>头像</th> |
|
|
|
|
|
|
|
<th>服务地点</th> |
|
|
|
|
|
|
|
<th>用户身份</th> |
|
|
|
<th>电话</th> |
|
|
|
<th>电话</th> |
|
|
|
<th>邮箱</th> |
|
|
|
<th>邮箱</th> |
|
|
|
<th>地点</th> |
|
|
|
|
|
|
|
<th>时间币</th> |
|
|
|
<th>时间币</th> |
|
|
|
<th>个人描述</th> |
|
|
|
<th>简介</th> |
|
|
|
<th>操作</th> |
|
|
|
<th>操作</th> |
|
|
|
</tr> |
|
|
|
</tr> |
|
|
|
</thead> |
|
|
|
</thead> |
|
|
@ -124,8 +223,9 @@ export class User extends React.Component< |
|
|
|
<td className="align-middle">{index+1}</td> |
|
|
|
<td className="align-middle">{index+1}</td> |
|
|
|
<td className="align-middle">{user.userId}</td> |
|
|
|
<td className="align-middle">{user.userId}</td> |
|
|
|
<td className="align-middle">{user.name}</td> |
|
|
|
<td className="align-middle">{user.name}</td> |
|
|
|
<td className="align-middle">{user.sex}</td> |
|
|
|
|
|
|
|
<td className="align-middle">{user.age}</td> |
|
|
|
<td className="align-middle">{user.age}</td> |
|
|
|
|
|
|
|
<td className="align-middle">{user.sex==='man'?'男':'女'}</td> |
|
|
|
|
|
|
|
<td className="align-middle">{user.address}</td> |
|
|
|
<td className="align-middle"> |
|
|
|
<td className="align-middle"> |
|
|
|
{<Image className="head-img" src={prefix.image+user.headImg} onClick={()=>this.setState({ |
|
|
|
{<Image className="head-img" src={prefix.image+user.headImg} onClick={()=>this.setState({ |
|
|
|
dialog:<MyDialog content={<Image src={prefix.image + user.headImg}/>} |
|
|
|
dialog:<MyDialog content={<Image src={prefix.image + user.headImg}/>} |
|
|
@ -135,9 +235,11 @@ export class User extends React.Component< |
|
|
|
})}/> |
|
|
|
})}/> |
|
|
|
})}/>} |
|
|
|
})}/>} |
|
|
|
</td> |
|
|
|
</td> |
|
|
|
|
|
|
|
<td className="align-middle">{user.serviceAddress}</td> |
|
|
|
|
|
|
|
<td className="align-middle">{user.userType===UserType.seekHelp?'服务发起者':'服务接受者'}</td> |
|
|
|
<td className="align-middle">{user.mobile}</td> |
|
|
|
<td className="align-middle">{user.mobile}</td> |
|
|
|
<td className="align-middle">{user.email}</td> |
|
|
|
<td className="align-middle">{user.email}</td> |
|
|
|
<td className="align-middle">{user.address}</td> |
|
|
|
|
|
|
|
<td className="align-middle">{user.timeScore}</td> |
|
|
|
<td className="align-middle">{user.timeScore}</td> |
|
|
|
<td className="align-middle">{user.info}</td> |
|
|
|
<td className="align-middle">{user.info}</td> |
|
|
|
<td className="align-middle"> |
|
|
|
<td className="align-middle"> |
|
|
@ -173,7 +275,16 @@ export class User extends React.Component< |
|
|
|
let that=this |
|
|
|
let that=this |
|
|
|
request(API.account.updateUser,Method.POST, { |
|
|
|
request(API.account.updateUser,Method.POST, { |
|
|
|
userId:user.userId, |
|
|
|
userId:user.userId, |
|
|
|
name:user.name |
|
|
|
name:user.name, |
|
|
|
|
|
|
|
age:String(user.age), |
|
|
|
|
|
|
|
sex:String(user.sex), |
|
|
|
|
|
|
|
address:user.address, |
|
|
|
|
|
|
|
serviceAddress:user.serviceAddress, |
|
|
|
|
|
|
|
userType:user.userType, |
|
|
|
|
|
|
|
mobile:user.mobile, |
|
|
|
|
|
|
|
email:user.email, |
|
|
|
|
|
|
|
info:user.info |
|
|
|
|
|
|
|
|
|
|
|
},new EmptyBodyTransform(),function (res:JSONResponse<SimpleMessage>) { |
|
|
|
},new EmptyBodyTransform(),function (res:JSONResponse<SimpleMessage>) { |
|
|
|
switch (res.customResult) { |
|
|
|
switch (res.customResult) { |
|
|
|
case SimpleMessage.ok: |
|
|
|
case SimpleMessage.ok: |
|
|
|