NameAuthen.js
11.4 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
/**
* Created by misty on 2019/06/05.
*/
'use strict';
import React, {Component} from "react";
import ReactNative ,{
Dimensions,
StyleSheet,
Text,
View,
TouchableOpacity,
TextInput,
ScrollView,
Platform,
Image,
InteractionManager,
} from "react-native";
import Prompt from "../../common/components/Prompt";
import YH_Image from "../../common/components/YH_Image";
import YH_ActionSheet from "../../common/components/YH_ActionSheet";
import ImagePicker from 'react-native-image-picker';
import LoadingIndicator from '../../common/components/LoadingIndicator';
export default class NameAuthen extends Component {
constructor(props) {
super(props);
this.state = {
isBack: false,
backIDCardImageUri: '',
frontIDCardImageUri: '',
}
this.renderHeader = this.renderHeader.bind(this)
this.renderMeritCell = this.renderMeritCell.bind(this)
this.renderIDCardAddDetailCell = this.renderIDCardAddDetailCell.bind(this)
this.actionsheetItemClick = this.actionsheetItemClick.bind(this)
}
renderHeader(title) {
return <View style={styles.headerDetailContainer}>
<View style={{width: width, height: 0.5, backgroundColor: '#e0e0e0'}}/>
<Text style={styles.headerTitle} numberOfLines={1}>{title}</Text>
</View>
}
renderMeritCell(title) {
return <View style={styles.meritCell}>
<View style={styles.meritAnnotation}/>
<Text style={styles.headerDetailTitle}>{title}</Text>
</View>
}
renderIDCardAddDetailCell() {
return (
<View style={styles.renderIDCardAddDetailCell}>
{this.renderIDCardAddCellImage(false)}
{this.renderIDCardAddCellImage(true)}
</View>
)
}
renderIDCardAddCellImage(isBack) {
let title = isBack ? '反面照片' : '正面照片';
let cardImage = isBack ? require('../images/cardBack.png') : require('../images/cardFront.png');
let addImage = isBack ? require('../images/addBack.png') : require('../images/addFront.png');
let imageUrl = isBack ? this.state.backIDCardImageUri : this.state.frontIDCardImageUri;
let hasImage = imageUrl.length > 0 ? true : false;
return (
<View style={styles.renderIDCardAddCellImage}>
<TouchableOpacity activeOpacity={1.0}
onPress={() => {
if(!hasImage){
this.setState({
isBack,
})
this.refs.YH_ActionSheet.showModal();
}
}}>
{hasImage ?
<YH_Image resizeMode="contain" url={imageUrl} style={styles.leftViewImage}/>
:
<Image resizeMode={'contain'} source={addImage} style={isBack ? styles.rightViewImage : styles.leftViewImage}/>
}
</TouchableOpacity>
<TouchableOpacity hitSlop={{top: 3, left: 3, bottom: 3, right: 3}} activeOpacity={1.0} style={styles.addImageClose}
onPress={() => {
if(isBack){
this.setState({
backIDCardImageUri: '',
})
}else {
this.setState({
frontIDCardImageUri: '',
})
}
}}>
{hasImage ?
<Image style={{height: 16,width: 16}} source={require('../images/imageShareClose.png')}/>
: null}
</TouchableOpacity>
<View style={styles.renderIDCardSampleCellImage}>
<Image style={styles.cardImage} source={cardImage}/>
<Text style={styles.cardImageEGtip}>(示例)</Text>
</View>
</View>
)
}
actionsheetItemClick(id){
this.props.showLoading && this.props.showLoading(true);
let that = this;
if(id == 1){
ReactNative.NativeModules.YH_MarketHelper.goUFOIDCardCameraVC(this.state.isBack).then(data => {
InteractionManager.runAfterInteractions(() => {
that.refs.YH_ActionSheet.cancelModal();
if(that.state.isBack){
that.setState({
backIDCardImageUri: data,
})
}else {
that.setState({
frontIDCardImageUri: data,
})
}
that.props.showLoading && that.props.showLoading(false);
});
})
.catch(error => {
that.refs.YH_ActionSheet.cancelModal();
that.props.showLoading && that.props.showLoading(false);
});
}else if(id == 2){
if(Platform.OS == 'ios'){
let options = {
storageOptions: {
skipBackup: true,
path: 'images',
},
};
ImagePicker.launchImageLibrary(options, (response) => {
InteractionManager.runAfterInteractions(() => {
console.log(response);
that.refs.YH_ActionSheet.cancelModal();
let uri = response ? response.uri : '';
if(uri){
if(that.state.isBack){
that.setState({
backIDCardImageUri: uri,
})
}else {
that.setState({
frontIDCardImageUri: uri,
})
}
}
that.props.showLoading && that.props.showLoading(false);
});
});
}
else{
ReactNative.NativeModules.YH_MarketHelper.goPhotoVC().then(data => {
InteractionManager.runAfterInteractions(() => {
that.refs.YH_ActionSheet.cancelModal();
if(that.state.isBack){
that.setState({
backIDCardImageUri: data,
})
}else {
that.setState({
frontIDCardImageUri: data,
})
}
that.props.showLoading && that.props.showLoading(false);
});
})
.catch(error => {
});
}
}
}
render() {
let buttonDisabled = this.state.backIDCardImageUri.length == 0 || this.state.frontIDCardImageUri.length == 0
let isShowToast = this.props.isShowToast;
let toastMessage = this.props.toastMessage;
return <View style={styles.mainContainer}>
<ScrollView style={styles.mainContainer}
keyboardShouldPersistTaps={'handled'}>
{this.renderHeader('请上传身份证照片')}
{this.renderMeritCell('请上传原始比例清晰的身份证正反面。请勿进行裁剪涂改,否则无法通过审核。')}
{this.renderMeritCell('照片格式支持jpg、jpeg、png。')}
{this.renderMeritCell('身份证照片信息将加密处理,仅用于提现财务用途。')}
{this.renderMeritCell('身份证信息需与提现银行卡信息匹配,否则无法正常提现成功。')}
{this.renderIDCardAddDetailCell()}
<TouchableOpacity style={[styles.submitButton, buttonDisabled ? styles.disabledButton : {}]}
disabled={buttonDisabled}
onPress={()=> {
if (this.state.backIDCardImageUri.length > 0 && this.state.frontIDCardImageUri.length > 0) {
this.props.bindIdentityCard && this.props.bindIdentityCard(this.state.frontIDCardImageUri, this.state.backIDCardImageUri);
}
}}>
<Text style={styles.buttonText}>{'提交'}</Text>
</TouchableOpacity>
</ScrollView>
{isShowToast ? <Prompt
text={toastMessage}
duration={800}
onPromptHidden={this.props.hideToastMessage}
/> : null}
<YH_ActionSheet
ref="YH_ActionSheet"
items={[{title:'拍照',id:'1'},{title:'从相册中选择',id:'2'}]}
actionsheetItemClick={this.actionsheetItemClick}
modalTitle={""} />
<LoadingIndicator
isVisible={this.props.isShowLoading}
/>
</View>
}
}
const { width } = Dimensions.get('window');
let styles = StyleSheet.create({
mainContainer: {
flex: 1,
backgroundColor: 'white',
},
headerDetailContainer: {
backgroundColor: 'white',
},
headerTitle: {
marginLeft: 15,
marginTop: 20,
fontFamily: 'PingFang-SC-Medium',
fontSize: 17,
color: '#444444',
letterSpacing: 0,
fontWeight: 'bold',
},
meritCell: {
marginTop: 10,
flexDirection: 'row',
paddingLeft: 15,
paddingRight: 10,
},
meritAnnotation: {
width: 3,
height: 3,
borderRadius: 1.5,
backgroundColor: '#B0B0B0',
marginTop: 8,
},
headerDetailTitle: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 14,
color: '#B0B0B0',
letterSpacing: 0,
marginLeft: 5,
},
cell: {
height: 50,
alignItems: 'center',
flexDirection: 'row',
paddingLeft: 15,
paddingRight: 15,
},
cellTitle: {
fontSize: 14,
fontFamily: 'PingFang-SC-Regular',
color: '#444444',
},
textInput: {
fontSize: 14,
marginLeft: 22,
fontFamily: 'PingFang-SC-Regular',
color: '#B0B0B0',
},
imageText: {
fontFamily: 'PingFang-SC-Regular',
color: '#B0B0B0',
fontSize: 14,
},
buttonText: {
color: 'white',
fontSize: 14,
fontWeight: 'bold',
},
submitButton: {
marginLeft: 15,
marginRight: 15,
marginTop: 44,
height: 44,
borderRadius: 4,
backgroundColor: '#002B47',
alignItems: 'center',
justifyContent: 'center',
},
disabledButton: {
backgroundColor: '#CCCCCC'
},
line: {backgroundColor: '#EEEEEE', left: 20, right: 20, bottom: 0, height: 1, position: 'absolute'},
renderIDCardAddDetailCell: {
flexDirection: 'row',
marginTop: 15,
marginLeft: 15,
marginRight: 15,
justifyContent: 'center',
alignItems: 'center',
},
renderIDCardAddCellImage: {
width: (width-30)/2,
},
leftViewImage: {
width: (width-50)/2,
height: 101,
marginTop: 5,
marginLeft: 0,
backgroundColor: 'transparent',
},
rightViewImage: {
width: (width-50)/2,
height: 101,
marginTop: 5,
marginLeft: 10,
backgroundColor: 'transparent'
},
addImage: {
height: 30,
width: 30,
},
addImageClose: {
position: 'absolute',
height: 16,
width: 16,
top: 0,
left: (width-50)/2-6,
},
renderIDCardSampleCellImage: {
width: (width-30)/2,
marginTop: 30,
alignItems: 'center'
},
cardImage: {
width: 80,
height: 50,
},
cardImageEGtip: {
height: 13,
width: 80,
marginTop: 4,
fontFamily: 'PingFang-SC-Regular',
fontSize: 9,
color: '#999999',
letterSpacing: 0,
textAlign: 'center',
},
})