import React, { Component } from 'react';
import style from './index.less';
import $ from 'jquery';

class TipsMsg extends Component {
    constructor(props) {
        super(props);
    }
    componentWillReceiveProps(next){
        //滚动条定位到提示信息模块
      if(JSON.stringify(next.tips)!=JSON.stringify(this.props.tips)){
        const {patDom} = this.props;
        const ht = $(patDom.current).height();
        $(patDom.current).scrollTop(ht);
      }
    }

    render() {
        const { tips, showTips, tipsDiscalimer, tipsImg, tmpFlg} = this.props;
        return <div id="tipsMsg" className={style["tips"]}>
        <h1>
          <img src={tipsImg} />
          提示信息
        </h1>
        <div className={style["content"]}>
          {tips && tips.details ? (
            <div>
              <div className={style["title"]}>
                {tips.name}
                <span
                  className={style["tips-details"]}
                  onClick={() => showTips()}
                  // style={{display:tmpFlg?'none':'inline-block'}}
                >
                  详情
                </span>
              </div>
              {tips.details &&
                tips.details.map((item, index) => {
                  return (
                      <div>
                        <div
                          dangerouslySetInnerHTML={{
                            __html: item.title
                          }}
                        />
                        <div
                          dangerouslySetInnerHTML={{
                            __html: item.content
                          }}
                        />
                        {item.isReason === 1 && (
                          <div className={style["warn"]}>
                            {tipsDiscalimer.data.data &&tipsDiscalimer.data.data.find(item => item.disclaimerCode == '1')&&tipsDiscalimer.data.data.find(item => item.disclaimerCode == '1').description}
                          </div>
                        )}
                      </div>
                  );
                })}
            </div>
          ) : (
            "无"
          )}
        </div>
    </div>
    }
}

export default TipsMsg;

