import React, { Component, useState, useEffect } from 'react';
import { Card, Row, Col, Statistic, Icon } from 'antd';
// import IndexEcharts from './components/indexEcharts';
// import Swiper from './swiper/index';
import moment from 'moment';
import router from 'umi/router';
import request from '@/utils/request';
import apis from '@/services/apis';

function getDayBegin(dt) {
  return moment(dt, 'day').hours(0).minutes(0).seconds(0).milliseconds(0).format('YYYY-MM-DDTHH:mm:ss')+'.000Z';
}


function getDayEnd(dt) {
  return moment(dt, 'day').hours(23).minutes(59).seconds(59).milliseconds(999).format('YYYY-MM-DDTHH:mm:ss')+'.999Z';
}


const Count = props => {
  const {params} = props
  const [data, setData] = useState([]);


  const [checkData, setCheckData] = useState([]);

  useEffect(() => {
    getList()

  }, [params]);

 const getList =() => {

console.log(params,'params')
    request({
      ...apis.activityDataStatis.total,
      params: {
        ...params,
        // startDate: getDayBegin(params.startDate),
        // endDate: getDayEnd(params.endDate),
      }
    }).then(res => {
    setData(res)
    }).catch(err => {

    })
  }

//   function getBuildingReports() {
//     request({ ...apis.system.taBuildingReports }).then(data => {
//       console.log(
//         (data.records || []).map(x => x.reportCode),
//         '22222222222222222',
//       );
//       setCheckData((data.records || []).map(x => x.reportCode));
//     });
//   }

  return (
    <>
      <Row gutter={16} style={{textAlign:'center'}}>
        <Col span={6}>
          <Card>
            <Statistic
              title="分享总次数"
              value={data.shareNum || 0}
              //   valueStyle={{ color: '#3f8600' }}
            />
          </Card>
        </Col>
        <Col span={6}>
          <Card>
            <Statistic
              title="分享总人数"
              value={data.sharePersonNum || 0}
              //   valueStyle={{ color: '#cf1322' }}
            />
          </Card>
        </Col>
        <Col span={6}>
          <Card>
            <Statistic
              title="访问总次数"
              value={data.visitNum || 0}
              //   valueStyle={{ color: '#3f8600' }}
            />
          </Card>
        </Col>
        <Col span={6}>
          <Card >
            <Statistic
              title="访问总人数"
              value={data.visitPersonNum || 0}
              //   valueStyle={{ color: '#cf1322' }}
            />
          </Card>
        </Col>
      </Row>
    </>
  );
};
export default Count;
