parent
6f30ed1fea
commit
d23bcb2baa
@ -1,20 +0,0 @@ |
||||
|
||||
/** |
||||
* 登陆表单 |
||||
*/ |
||||
export interface LoginProps{ |
||||
//跳转注册
|
||||
toRegister:Function; |
||||
//登录
|
||||
login:Function; |
||||
} |
||||
|
||||
/** |
||||
* 登陆状态 |
||||
*/ |
||||
export interface LoginState { |
||||
//管理员名
|
||||
user:string; |
||||
//密码
|
||||
password:string; |
||||
} |
@ -1,14 +0,0 @@ |
||||
/** |
||||
* 注册表单 |
||||
*/ |
||||
export interface RegisterProps { |
||||
//跳转登录
|
||||
toLogin:Function; |
||||
} |
||||
|
||||
export interface RegisterState { |
||||
//管理员名
|
||||
user:string; |
||||
//密码
|
||||
password:string; |
||||
} |
@ -0,0 +1,22 @@ |
||||
import {UserType} from "../entity"; |
||||
|
||||
export const userObj={ |
||||
//发送人名称
|
||||
name:"张三", |
||||
//发送人头像
|
||||
headImg:"logo512.png", |
||||
//发送内容
|
||||
content:"发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容发送内容", |
||||
//发送时间
|
||||
time:new Date().getTime(), |
||||
userId:"admin", |
||||
age:Math.ceil(Math.random()*100)+1, |
||||
mobile:1234567879, |
||||
email:"admin@qq.com", |
||||
address:"上海高新区", |
||||
info:"个人简介", |
||||
//性别
|
||||
sex:"男", |
||||
flag:false, |
||||
userType:UserType.seekHelp.toString() |
||||
} |
@ -0,0 +1,61 @@ |
||||
import React, {RefObject} from "react"; |
||||
import {Form, Image} from "react-bootstrap"; |
||||
import path from "path"; |
||||
|
||||
/** |
||||
* 上传图片 |
||||
*/ |
||||
export class UploadImg extends React.Component< |
||||
{ |
||||
//文件对象
|
||||
fileImg:RefObject<any>; |
||||
//图片尺寸限制
|
||||
maxImageSize:{ |
||||
width:number, |
||||
height:number |
||||
}; |
||||
//上传事件
|
||||
onChange:Function; |
||||
//图片文件名
|
||||
imageName:string; |
||||
}, any>{ |
||||
|
||||
/** |
||||
* 获取图片url |
||||
*/ |
||||
getUrl(){ |
||||
if(this.props.fileImg.current!==null&&this.props.fileImg.current.files.length>0) { |
||||
return URL.createObjectURL(this.props.fileImg.current.files[0]) |
||||
} |
||||
} |
||||
|
||||
render() { |
||||
return ( |
||||
<div> |
||||
{/* |
||||
预览背景图 |
||||
*/} |
||||
<Image className="mt-3 d-none" src={this.getUrl()} onLoad={(s)=> { |
||||
if(s.target instanceof HTMLImageElement){ |
||||
//限制图片显示大小
|
||||
s.target.width=s.target.width>this.props.maxImageSize.width?this.props.maxImageSize.width:s.target.width |
||||
s.target.height=s.target.height>this.props.maxImageSize.height?this.props.maxImageSize.height:s.target.height |
||||
s.target.classList.remove('d-none') |
||||
} |
||||
} |
||||
}/> |
||||
|
||||
{/*上传背景图*/} |
||||
<div className="col-7 ml-auto mr-auto mt-3"> |
||||
<Form.File |
||||
ref={this.props.fileImg} |
||||
label={path.basename(this.props.imageName.replace(/\\/g,'/'))} |
||||
custom |
||||
accept="image/*" |
||||
onChange={(e:any)=>this.props.onChange(e.target.value)} |
||||
/> |
||||
</div> |
||||
</div> |
||||
) |
||||
} |
||||
} |
Loading…
Reference in new issue