index.jsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import React,{Component} from 'react';
  2. import {windowEventHandler,getWindowInnerHeight} from '@utils/tools';
  3. import {connect} from 'react-redux';
  4. import $ from 'jquery';
  5. class PushEmbed extends Component{
  6. constructor(props){
  7. super(props);
  8. this.state={
  9. height:100,
  10. width:'100%'
  11. }
  12. }
  13. componentDidMount() {
  14. const height = getWindowInnerHeight() - 190;
  15. this.setState({height:height});
  16. windowEventHandler('resize', ()=>{
  17. const height = getWindowInnerHeight() - 190;
  18. this.setState({height:height});
  19. });
  20. }
  21. componentWillReceiveProps(next){
  22. if(next.update!=this.props.update){
  23. //window.frames['embedPage'].contentWindow.location.reload();
  24. //console.log(window.frames['embedPage'].contentWindow)
  25. }
  26. }
  27. render(){
  28. const {width,height}=this.state;
  29. const {mrId} = this.props;
  30. const url = "http://192.168.2.241:5448/index.html?mrId="+mrId+"&plan=1";
  31. return <iframe id='embedPage' width={width} height={height} src={url} frameborder="0"></iframe>;
  32. }
  33. }
  34. function mapStateToProps(state){
  35. const {mrId,update} = state.print.mrInfo;
  36. //console.log(state);
  37. return {mrId,update};
  38. };
  39. const PushEmbedContainer = connect(
  40. mapStateToProps
  41. )(PushEmbed);
  42. export default PushEmbedContainer;