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

5
import Ellipsis from '@/components/Ellipsis';
6
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
7 8 9

import styles from './CardList.less';

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

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

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

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

    return (
65
      <PageHeaderWrapper title="卡片列表" content={content} extraContent={extraContent}>
66
        <div className={styles.cardList}>
nikogu's avatar
nikogu committed
67
          <List
nikogu's avatar
nikogu committed
68
            rowKey="id"
nikogu's avatar
nikogu committed
69
            loading={loading}
nikogu's avatar
nikogu committed
70
            grid={{ gutter: 24, lg: 3, md: 2, sm: 1, xs: 1 }}
nikogu's avatar
nikogu committed
71
            dataSource={['', ...list]}
jim's avatar
jim committed
72 73 74 75 76 77
            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} />}
陈帅's avatar
陈帅 committed
78
                      title={<a>{item.title}</a>}
jim's avatar
jim committed
79 80 81 82 83 84 85 86
                      description={
                        <Ellipsis className={styles.item} lines={3}>
                          {item.description}
                        </Ellipsis>
                      }
                    />
                  </Card>
                </List.Item>
nikogu's avatar
nikogu committed
87 88 89 90 91
              ) : (
                <List.Item>
                  <Button type="dashed" className={styles.newButton}>
                    <Icon type="plus" /> 新增产品
                  </Button>
nikogu's avatar
nikogu committed
92
                </List.Item>
nikogu's avatar
nikogu committed
93
              )
jim's avatar
jim committed
94
            }
nikogu's avatar
nikogu committed
95
          />
96
        </div>
97
      </PageHeaderWrapper>
98 99 100
    );
  }
}