将IE拍照代码迁移到tsx
This commit is contained in:
@ -1,28 +1,36 @@
|
||||
import React from "react";
|
||||
import FrameLoader from "./FrameLoader";
|
||||
export default class FrameFaceLogin extends React.Component {
|
||||
constructor(props) {
|
||||
constructor(props:any) {
|
||||
super(props);
|
||||
console.log(props, "props数据");
|
||||
this.state = {
|
||||
transferData: {
|
||||
optimizationOrderFn: false,
|
||||
allocationFn: false,
|
||||
releaseFn: false,
|
||||
revocationFn: false,
|
||||
image: ''
|
||||
},
|
||||
};
|
||||
}
|
||||
componentDidMount() {
|
||||
// 接收Iframe 传递的数据
|
||||
// 接收Iframe传递的数据
|
||||
window.addEventListener("message", (e) => {
|
||||
const { allocationFn, releaseFn } = e.data || {}; //传递的数据
|
||||
if (allocationFn || releaseFn) {
|
||||
const { image} = e.data || {}; //传递的数据
|
||||
if (image) {
|
||||
this.setState({
|
||||
transferData: e.data,
|
||||
transferData: {
|
||||
image:e.data
|
||||
},
|
||||
});
|
||||
|
||||
console.log(this.state.transferData, "传数据");
|
||||
const url = 'http://127.0.0.1:8081/outer/v1.0/stock/logicStock/rgbArray2Base64';
|
||||
window.fetch(url,{
|
||||
method:'post',
|
||||
body : JSON.stringify({//post请求参数
|
||||
type: 'pixel',
|
||||
rgb: image
|
||||
})
|
||||
}).then(res => res.json()).then(res => {
|
||||
const childFrameObj = document.getElementById('faceLoginFrame');
|
||||
childFrameObj.contentWindow.postMessage(res, '*');
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import Iframe from "react-iframe";
|
||||
export default class FrameLoader extends React.Component {
|
||||
constructor(props) {
|
||||
constructor(props:any) {
|
||||
super(props);
|
||||
this.state = {
|
||||
iFrameHeight: this.props.height ? this.props.height : 0, // 设置iframe的高度
|
||||
@ -14,6 +14,7 @@ export default class FrameLoader extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<Iframe
|
||||
id="faceLoginFrame"
|
||||
onLoad={() => {
|
||||
const obj = ReactDOM.findDOMNode(this);
|
||||
this.setState({
|
||||
|
Reference in New Issue
Block a user