Commit 5a762f7c by peii

host支持ip

parent 10f67d54
Showing with 56 additions and 70 deletions
import React, { Component } from 'react'; import React, { Component } from 'react'
import { import { ActionSheet } from '@ant-design/react-native'
View, import { View, Text, Modal, SafeAreaView, TextInput, StyleSheet, TouchableOpacity } from 'react-native'
Text,
Modal,
SafeAreaView,
TextInput,
StyleSheet,
TouchableOpacity
} from 'react-native';
import { import {
safe_view, safe_view,
placehold_text_color, placehold_text_color,
...@@ -21,44 +14,45 @@ import { ...@@ -21,44 +14,45 @@ import {
btn_sub_color, btn_sub_color,
second_text_size, second_text_size,
title_text_color, title_text_color,
pxSize pxSize,
} from '../../../base/BaseStyle'; scale,
import { show } from '../../../utils/Utils'; } from '../../../base/BaseStyle'
import { show } from '../../../utils/Utils'
class FillDomainModel extends Component { class FillDomainModel extends Component {
constructor(props) { constructor(props) {
super(props); super(props)
this.state = { this.state = {
isVisible: false, isVisible: false,
defaDomainHead: 'https://', defaDomainHead: 'http(s)://',
domainValue: '', domainValue: '',
isNull: false isNull: false,
} }
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
if (this.state.isVisible != nextProps.show) { if (this.state.isVisible != nextProps.show) {
this.setState({ this.setState({
isVisible: nextProps.show isVisible: nextProps.show,
}); })
} }
if(this.state.domainValue != nextProps.domainValue) { if (this.state.domainValue != nextProps.domainValue) {
let tempDomain = nextProps.domainValue let tempDomain = nextProps.domainValue
let {isVisible} = this.state let { isVisible } = this.state
if(tempDomain.includes("obs.uat.guke.tech")) { if (tempDomain.includes('obs.uat.guke.tech')) {
// tempDomain = '' // tempDomain = ''
isVisible = true isVisible = true
} }
this.setState({ this.setState({
domainValue: tempDomain, domainValue: tempDomain,
isVisible isVisible,
}) })
} }
} }
closeModal() { closeModal() {
this.setState({ this.setState({
isVisible: false isVisible: false,
}) })
this.props.closeModal(false) this.props.closeModal(false)
} }
...@@ -66,28 +60,32 @@ class FillDomainModel extends Component { ...@@ -66,28 +60,32 @@ class FillDomainModel extends Component {
// 域名 输入 // 域名 输入
handleDomainInput(text) { handleDomainInput(text) {
let isNull = false let isNull = false
if(!text) { if (!text) {
isNull = true isNull = true
} }
this.setState({ this.setState({
domainValue: text, domainValue: text,
isNull isNull,
}) })
} }
// 确定 // 确定
handleSubClick() { handleSubClick() {
let {defaDomainHead, domainValue} = this.state let { domainValue } = this.state
if(!domainValue) { if (!domainValue) {
this.setState({ this.setState({
isNull: true isNull: true,
}) })
return return
} }
// 存储值 !!! // 存储值 !!!
let tempDomain = defaDomainHead+domainValue let host = 'https://' + domainValue
const exp = /^((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])/g
if (exp.test(domainValue)) {
host = 'http://' + domainValue
}
this.closeModal() this.closeModal()
this.props.callback(tempDomain) this.props.callback(host)
} }
renderDialog() { renderDialog() {
...@@ -101,28 +99,23 @@ class FillDomainModel extends Component { ...@@ -101,28 +99,23 @@ class FillDomainModel extends Component {
<View style={styles.cont_cell}> <View style={styles.cont_cell}>
<Text style={styles.input_head}>{defaDomainHead}</Text> <Text style={styles.input_head}>{defaDomainHead}</Text>
<TextInput <TextInput
autoCapitalize='none' autoCapitalize="none"
style={styles.cell_inp_txt} style={styles.cell_inp_txt}
placeholderTextColor={placehold_text_color} placeholderTextColor={placehold_text_color}
returnKeyType="done" returnKeyType="done"
defaultValue={domainValue} defaultValue={domainValue}
placeholder={'请输入域名'} placeholder={'请输入域名'}
keyboardType="email-address" keyboardType="email-address"
onChangeText={(text) => this.handleDomainInput(text)} onChangeText={text => this.handleDomainInput(text)}
/> />
</View> </View>
{ {isNull ? (
isNull ?
<View style={styles.err_input_box}> <View style={styles.err_input_box}>
<Text style={styles.err_input}>请输入域名</Text> <Text style={styles.err_input}>请输入域名</Text>
</View> : null </View>
} ) : null}
<View style={styles.cont_footer}> <View style={styles.cont_footer}>
<TouchableOpacity <TouchableOpacity activeOpacity={0.8} style={styles.sub_btn_box} onPress={() => this.handleSubClick()}>
activeOpacity={.8}
style={styles.sub_btn_box}
onPress={() => this.handleSubClick()}
>
<Text style={styles.sub_tit}>确定</Text> <Text style={styles.sub_tit}>确定</Text>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
...@@ -134,57 +127,51 @@ class FillDomainModel extends Component { ...@@ -134,57 +127,51 @@ class FillDomainModel extends Component {
render() { render() {
return ( return (
<View style={styles.dia_container}> <View style={styles.dia_container}>
<Modal <Modal transparent={true} visible={this.state.isVisible} animationType={'fade'}>
transparent={true}
visible={this.state.isVisible}
animationType={'fade'}
>
<SafeAreaView style={safe_view}> <SafeAreaView style={safe_view}>
<View style={styles.container}> <View style={styles.container}>{this.renderDialog()}</View>
{this.renderDialog()}
</View>
</SafeAreaView> </SafeAreaView>
</Modal> </Modal>
</View> </View>
); )
} }
} }
const styles = StyleSheet.create({ const styles = StyleSheet.create({
dia_container: { dia_container: {
flex: 1 flex: 1,
}, },
container: { container: {
flex: 1, flex: 1,
backgroundColor: 'rgba(0, 0, 0, 0.5)' backgroundColor: 'rgba(0, 0, 0, 0.5)',
}, },
cont_mian: { cont_mian: {
flex: 1, flex: 1,
justifyContent: 'center', justifyContent: 'center',
position: 'relative' position: 'relative',
}, },
cont_inner: { cont_inner: {
position: 'absolute', position: 'absolute',
left: 0, left: 0,
top: pxHeight(196), top: scale(196),
width: Width() - 60, width: Width() - 60,
flex: 1, flex: 1,
flexDirection: 'column', flexDirection: 'column',
backgroundColor: foundation_color, backgroundColor: foundation_color,
height: pxSize(360), height: scale(360),
borderRadius: 10, borderRadius: 10,
marginHorizontal: 30, marginHorizontal: 30,
marginVertical: 20, marginVertical: 20,
paddingTop: 30, paddingTop: 30,
paddingBottom: 60, paddingBottom: 60,
paddingHorizontal: 20 paddingHorizontal: 20,
}, },
cont_tit_box: {}, cont_tit_box: {},
cont_tit: { cont_tit: {
color: promary_text_color, color: promary_text_color,
fontSize: 20, fontSize: 20,
lineHeight: 28, lineHeight: 28,
fontFamily: font_family_semibold fontFamily: font_family_semibold,
}, },
cont_cell: { cont_cell: {
height: 45, height: 45,
...@@ -193,32 +180,32 @@ const styles = StyleSheet.create({ ...@@ -193,32 +180,32 @@ const styles = StyleSheet.create({
borderRadius: 100, borderRadius: 100,
paddingHorizontal: 12, paddingHorizontal: 12,
backgroundColor: '#EFEFEF', backgroundColor: '#EFEFEF',
marginTop: 30 marginTop: 30,
}, },
input_head: { input_head: {
fontSize: 14, fontSize: 14,
fontFamily: font_family_semibold, fontFamily: font_family_semibold,
color: promary_text_color color: promary_text_color,
}, },
cell_inp_txt: { cell_inp_txt: {
paddingLeft: 4, paddingLeft: 4,
fontFamily: font_family_regular, fontFamily: font_family_regular,
fontSize: 14, fontSize: 14,
color: first_text_color, color: first_text_color,
width: '80%' width: '80%',
}, },
err_input_box: { err_input_box: {
paddingLeft: 10, paddingLeft: 10,
paddingTop: 4 paddingTop: 4,
}, },
err_input:{ err_input: {
fontSize: 14, fontSize: 14,
fontFamily: font_family_regular, fontFamily: font_family_regular,
color: '#FF0000' color: '#FF0000',
}, },
cont_footer: { cont_footer: {
flex: 1, flex: 1,
justifyContent: 'flex-end' justifyContent: 'flex-end',
}, },
sub_btn_box: { sub_btn_box: {
width: '100%', width: '100%',
...@@ -231,16 +218,16 @@ const styles = StyleSheet.create({ ...@@ -231,16 +218,16 @@ const styles = StyleSheet.create({
shadowColor: btn_sub_color, shadowColor: btn_sub_color,
shadowOffset: { shadowOffset: {
width: 1, width: 1,
height: 2 height: 2,
}, },
shadowOpacity: 1, shadowOpacity: 1,
elevation: 2, elevation: 2,
borderWidth: 0 borderWidth: 0,
}, },
sub_tit: { sub_tit: {
color: title_text_color, color: title_text_color,
fontSize: second_text_size fontSize: second_text_size,
} },
}) })
export default FillDomainModel; export default FillDomainModel
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment