home.js
5.22 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
/**
* Created by Cassie on 2018/05/14
*/
import React, { Component } from 'react';
import {
StyleSheet,
View,
Image,
Text,
StatusBar,
TouchableOpacity,
} from 'react-native';
import QRCode from 'react-native-qrcode';
import {zoomW,zoomH} from '../utils/getSize';
import {xnToast,getHeaderPadding} from '../utils/utils';
import AppService from '../service/AppService'
const refresh = require('../img/refresh.png');
const backImg = require('../img/backImg.png');
export default class Home extends Component {
constructor(props) {
super(props);
this.state = {
AnnounceList:[],
ownCount:0,
loading:true,
loadMore:false,
key:'',
type:'',
imageAvatar:{},
random:0,
code:global.code,
modalShow: true
};
}
componentWillMount() {
}
componentDidMount(){
this.props.navigation.setParams({
title:'通行码',
backgroundColor:'#37BF63',
titleColor:'white',
isBack:false,
});
};
componentWillUnmount(){
}
toGetUnionCode(){
AppService.getUserCode({}).then((data) => {
if (data && data.code) {
this.setState({
code:data.code
});
}
this.setState({
loading: false
});
}).catch((error) => {
this.setState({
loading: false
});
xnToast(error)
});
}
render(){
return(
<View style={{flex:1,display:'flex',flexDirection:"column",alignItems:'stretch', justifyContent: 'center',backgroundColor:'#37BF63'}}>
<StatusBar
backgroundColor={'#37BF63'}
networkActivityIndicatorVisible
/>
<View style={{flex:1,display:'flex',flexDirection:"column",alignItems:'stretch', justifyContent: 'center',backgroundColor:'#37BF63'}}>
<View style={{ width: '100%', height: getHeaderPadding() }} />
<View style={[styles.header,{marginBottom: 39/zoomH,flexDirection:"row",}]}>
</View>
<View style={{justifyContent: 'center', alignItems: 'center'}}>
<View style={{width:330/zoomW, height:389/zoomH,borderRadius: 8, backgroundColor: '#ffffff',alignItems: 'center'}}>
<Text style={[styles.textTitleRemind,{marginTop:(39/zoomH)}]}>门禁通行码</Text>
<Text style={[styles.textModelRemind,{marginTop:(10/zoomH),marginBottom:(20/zoomH)}]}>请将二维码对准扫描口扫码开门</Text>
<TouchableOpacity style={[styles.textCenter,{padding:5,width:185/zoomW,height:193/zoomH}]} onPress={() => {this.toGetUnionCode()}}>
<QRCode
value={this.state.code}
size={180/zoomH}
bgColor='black'
fgColor='white'/>
</TouchableOpacity>
<View style={[styles.textCenter,{flexDirection:"row",marginTop:(20/zoomH)}]}>
<Image source={refresh} style={{ width: 11 / zoomW, height: 11 / zoomW }} resizeMode="contain"/><Text style={[styles.textRemind]}> 如超过5分钟有效时间,请点击二维码刷新</Text>
</View>
</View>
<View style={styles.backImgWrap}>
<Image source={backImg} style={{ width: 360 / zoomW, height: 178 / zoomH }} resizeMode="contain"/>
</View>
</View>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
textCenter: {
backgroundColor:'transparent',
flexDirection:"column",
display:'flex',
alignItems:'center',
justifyContent: 'center',
},
backImgWrap: {
width: '100%',
height: 178 / zoomH,
alignItems: 'center',
},
header: {
width: '100%',
height: 55 / zoomH,
justifyContent: 'center',
alignItems: 'center'
},
textRemind:{
opacity: 0.45,
fontSize: 12,
color: '#000000',
},
textModelRemind:{
fontSize: 14,
color: '#888888',
},
textTitleRemind:{
fontSize: 18,
color: '#000000',
},
background:{
flex:1,
backgroundColor:'#ececf1',
display:'flex',
alignItems:'center'
},
itemBackground:{
flex:1,
backgroundColor:'#ffffff',
display:'flex',
alignItems:'center'
},
loadingBg:{
width:'100%',
height:'100%',
position:'absolute',
display:'flex',
alignItems:'center',
justifyContent:'center'
},
loadingBox:{
width:(100/zoomW),
height:(120/zoomH),
backgroundColor:'rgba(0,0,0,.5)',
borderRadius:8,
display:'flex',
alignItems:'center',
justifyContent:'center'
},
})