import React, { Component } from 'react'; import style from './index.less'; import $ from "jquery"; import close from './img/close.png'; import info from './img/info.png'; import info1 from './img/info1.png'; import info2 from './img/info2.png'; import info3 from './img/info3.png'; class TreatDesc extends Component { constructor(props){ super(props); this.state = { currentIndex: -1, hasEnterImg: false } this.hideTreatDesc = this.hideTreatDesc.bind(this); this.handleSelect= this.handleSelect.bind(this); this.handleMouseEnterDrug = this.handleMouseEnterDrug.bind(this) this.handleMouseLeaveDrug = this.handleMouseLeaveDrug.bind(this) this.handleMouseEnterImg = this.handleMouseEnterImg.bind(this) this.handleMouseLeaveImg = this.handleMouseLeaveImg.bind(this) } handleMouseEnterDrug( index, item) { // console.log('item', item) const drugNameWidth = parseInt($('#'+item.medicitionName)[0].offsetWidth) const imgLeft = drugNameWidth/2-10 console.log('imgLeft', imgLeft) $('#'+item.medicitionName).find('img').css('left', imgLeft) this.setState({ currentIndex: index, }) } handleMouseLeaveDrug() { this.setState({ currentIndex: -1, }) } handleMouseEnterImg() { this.setState({ hasEnterImg: true }) } handleMouseLeaveImg() { this.setState({ hasEnterImg: false }) } handleSelect(index,ii) { const { selectDrug } = this.props; selectDrug && selectDrug(index,ii); } hideTreatDesc() { $('#treatDescBox').css({'display': 'none'}); $('#treatDescBox').animate({'display': 'none'}, 500); $('#treatWrapper').animate({'margin-left': '-340px','left':'50%'}, 500); } render(){ const { treatment, treatDesc, setDrugInfo, showDrugInfo} = this.props const { title, basic, otherDrugIndex, drugDesc} = treatDesc const { currentIndex, hasEnterImg } = this.state return (treatment && treatment.length >0 &&