import * as React from 'react';
import './style.scss'; // 组件内容样式

export default class InfoCard extends React.PureComponent {
  constructor() {
    super();
    this.agreeDataFormat = this.agreeDataFormat.bind(this);
  }
  agreeDataFormat(agreeData) {
    if (agreeData && agreeData <= 9999) {
      return agreeData;
    }
    if (agreeData && agreeData > 9999) {
      return `${Math.floor(agreeData / 1000) / 10}w`;
    }
  }
  render() {
    const { title, backgroundImage, imgCount, commentCount } = this.props;
    const curBackgroundImage =
      backgroundImage || 'https://custom-widgets.bj.bcebos.com/amis-cmp-cli.jpg';
    return (
      <div className="info-card-container">
        <div className="news-title">
          {title ||
            '全场景智能业务管理系统，助力企业构建数字化客户管理平台，推动业务持续增长。'}
        </div>
        <div className="item-imgbox">
          <div
            className="news-img"
            style={{ backgroundImage: `url(${curBackgroundImage})` }}
          ></div>
          {imgCount > 0 && <div className="img-count">{imgCount}</div>}
        </div>
        <div className="news-info">
          <div className="left media-mark">Amis · 低代码平台</div>
          {commentCount && commentCount > 0 && (
            <div className="cmt-num right">
              {this.agreeDataFormat(commentCount)}评
            </div>
          )}
        </div>
      </div>
    );
  }
}
