result.js
5.17 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
168
169
170
171
172
/*
* 潮流优选、明星原创
*/
'use strict';
import React, {Component} from 'react';
import StudentProductListCell from './StudentProductListCell';
import ReactNative, {
View,
ScrollView,
Text,
NativeAppEventEmitter,
StyleSheet,
ListView,
Image,
TouchableOpacity,
Dimensions,
} from 'react-native';
export default class Result extends Component {
constructor(props) {
super(props);
this._renderRow = this._renderRow.bind(this);
this._renderHeader = this._renderHeader.bind(this);
this._renderSectionHeader = this._renderSectionHeader.bind(this);
this.dataSource = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
}
componentDidMount() {
this.props.fetchStudentProducts();
}
_renderRow(rowData: object, sectionID: number, rowID: number) {
let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
let customStyle = rowID == 0 || rowID == 1 ? {paddingLeft, marginTop: 0} : {paddingLeft};
return (
<StudentProductListCell
style={[styles.listContainer, customStyle]}
key={'row' + rowID}
rowID={rowID}
data={rowData}
onPressProduct={this.props.onPressProduct}
/>
);
}
_renderHeader(){
let {resource} = this.props;
let {verifyResult} = resource?resource:null;
let text = verifyResult?'认证成功!100有货币已放入您的账户':'太遗憾了,您的学校信息未通过审核!';
let {count} = resource?resource:null;
let aaaaa = true;
return (
aaaaa?
<View style={styles.subview}>
<Image style={styles.thumb} source={{uri: 'https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png'}}/>
<Text style={styles.title}>{text}</Text>
<View style={styles.reVerifyView}>
<Text style={styles.customColorTips}>您是所在城市第</Text>
<Text style={styles.redColorTips}>100000</Text>
<Text style={styles.customColorTips}>位认证学生~</Text>
</View>
</View>
:<View style={styles.subview}>
<Image style={styles.thumb} source={{uri: 'https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png'}}/>
<Text style={styles.title}>{text}</Text>
<View style={styles.reVerifyView}>
<Text style={styles.customColorTips}>您可以</Text>
<TouchableOpacity activeOpacity={0.5} onPress={() => {
this.props.onPressBrandItem && this.props.onPressBrandItem(rowData.url);
}}>
<Text style={styles.redColorTips}>重新验证></Text>
</TouchableOpacity>
</View>
</View>
);
}
_renderSectionHeader(){
return (
<Text style={styles.sectionHeader}>学生专属商品</Text>
);
}
render() {
let {resource}=this.props;
let obj= resource?resource.get('studentProducts'):null;
let dataSource = obj?obj.get('product_list'):[];
if (!dataSource || dataSource.size == 0) {
return null;
}
return (
<View style={styles.container}>
<ListView
contentContainerStyle={styles.grid}
dataSource={this.dataSource.cloneWithRows(dataSource.toArray())}
renderRow={this._renderRow}
renderHeader={this._renderHeader}
pressRow={this._pressRow}
renderSectionHeader={this._renderSectionHeader}
enableEmptySections = {true}
/>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let rowWidth = Math.ceil(137.5 * width / 320);
let rowHeight = Math.ceil(254 * width / 320);
let rowMarginTop = Math.ceil(10 * width / 320);
let rowMarginHorizontal = (width - rowWidth * 2) / 3;
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#ffffff',
},
grid: {
flexDirection: 'row',
flexWrap: 'wrap',
},
title: {
color: '#dc143c',
fontSize: 14,
textAlign:'center',
marginTop:8,
},
subview:{
paddingTop:50,
alignItems:'center',
height:200,
width,
},
thumb:{
width:60,
height:60,
alignItems: 'center',
},
reVerifyView:{
alignItems:'center',
flexDirection: 'row',
justifyContent: 'center',
marginTop:8,
},
redColorTips:{
color:'#dc143c',
marginLeft: 5,
fontSize:12,
},
customColorTips:{
color:'#a9a9a9',
fontSize:12,
},
listContainer: {
width: width / 2,
},
sectionHeader: {
height: 33,
width,
backgroundColor: 'gainsboro',
fontSize: 14,
textAlign:'center',
flex: 1,
paddingTop:10,
// borderTopWidth: 0.5, // borderTopWidth 在iPhone 6P上显示有bug
// borderTopColor: '#e0e0e0',
},
});