PhoneEditView.js 2.05 KB
import React, {Component} from 'react';
import {
    View,
    Text,
    TextInput,
    Image,
} from 'react-native';

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', paddingHorizontal: 5, paddingVertical: 10}}>
                <Text style={{fontSize: 16, color: 'rgba(0, 0, 0, 1)', marginBottom: 5}}>{name}</Text>
                <View style={{flexDirection: 'row', width: '100%', alignItems: 'center'}}>
                    <Text style={{fontSize: 16, color: 'rgba(0, 0, 0, 1)'}}>{'+86 >'}</Text>
                    <View style={{width: 1, height: 24, backgroundColor: 'rgba(245, 245, 245, 1)', marginHorizontal: 5}}/>
                    <TextInput
                        style={{flex: 1, backgroundColor: 'white', textAlign: 'left', paddingVertical: 5}}
                        maxLength={11}
                        keyboardType={this.inputType}
                        onChangeText={text => {
                            if (this.onChangeText) {
                                this.onChangeText(text)
                            }
                        }}
                        placeholderTextColor={'#999'}
                        placeholder={placeholder}
                        underlineColorAndroid="transparent"
                    />
                </View>
            </View>
        );
    }
}