preview
This commit is contained in:
@@ -29,7 +29,17 @@ const nations = [
|
|||||||
{key:'singapore', value:'新加坡'},
|
{key:'singapore', value:'新加坡'},
|
||||||
{key:'hk', value:'中国香港'},
|
{key:'hk', value:'中国香港'},
|
||||||
]
|
]
|
||||||
|
function getObjectURL(file) {
|
||||||
|
var url = null ;
|
||||||
|
if (window.createObjectURL!=undefined) { // basic
|
||||||
|
url = window.createObjectURL(file) ;
|
||||||
|
} else if (window.URL!=undefined) { // mozilla(firefox)
|
||||||
|
url = window.URL.createObjectURL(file) ;
|
||||||
|
} else if (window.webkitURL!=undefined) { // webkit or chrome
|
||||||
|
url = window.webkitURL.createObjectURL(file) ;
|
||||||
|
}
|
||||||
|
return url ;
|
||||||
|
}
|
||||||
const IdentityPage: React.FC<DispatchProp & UserModelState & IdentityModelState> = ({
|
const IdentityPage: React.FC<DispatchProp & UserModelState & IdentityModelState> = ({
|
||||||
dispatch,
|
dispatch,
|
||||||
user,
|
user,
|
||||||
@@ -39,18 +49,26 @@ const IdentityPage: React.FC<DispatchProp & UserModelState & IdentityModelState>
|
|||||||
}) => {
|
}) => {
|
||||||
const picCover = React.createRef();
|
const picCover = React.createRef();
|
||||||
const picBack = React.createRef();
|
const picBack = React.createRef();
|
||||||
|
const pic1url = React.createRef();
|
||||||
|
const pic2url = React.createRef();
|
||||||
const [idtypesVisible, setIdtypesVisible] = useState(false);
|
const [idtypesVisible, setIdtypesVisible] = useState(false);
|
||||||
const [nationVisible, setNationVisible] = useState(false);
|
const [nationVisible, setNationVisible] = useState(false);
|
||||||
const [realname, setRealname] = useState();
|
const [realname, setRealname] = useState();
|
||||||
const [idNo, setIdNo] = useState();
|
const [idNo, setIdNo] = useState();
|
||||||
|
|
||||||
const onPicCover = (key: any) => {
|
const preview = (type) => {
|
||||||
console.log(key);
|
const pic1 = picCover.current;
|
||||||
dispatch({ type: 'user/onUpdateState', payload: key });
|
const pic2 = picBack.current;
|
||||||
};
|
const obj = type === 1 ? pic1 : pic2;
|
||||||
const onPicBack = (key: any) => {
|
// let x = getObjectURL(obj);
|
||||||
dispatch({ type: 'user/onUpdateState', payload: key });
|
// pic1url.current.src = x;
|
||||||
};
|
var reader = new FileReader();
|
||||||
|
reader.readAsDataURL(obj.files[0]);
|
||||||
|
reader.onload = function(e) {
|
||||||
|
type === 1 ? (pic1url.current.src = e.target.result) : (pic2url.current.src = e.target.result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
const onIdTypeSelected = (key: string) => {
|
const onIdTypeSelected = (key: string) => {
|
||||||
setIdtypesVisible(false);
|
setIdtypesVisible(false);
|
||||||
dispatch({ type: 'user/onUpdateState', payload: key });
|
dispatch({ type: 'user/onUpdateState', payload: key });
|
||||||
@@ -92,8 +110,8 @@ const IdentityPage: React.FC<DispatchProp & UserModelState & IdentityModelState>
|
|||||||
formData.append('pic2', pic2);
|
formData.append('pic2', pic2);
|
||||||
formData.append('realname', realname);
|
formData.append('realname', realname);
|
||||||
formData.append('idNo', idNo);
|
formData.append('idNo', idNo);
|
||||||
const data = await http.post('/user/verify', formData);
|
// const data = await http.post('/user/verify', formData);
|
||||||
console.log(data);
|
// console.log(data);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
@@ -111,15 +129,15 @@ const IdentityPage: React.FC<DispatchProp & UserModelState & IdentityModelState>
|
|||||||
<div style={{'display': 'flex', 'position': 'relative'}}>
|
<div style={{'display': 'flex', 'position': 'relative'}}>
|
||||||
<div className={styles.uploadBox}>
|
<div className={styles.uploadBox}>
|
||||||
<div className={styles.imgBox}>
|
<div className={styles.imgBox}>
|
||||||
<img src={kycIdCover} className={styles.idPhoto} />
|
<img src={kycIdCover} className={styles.idPhoto} ref={pic1url}/>
|
||||||
</div>
|
</div>
|
||||||
<input type="file" className={styles.input} ref={picCover}/>
|
<input type="file" className={styles.input} ref={picCover} onChange={e => preview(1)}/>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.uploadBox}>
|
<div className={styles.uploadBox}>
|
||||||
<div className={styles.imgBox}>
|
<div className={styles.imgBox}>
|
||||||
<img src={kycIdBack} className={styles.idPhoto}/>
|
<img src={kycIdBack} className={styles.idPhoto} ref={pic2url}/>
|
||||||
</div>
|
</div>
|
||||||
<input type="file" className={styles.input} ref={picBack}/>
|
<input type="file" className={styles.input} ref={picBack} onChange={e => preview(2)}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<input className={styles.myinput}
|
<input className={styles.myinput}
|
||||||
|
|||||||
@@ -46,6 +46,8 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
width:100%;
|
width:100%;
|
||||||
height:100%;
|
height:100%;
|
||||||
|
max-width: 300px;
|
||||||
|
max-height: 200px;
|
||||||
}
|
}
|
||||||
.uploadBox {
|
.uploadBox {
|
||||||
flex: 1 0 auto;
|
flex: 1 0 auto;
|
||||||
|
|||||||
Reference in New Issue
Block a user