|
@@ -1,21 +1,71 @@
|
|
import React, { Component } from 'react';
|
|
import React, { Component } from 'react';
|
|
import style from './index.less';
|
|
import style from './index.less';
|
|
import close from './../img/close.png';
|
|
import close from './../img/close.png';
|
|
|
|
+import $ from "jquery";
|
|
|
|
+
|
|
|
|
|
|
class DrugInfo extends Component {
|
|
class DrugInfo extends Component {
|
|
constructor(props) {
|
|
constructor(props) {
|
|
super(props);
|
|
super(props);
|
|
|
|
+ this.state = {
|
|
|
|
+ currentIndex: 0
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ handleClickMenu(index, item, drugDesc) {
|
|
|
|
+ const that = this
|
|
|
|
+ setTimeout(function(){
|
|
|
|
+ that.setState({
|
|
|
|
+ currentIndex: index
|
|
|
|
+ })
|
|
|
|
+ },0)
|
|
|
|
+
|
|
|
|
+ let scrollTop = 60 //标题高度为60px
|
|
|
|
+ drugDesc.map((it, ii) => {
|
|
|
|
+ if( ii < index) {
|
|
|
|
+ scrollTop = scrollTop + parseInt($('#' + it.title.trim()).css('height'))
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ $('#drugDesc').scrollTop(scrollTop)
|
|
|
|
+ }
|
|
|
|
+ handleScrollModal(drugDesc) {
|
|
|
|
+ const scrollTop = $('#drugDesc').scrollTop()
|
|
|
|
+ let divHeight = 60; //标题高度为60px
|
|
|
|
+ for (let i = 0; i < drugDesc.length; i++) {
|
|
|
|
+ divHeight = divHeight + parseInt($('#' + drugDesc[i].title.trim()).css('height'))
|
|
|
|
+ if(divHeight > scrollTop) {
|
|
|
|
+ this.setState({
|
|
|
|
+ currentIndex: i
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
render() {
|
|
render() {
|
|
const { drugInfo, hideDrugInfo, drugInfoList,hideDrugInfoMore } = this.props
|
|
const { drugInfo, hideDrugInfo, drugInfoList,hideDrugInfoMore } = this.props
|
|
|
|
+ const { currentIndex } = this.state
|
|
return (<div className={style['drug-info-wrapper']}>
|
|
return (<div className={style['drug-info-wrapper']}>
|
|
<h3 className={style['drug-title']}>{drugInfo.title}说明书 <img src={close} onClick={hideDrugInfo} className={style['close-drug-desc']}/> </h3>
|
|
<h3 className={style['drug-title']}>{drugInfo.title}说明书 <img src={close} onClick={hideDrugInfo} className={style['close-drug-desc']}/> </h3>
|
|
- { drugInfo && drugInfo.drugDesc.length > 0 && <div className={style['drug-desc-wrapper']}>
|
|
|
|
- <div className={style['drug-title1']}>{drugInfo.title}说明书</div>
|
|
|
|
|
|
+ { drugInfo && drugInfo.drugDesc.length > 0 && <div className={style['drug-desc-wrapper']} id='drugDesc' onScroll={this.handleScrollModal.bind(this, drugInfo.drugDesc)}>
|
|
|
|
+ <div className={style['drug-title1']} >{drugInfo.title}说明书</div>
|
|
{drugInfo.drugDesc.map((item, index) =>{
|
|
{drugInfo.drugDesc.map((item, index) =>{
|
|
- return <div className={style['drug-desc-item']}><span className={style['drug-desc-title']}>{item.title.trim()}</span> <div className={style['drug-desc-content']} dangerouslySetInnerHTML ={{__html: item.content}}></div> </div>
|
|
|
|
|
|
+ return <div className={style['drug-desc-item']} id={item.title.trim()}>
|
|
|
|
+ <span className={style['drug-desc-title']} >{item.title.trim()}</span>
|
|
|
|
+ <div className={style['drug-desc-content']} dangerouslySetInnerHTML ={{__html: item.content}}></div>
|
|
|
|
+ </div>
|
|
})}
|
|
})}
|
|
|
|
+ <div className={style['content-menu']}>
|
|
|
|
+ {drugInfo.drugDesc.map((item, index) => {
|
|
|
|
+ return (<div>
|
|
|
|
+ <div className={style['details-menu-title-box']}>
|
|
|
|
+ {index === 0 ? '' : <div className={style['details-content-menu-line']}></div>}
|
|
|
|
+ <span onClick={this.handleClickMenu.bind(this, index, item, drugInfo.drugDesc)} className={style['details-content-menu-name']} style = {index === currentIndex ? {color:'#0089be'} : ''}>
|
|
|
|
+ <span className={style['details-content-menu-circle']} style = {index === currentIndex ? {background:'#0089be'} : ''}></span>{item.title}
|
|
|
|
+ </span>
|
|
|
|
+ </div>
|
|
|
|
+ </div>)
|
|
|
|
+ })}
|
|
|
|
+ </div>
|
|
</div> }
|
|
</div> }
|
|
{ !drugInfo || (drugInfo && drugInfo.drugDesc.length === 0) && <div className={style['drug-desc-wrapper']}>
|
|
{ !drugInfo || (drugInfo && drugInfo.drugDesc.length === 0) && <div className={style['drug-desc-wrapper']}>
|
|
<div>
|
|
<div>
|