import React, { Component } from 'react';
import style from './index.less';
import arrowIcon from '@images/arrowIcon.png';
import pushEmpty from '@images/pushEmpty.png';
import {pushPage2} from '@utils/config';
import {dragBox} from '@utils/drag';
import hideConfirm from '@images/hideConfirm.png';

class PushData extends Component{
    constructor(props){
        super(props);
        this.state = {
            hashNum:0
        }
        this.showPushData = this.showPushData.bind(this)
        this.hidePushData = this.hidePushData.bind(this)
    }
    showPushData(){
        const {togglePushData} = this.props
        setTimeout(function(){
        dragBox('dragModalWrap','dragModalTitle','add')

        })
        togglePushData()
    }
    hidePushData(){
        const {togglePushData} = this.props
        dragBox('dragModalWrap','dragModalTitle','del')
        togglePushData()
    }
    handleScroll(e){
        e.preventDefault();
    }
    componentWillReceiveProps(next){
      
      }

    render(){
        const {hashNum } = this.state
        const {mrId,isTcm,planCode,showPushData,togglePushData ,windowWidth,windowHeight,hospitalId} = this.props
        const pushBoxPos = windowWidth>1200?(windowWidth-1200)/2:0;
        const url =`${pushPage2}?mrId=${mrId.indexOf("reStart") > - 1?"":mrId}&isTcm=${isTcm}&planCode=${planCode}&hospitalId=${hospitalId}${mrId.indexOf("reStart") > - 1 ? '&reStart='+Math.random():""}`;
        return <div >
            {!showPushData&&<div className={style['slideButton']} style={{right:pushBoxPos+'px'}} onClick={this.showPushData}>
                朗通智能提醒 
                <img class={style['arrowIcon']} src={arrowIcon} alt=""/>
            </div>}
            {showPushData&&<div id="dragModalWrap" className={style['pushWrapper']} style={{right:pushBoxPos+'px'}} onWheel={this.handleScroll.bind(this)}>
                {/* <div id="dragModalTitle"  className={style['pushDataTitle']}>朗通智能提醒 <span className={style['pushDataHide']} onClick={this.hidePushData}>收起</span></div> */}
                <div className={style['pushDataTitle']}>朗通智能提醒 <span className={style['pushDataHide']} onClick={this.hidePushData}>    <img class={style['hideConfirm']} src={hideConfirm} alt=""/></span></div>
                {hospitalId&&<iframe id='embedPage'  src={url} frameborder="0" width="348" height="507" onWheel={this.handleScroll.bind(this)}></iframe>}
                {!hospitalId&&<div className={style['pushEmpty']}>
                        <div className={style['pushEmptyBox']}>
                            <img className={style['pushEmptyImg']} src={pushEmpty} alt=""/>
                            <p className={style['pushEmptyTxt']}>等待内容输入中…</p>
                        </div>
                </div>}

            </div>}
        </div>
    }
}

export default PushData;