Commit c3fdfd57 by peii

Merge branch 'develop' into product

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