InfoCell.js
3.67 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
'use strict'
import React, {Component} from 'react';
import {
StyleSheet,
Dimensions,
Platform,
View,
Text,
Image,
TouchableOpacity,
} from 'react-native';
import {Map} from 'immutable';
import YH_Image from '../../common/components/YH_Image';
export default class PersonalInfo extends Component {
constructor(props) {
super(props);
}
render() {
let {dataSource} = this.props;
let cellHeight = 44;
if (dataSource.get('id') == 'portrait') {
cellHeight = 60;
}
let withoutBottomLine = dataSource.get('withoutBottomLine');
let imageUrl = '';
if (dataSource.get('id') == 'portrait' && dataSource.get('url') == '') {
imageUrl = require('../image/avatar_icon.png');
} else if (dataSource.get('id') == 'VIPLevel') {
switch (dataSource.get('content')) {
case '1':
imageUrl = require('../image/VIP1.png');
break;
case '2':
imageUrl = require('../image/VIP2.png');
break;
case '3':
imageUrl = require('../image/VIP3.png');
break;
default:
imageUrl = '';
}
} else if (dataSource.get('id') == 'mineQRCode') {
imageUrl = require('../image/mine_qr.png');
}
let url = YH_Image.getSlicedUrl(dataSource.get('url'), 40, 40, 2); // 商品缩略图
return (
<TouchableOpacity activeOpacity={1.0} onPress={() => {
this.props.onPressInfoCell && this.props.onPressInfoCell(dataSource);
}}>
<View style={[styles.container,{height: cellHeight + (withoutBottomLine?0.0:0.5)}]}>
<View style={[styles.contentContainer,{height: cellHeight}]}>
<Text style={styles.title}>
{dataSource.get('title')}
</Text>
<View style={styles.contentContainer}>
{dataSource.get('id') == 'VIPLevel'?
null
:<Text style={styles.content}>
{dataSource.get('content')}
</Text>
}
{dataSource.get('id') == 'portrait' && dataSource.get('url') != '' ?
<YH_Image url={url} style={styles.userImage} />
:null
}
{imageUrl==''?null:
<Image style={styles.arrow}
source={imageUrl}
/>}
<Image style={styles.arrow}
source={require('../image/cell_indicator.png')}
/>
</View>
</View>
{withoutBottomLine ? null:
<View style={{width: width,height: 0.5,backgroundColor: '#e5e5e5',}}/>
}
</View>
</TouchableOpacity>
);
}
}
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
},
title: {
marginLeft: 15,
},
userImage: {
width: 40,
height: 40,
borderRadius: 20,
marginRight: 15,
},
content:{
color: '#b0b0b0',
marginRight: 14,
fontSize: 12,
},
contentContainer: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
arrow: {
marginRight: 15,
}
});