import React, { Component } from 'react';
import style from './index.less';
import $ from 'jquery';
import { imageUrlPrefix } from '@utils/config.js';

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,showPartName} = 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"]}>
                {showPartName ? showPartName : 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 (
                  item.position&&item.position.indexOf('1') > -1&&<div>
                        <div
                          dangerouslySetInnerHTML={{
                            __html: item.title
                          }}
                        />
                        <pre
                          dangerouslySetInnerHTML={{
                            __html: item.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix)
                          }}
                        />
                        {/* {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;

