myContribution.js
3.11 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
/**
* Created by tdzl2003 on 12/18/16.
*/
import React, {Component, PropTypes} from "react";
import {
Dimensions,
Image,
ScrollView,
StyleSheet,
Text,
TouchableOpacity,
View,
Platform,
FlatList,
BackHandler,
ActivityIndicator,
StatusBar,
NativeModules
} from "react-native";
import {zoomW,zoomH} from '../../utils/getSize';
const noResult = require('../../img/noResult.png');
const logo = require('../../img/logo.png');
import xnService from "../../service/AppService";
import {clock,xnToast,timeReduce,timePlus,timeEvery,getDay} from '../../utils/utils';
export default class myContribution extends Component {
static navigationOptions = ({navigation}) => ({
headerTitle:'我的贡献',
headerLeft:(
<TouchableOpacity style={styles.backWrap} onPress={() => navigation.goBack()}>
<Image source={require('../../img/back_gray.png')} resizeMode="contain" />
</TouchableOpacity>
),
headerRight:(
<View></View>
)
});
constructor(){
super()
this.state = {
loading:false,
escortCount:'0',
escortTime:''
};
}
componentDidMount(){
this.state = {
loading:true,
};
let prams={
id:global.user.id
}
xnService.getUserById(prams).then((data)=>{
this.setState({
loading:false
});
if(data.message){
xnToast(data.message);
return;
}
if(data.errors.length > 0){
xnToast(data.errors[0].message);
}else{
this.setState({
escortCount:data.user.escortCount,
escortTime:data.user.escortTime
})
}
})
}
render(){
return(
<View style={styles.bg}>
<StatusBar barStyle={'default'}/>
<View style={{flex:1,backgroundColor:'#f6f6f6',alignItems:'center',justifyContent:'center'}}>
<Text >我的护行次数:</Text>
<Text style={{fontSize:18,marginTop:20}}>45次</Text>
<Text style={{marginTop:40}}>我的护行时间:</Text>
<Text style={{fontSize:17,marginTop:20}}>{timeEvery(this.state.escortTime,'day')}</Text>
</View>
{this.state.loading && <View style={styles.loadingBg}>
<ActivityIndicator size="large" />
</View>}
</View>
)
}
}
const styles = StyleSheet.create({
backWrap: {
justifyContent: 'center',
paddingLeft: 18.5/zoomW,
paddingRight: 18.5/zoomW,
height: 44/zoomH,
},
back: {
width: 8.5/zoomW,
height: 15/zoomH,
},
bg:{
flex:1,
backgroundColor:'#f6f6f6',
},
loadingBg:{
width:'100%',
height:'100%',
position:'absolute',
display:'flex',
alignItems:'center',
justifyContent:'center'
},
});