DetailTest.js 1.7 KB
Newer Older
钟是志's avatar
钟是志 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
import React, { Fragment, Component } from 'react';

const getUrlInfo = param => {
  let url = window.document.location.href.toString();
  let u = url.split('?');
  if (typeof u[1] == 'string') {
    u = u[1].split('&');
    let get = {};
    for (let i in u) {
      let j = u[i].split('=');
      get[j[0]] = decodeURIComponent(j[1]);
    }
    return get;
  } else {
    return {};
  }
};

export default class Detail extends Component {
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    window.addEventListener(
      'message',
      event => {
        if (event.data && event.data.indexOf && event.data.indexOf('iframeDetailHeight') > -1) {
          const height = Number(event.data.split('-')[1]);
          document.getElementById('detailIframeId').height = height + 50;
          setTimeout(() => {
            //document.getElementsByClassName('ant-layout-content')[0].scrollTo(0, height);
            // 23627 签约审核/另行签约审核,审核框优化,自动显示到当前页面,不要一直拉
            // 需求存在争议 暂时这样解决
          }, 500);
        }
      },
      false,
    );
  }

  render() {
    let iframeUrl = `http://localhost:8000/onestop/IframeForDetail?id=1471409591622303744&token=2055c709-a144-4897-b8b8-0e907f9e9221`;
    return (
      <div>
        <iframe
          src={iframeUrl}
          frameBorder={0}
          id="detailIframeId"
          name="applyIframe"
          marginWidth="0"
          marginHeight="0"
          onLoad={this.showAll}
          allowtransparency="yes"
          seamless
          scrolling={'no'}
          style={{
            width: '100%',
            overflowY: 'hidden',
            minHeight: '800px',
          }}
        />
      </div>
    );
  }
}