myContribution.js
5.5 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/**
* Created by xiniu on 2018/4/25.
*/
import React, { Component } from 'react';
import {
StyleSheet,
View,
Text,
Dimensions,
TouchableOpacity,
Image,
TextInput,
FlatList,
ActivityIndicator,
Keyboard,
ScrollView,
} from 'react-native';
import Carousel, { Pagination } from 'react-native-snap-carousel';
import { width, height, zoomW, zoomH } from '../../utils/getSize';
import { xnToast } from '../../utils/utils';
import AppService from '../../service/AppService';
export default class myContribution extends Component {
static navigationOptions = ({ navigation, screenProps }) => ({
title: '我的贡献',
headerLeft: (
<TouchableOpacity style={styles.backWrap} onPress={() => navigation.goBack()}>
<Image source={require('../../img/back_gray.png')} resizeMode="contain" />
</TouchableOpacity>
),
headerRight: (
<View />
),
});
constructor(props) {
super(props);
this.state = {
avatar: global.user.avatar || null,
entries: [1, 1, 1, 1],
activeSlide: 0,
};
}
componentWillMount() {
const _this = this;
AppService.findMyContribution({ userId: global.user.id }).then((data) => {
if (data.message) {
xnToast(data.message);
return;
}
if (!!data.errors === true && !!data.errors.length > 0) {
xnToast(data.errors[0].message);
} else {
// _this.setState({
// entries:data
// })
console.log(global.user, data, '-------------------------');
}
});
}
_renderItem({ item, index }) {
return (
<View style={styles.carouselWrap}>
<Image style={styles.carouselImg} source={require('../../img/carouselBg.png')} resizeMode="contain" />
<Text style={{ fontSize: 18, color: '#FFDA14', marginBottom: 33 / zoomH }}>志愿服务</Text>
<Text style={{ fontSize: 14, color: '#F9F9F9', marginBottom: 13 / zoomH }}>志愿服务共 <Text style={{ fontSize: 18, color: '#FFDA14' }}>28</Text> 次</Text>
<Text style={{ fontSize: 14, color: '#F9F9F9' }}>时间总计 <Text style={{ fontSize: 18, color: '#FFDA14' }}>28</Text> 小时</Text>
</View>
);
}
get pagination() {
const { entries, activeSlide } = this.state;
return (
<Pagination
dotsLength={entries.length}
activeDotIndex={activeSlide}
containerStyle={{
paddingVertical: 0,
}}
dotContainerStyle={{
marginHorizontal: 10 / zoomW,
}}
dotStyle={{
width: 29 / zoomW,
height: 2 / zoomH,
backgroundColor: '#FFFFFF',
borderRadius: 0,
}}
inactiveDotStyle={{
backgroundColor: '#C4C4C4',
}}
inactiveDotScale={1}
inactiveDotOpacity={1}
/>
);
}
render() {
return (
<View style={styles.background}>
<View style={styles.bgImgWrap}>
<Image style={{ width: '100%', height: '100%' }} source={require('../../img/contributionBg.png')} resizeMode="cover" />
</View>
<ScrollView style={{ flex: 1 }}>
<View style={{ paddingTop: 42 / zoomH, alignItems: 'center' }}>
<View style={styles.avatarWrap}>
{this.state.avatar ? <Image source={{ uri: this.state.avatar }} style={{ width: 74 / zoomW, height: 74 / zoomW }} resizeMode="contain" /> :
<Image source={global.user.isPartyMember ? require('../../img/defultPartyIcon.png') : require('../../img/defultIcon.png')} style={{ width: 74 / zoomW, height: 74 / zoomW }} resizeMode="contain" />}
</View>
<View style={styles.baseInfoWrap}>
<Text style={{ fontSize: 13, color: '#FCFCFC' }}>等级:12级</Text>
<View style={styles.gap} />
<Text style={{ fontSize: 13, color: '#FCFCFC' }}>头衔:头衔名</Text>
</View>
</View>
<Carousel
ref={(c) => { this._carousel = c; }}
data={this.state.entries}
renderItem={this._renderItem}
sliderWidth={width}
itemWidth={176 / zoomW}
inactiveSlideScale={0.85}
containerCustomStyle={{ height: 272 / zoomH, marginBottom: 30 / zoomH }}
onSnapToItem={index => this.setState({ activeSlide: index })}
/>
{ this.pagination }
</ScrollView>
</View>
);
}
}
const styles = StyleSheet.create({
backWrap: {
justifyContent: 'center',
paddingLeft: 18.5 / zoomW,
paddingRight: 18.5 / zoomW,
height: 44 / zoomH,
},
background: {
flex: 1,
backgroundColor: 'rgba(0,0,0,0.3)',
display: 'flex',
alignItems: 'center',
position: 'relative',
},
bgImgWrap: {
width: '100%',
height: '100%',
position: 'absolute',
left: 0,
top: 0,
},
baseInfoWrap: {
flexDirection: 'row',
alignItems: 'center',
marginBottom: 27 / zoomH,
},
avatarWrap: {
width: 80 / zoomW,
height: 80 / zoomW,
backgroundColor: '#EFEFEF',
borderRadius: 4 / zoomW,
justifyContent: 'center',
alignItems: 'center',
marginBottom: 27 / zoomH,
},
gap: {
width: 1 / zoomW,
height: 14 / zoomH,
backgroundColor: '#F6F6F6',
marginLeft: 25 / zoomW,
marginRight: 25 / zoomW,
},
carouselWrap: {
width: '100%',
height: '100%',
paddingTop: 31 / zoomH,
alignItems: 'center',
position: 'relative',
},
carouselImg: {
width: '100%',
height: '100%',
position: 'absolute',
left: 0,
top: 0,
},
});