PhoneEditView.js
2.8 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
import React, {Component} from 'react';
import {
View,
Text,
TextInput,
} from 'react-native';
const defaultHeight = (70);
const HPading = (16);
const VPading = (6);
export default class PhoneEditView extends Component {
constructor(props) {
super(props);
this.state = {};
this.attrData = this.props.attrData;
this.onChangeText = this.props.onChangeText;
this.inputType = this.props.inputType || 'numeric';
}
render() {
let {
name, // 名称
code,
type, // 固定:PHONE
description,
isRequired, // 是否必须
isPreview
} = this.attrData;
// data type: 校验类型 固定:ALL=手机和固话|MOBILE=手机|PHONE=固话
let extendData = JSON.parse(this.attrData.data);
let {placeholder} = extendData;
let tabType = extendData.type;
return (
<View style={{
width: '100%',
backgroundColor: 'white',
height: defaultHeight,
paddingVertical: VPading,
paddingHorizontal: HPading
}}>
<View style={{flexDirection: 'row', backgroundColor: '#fff'}}>
{isRequired && <Text style={{color: "#FF3030"}}>* {" "}</Text>}
{!isRequired && <Text style={{color: "#fff"}}>* {" "}</Text>}
<Text style={{fontSize: 16, color: 'rgba(0, 0, 0, 1)', marginBottom: 5}}>{name || ""}</Text>
</View>
<View style={{flexDirection: 'row', width: '100%', alignItems: 'center', marginLeft: HPading}}>
<Text style={{fontSize: 16, color: 'rgba(0, 0, 0, 1)'}}>{'+86 >'}</Text>
<View style={{width: 1, height: 24, backgroundColor: '#f3f4f5', marginHorizontal: 5}}/>
<TextInput
style={{
flex: 1,
fontSize: 14,
backgroundColor: 'white',
textAlign: 'left',
paddingVertical: 5,
paddingHorizontal: 0
}}
maxLength={11}
keyboardType={this.inputType}
onChangeText={text => {
if (this.onChangeText) {
this.onChangeText(text)
}
this.attrData.value = text;
}}
placeholderTextColor={'#999'}
placeholder={placeholder||'请输入'}
underlineColorAndroid="transparent"
/>
</View>
</View>
);
}
}