forked from alibaba/ice
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDownloadCard.jsx
More file actions
167 lines (155 loc) · 4.04 KB
/
DownloadCard.jsx
File metadata and controls
167 lines (155 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import React, { Component } from 'react';
import IceContainer from '@icedesign/container';
import axios from 'axios';
import { Tab, Button, Icon } from '@icedesign/base';
import './DownloadCard.scss';
const { TabPane } = Tab;
export default class DownloadCard extends Component {
static displayName = 'DownloadCard';
static propTypes = {};
static defaultProps = {};
constructor(props) {
super(props);
this.state = {
tabData: {},
};
}
/**
* 异步获取数据
*/
getData = () => {
axios
.get('/mock/download-card.json')
.then((response) => {
this.setState({
tabData: response.data.data || {},
});
})
.catch((error) => {
console.log(error);
});
};
componentDidMount() {
this.getData();
}
renderContent = (data) => {
return data.map((item, index) => {
return (
<div
key={index}
className="column-card-item"
style={styles.columnCardItem}
>
<div style={styles.cardBody}>
<div style={styles.avatarWrapper}>
<img style={styles.img} src={item.img} alt="头像" />
</div>
<p style={styles.title}>{item.title}</p>
<p style={styles.desc}>{item.desc}</p>
</div>
<div style={styles.downloadButtons}>
<Button
href={item.androidSDK}
download
style={styles.leftButton}
type="primary"
>
<Icon type="download" /> Android SDK
</Button>
<Button
href={item.iosSDK}
download
style={styles.rightButton}
type="primary"
>
<Icon type="download" /> IOS SDK
</Button>
</div>
<div style={styles.cardBottom}>
<a href={item.version} style={styles.bottomText}>
版本记录
</a>
<a href={item.docs} style={styles.bottomText}>
集成文档
</a>
<a href={item.guide} style={styles.bottomText}>
使用指南
</a>
<a href={item.faq} style={styles.bottomText}>
FAQ
</a>
</div>
</div>
);
});
};
render() {
const { tabData } = this.state;
return (
<div style={styles.downloadCard}>
<IceContainer>
<Tab type="bar">
<TabPane tab="客户端SDK" key="1">
{tabData.clientSDK
? this.renderContent(tabData.clientSDK)
: '暂无数据'}
</TabPane>
<TabPane tab="服务端SDK" key="2">
{tabData.serverSDK
? this.renderContent(tabData.serverSDK)
: '暂无数据'}
</TabPane>
</Tab>
</IceContainer>
</div>
);
}
}
const styles = {
columnCardItem: {
position: 'relative',
float: 'left',
width: '284px',
height: '280px',
padding: '0px',
marginRight: '16px',
marginBottom: '16px',
overflow: 'hidden',
boxShadow:
'0px 0px 2px 0px rgba(0, 0, 0, 0.1),0px 2px 2px 0px rgba(0, 0, 0, 0.1)',
background: '#fff',
},
cardBody: {
textAlign: 'center',
padding: '20px 0',
marginBottom: '15px',
borderBottom: '1px solid #dedede',
},
avatarWrapper: {
width: '50px',
height: '50px',
overflow: 'hidden',
margin: '0 auto',
},
title: { fontSize: '20px', margin: '10px' },
desc: { fontSize: '15px', color: '#999' },
downloadButtons: { marginBottom: '15px', textAlign: 'center' },
rightButton: { width: '114px', fontSize: '13px', marginLeft: '10px' },
leftButton: { width: '114px', fontSize: '13px' },
cardBottom: {
padding: '10px 10px',
background: '#f6f7f9',
position: 'absolute',
bottom: '0px',
left: '0px',
right: '0px',
},
bottomText: {
marginLeft: '15px',
fontSize: '13px',
color: '#666',
textDecoration: 'none',
},
downloadCard: {},
img: { width: '100%' },
};