VIPLevel.js
4.57 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
'use strict'
import React, {Component} from 'react';
import {
StyleSheet,
Dimensions,
Platform,
View,
Text,
Image,
ListView,
TouchableOpacity,
} from 'react-native';
import {Map} from 'immutable';
import VIPPrivilegeCell from './VIPPrivilegeCell';
import VIPLevelHeader from './VIPLevelHeader';
export default class VIPLevel extends Component {
constructor(props) {
super(props);
this.renderRow = this.renderRow.bind(this);
this.renderFooter = this.renderFooter.bind(this);
this.renderHeader = this.renderHeader.bind(this);
this.renderSectionHeader = this.renderSectionHeader.bind(this);
this.renderSeparator = this.renderSeparator.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2),
});
}
renderFooter() {
let {vipInfo} = this.props;
return(
<View style={styles.footer}>
{vipInfo.get('enjoy_preferential') && vipInfo.get('enjoy_preferential').size ?
<View style={{width: width,height: 15,backgroundColor: '#e5e5e5',}}/>
:null
}
<TouchableOpacity activeOpacity={1.0} onPress={() => {
this.props.onPressAllVIPPrivilegeCell && this.props.onPressAllVIPPrivilegeCell();
}}>
<View style={styles.allPrivilegeCell}>
<Text style={{marginLeft: 15, fontSize: 15}}>
查看全部VIP特权
</Text>
<Image style={{marginRight: 15}}
source={require('../image/cell_indicator.png')}
/>
</View>
</TouchableOpacity>
</View>
);
}
renderHeader() {
let {nickname, vipInfo, vipShowPageInfo} = this.props;
return(
<VIPLevelHeader
nickname={nickname}
vipInfo={vipInfo}
vipShowPageInfo={vipShowPageInfo}
/>
);
}
renderSectionHeader(sectionData, sectionID) {
if (!sectionData.length) {
return null;
}
return(
<View key={'sectionHeader' + sectionID} style={styles.sectionHeader}>
<Text style={{lineHeight:38,fontSize:17,color:'#444444',height:58}}>
当前可享受的特权
</Text>
<View style={{width: width,height: 0.5,backgroundColor: '#e5e5e5',}}/>
</View>
);
}
renderRow(rowData,sectionID,rowID) {
return(
<VIPPrivilegeCell
key={'row' + rowID}
dataSource={rowData}
onPressPrivilegeCell={this.props.onPressPrivilegeCell}
rowID={rowID}
/>
);
}
renderSeparator(sectionID, rowID, adjacentRowHighlighted) {
return(
<View key={'separator' + rowID} style={{width: width,height: 0.5,backgroundColor: '#e5e5e5',}}/>
);
}
render() {
let {nickname, isFetching, vipInfo} = this.props;
let dataSource = {};
if (vipInfo.get('enjoy_preferential') && vipInfo.get('enjoy_preferential').size) {
dataSource = {'privilegeSection':vipInfo.get('enjoy_preferential').toArray()};
}
return (
<View style={styles.container}>
<ListView
contentContainerStyle={styles.contentContainer}
enableEmptySections={true}
dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)}
renderRow={this.renderRow}
renderFooter={this.renderFooter}
renderHeader={this.renderHeader}
renderSectionHeader={this.renderSectionHeader}
renderSeparator={this.renderSeparator}
showsVerticalScrollIndicator={false}
/>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#ebebeb',
},
allPrivilegeCell: {
height: 44 * DEVICE_WIDTH_RATIO,
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
backgroundColor: 'white',
},
sectionHeader: {
height: 59,
paddingLeft: 15,
backgroundColor:'white',
},
});