CardList.js 2.97 KB
Newer Older
1 2
import React, { PureComponent } from 'react';
import { connect } from 'dva';
ddcat1115's avatar
ddcat1115 committed
3
import { Card, Button, Icon, List } from 'antd';
4

niko's avatar
niko committed
5
import Ellipsis from 'components/Ellipsis';
6 7 8 9
import PageHeaderLayout from '../../layouts/PageHeaderLayout';

import styles from './CardList.less';

Andreas Cederström's avatar
Andreas Cederström committed
10 11 12
@connect(({ list, loading }) => ({
  list,
  loading: loading.models.list,
13 14 15
}))
export default class CardList extends PureComponent {
  componentDidMount() {
16 17
    const { dispatch } = this.props;
    dispatch({
18 19 20 21 22 23 24 25
      type: 'list/fetch',
      payload: {
        count: 8,
      },
    });
  }

  render() {
陈帅's avatar
陈帅 committed
26 27 28 29
    const {
      list: { list },
      loading,
    } = this.props;
30 31 32

    const content = (
      <div className={styles.pageHeaderContent}>
afc163's avatar
afc163 committed
33
        <p>
afc163's avatar
afc163 committed
34
          段落示意蚂蚁金服务设计平台 ant.design用最小的工作量无缝接入蚂蚁金服生态
afc163's avatar
afc163 committed
35 36
          提供跨越设计与开发的体验解决方案
        </p>
37 38
        <div className={styles.contentLink}>
          <a>
jim's avatar
jim committed
39 40
            <img alt="" src="https://gw.alipayobjects.com/zos/rmsportal/MjEImQtenlyueSmVEfUD.svg" />{' '}
            快速开始
41 42
          </a>
          <a>
jim's avatar
jim committed
43 44
            <img alt="" src="https://gw.alipayobjects.com/zos/rmsportal/NbuDUAuBlIApFuDvWiND.svg" />{' '}
            产品简介
45 46
          </a>
          <a>
jim's avatar
jim committed
47 48
            <img alt="" src="https://gw.alipayobjects.com/zos/rmsportal/ohOEPSYdDTNnyMbGuyLb.svg" />{' '}
            产品文档
49 50 51 52 53 54 55
          </a>
        </div>
      </div>
    );

    const extraContent = (
      <div className={styles.extraImg}>
jim's avatar
jim committed
56 57 58 59
        <img
          alt="这是一个标题"
          src="https://gw.alipayobjects.com/zos/rmsportal/RzwpdLnhmvDJToTdfDPe.png"
        />
60 61 62 63
      </div>
    );

    return (
jim's avatar
jim committed
64
      <PageHeaderLayout title="卡片列表" content={content} extraContent={extraContent}>
65
        <div className={styles.cardList}>
nikogu's avatar
nikogu committed
66
          <List
nikogu's avatar
nikogu committed
67
            rowKey="id"
nikogu's avatar
nikogu committed
68
            loading={loading}
nikogu's avatar
nikogu committed
69
            grid={{ gutter: 24, lg: 3, md: 2, sm: 1, xs: 1 }}
nikogu's avatar
nikogu committed
70
            dataSource={['', ...list]}
jim's avatar
jim committed
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
            renderItem={item =>
              item ? (
                <List.Item key={item.id}>
                  <Card hoverable className={styles.card} actions={[<a>操作一</a>, <a>操作二</a>]}>
                    <Card.Meta
                      avatar={<img alt="" className={styles.cardAvatar} src={item.avatar} />}
                      title={<a href="#">{item.title}</a>}
                      description={
                        <Ellipsis className={styles.item} lines={3}>
                          {item.description}
                        </Ellipsis>
                      }
                    />
                  </Card>
                </List.Item>
nikogu's avatar
nikogu committed
86 87 88 89 90
              ) : (
                <List.Item>
                  <Button type="dashed" className={styles.newButton}>
                    <Icon type="plus" /> 新增产品
                  </Button>
nikogu's avatar
nikogu committed
91
                </List.Item>
nikogu's avatar
nikogu committed
92
              )
jim's avatar
jim committed
93
            }
nikogu's avatar
nikogu committed
94
          />
95 96 97 98 99
        </div>
      </PageHeaderLayout>
    );
  }
}