import React from "react";
import FrameLoader from "./FrameLoader";
export default class FrameFaceLogin extends React.Component {
  constructor(props) {
    super(props);
    console.log(props, "props数据");
    this.state = {
      transferData: {
        optimizationOrderFn: false,
        allocationFn: false,
        releaseFn: false,
        revocationFn: false,
      },
    };
  }
  componentDidMount() {
  // 接收Iframe 传递的数据
    window.addEventListener("message", (e) => {
      const { allocationFn, releaseFn } = e.data || {}; //传递的数据
      if (allocationFn || releaseFn) {
        this.setState({
          transferData: e.data,	
        });

        console.log(this.state.transferData, "传数据");
      }
    });
  }
 
  render() {
    const { transferData } = this.state || {};
    console.log(transferData, "数据");
    return (
      <div style={{ height: "100%" }}>
		{/* 设置Iframe 盒子的宽度 */}
        <div style={{ minHeight: "calc(55vh - 97px)", position: "relative" }}>
        {/* 这个是打包后的Iframe 地址：要到webpack中配置打包地址 */}
          <FrameLoader url="/faceLoginIE/index.html" />
        </div>
      </div>
    );
  }
}

