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 {getUrlArgObject} from '@utils/tools';
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 hideLg  = getUrlArgObject("hideLg");
        const {mrId,isTcm,planCode,showPushData ,windowWidth,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():""}`+(hideLg?`&hideLg=1`:``);
        return <div >
            {!showPushData&&<div className={style['slideButton']} style={{right:pushBoxPos+'px'}} onClick={this.showPushData}>
                {hideLg?'智能提醒':'朗通智能提醒'}
                <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']}>{hideLg?'智能提醒':'朗通智能提醒'} <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="400" height="557" 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;