...
|
...
|
@@ -24,15 +24,22 @@ export default class AddCoupon extends Component { |
|
|
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.textInputChange = this.textInputChange.bind(this);
|
|
|
this.state = {
|
|
|
disable: true,
|
|
|
text: '',
|
|
|
};
|
|
|
}
|
|
|
|
|
|
shouldComponentUpdate(nextProps){
|
|
|
|
|
|
if (Immutable.is(nextProps.resource, this.props.resource)) {
|
|
|
return false;
|
|
|
} else {
|
|
|
return true;
|
|
|
textInputChange(event) {
|
|
|
let dis = true;
|
|
|
if (event.nativeEvent.text) {
|
|
|
dis = false;
|
|
|
}
|
|
|
this.setState({
|
|
|
disable: dis,
|
|
|
text: event.nativeEvent.text,
|
|
|
});
|
|
|
}
|
|
|
|
|
|
render() {
|
...
|
...
|
@@ -43,31 +50,33 @@ export default class AddCoupon extends Component { |
|
|
let needShowToast = data?data.showMessage:false;
|
|
|
let message = data?data.message:false;
|
|
|
|
|
|
console.log(data);
|
|
|
|
|
|
return (
|
|
|
<View style={styles.container}>
|
|
|
<TextInput
|
|
|
autoCapitalize="none"
|
|
|
clearButtonMode="always"
|
|
|
placeholder={'输入优惠劵码'}
|
|
|
onChange={this.props.updateValue}
|
|
|
style={styles.textInput}
|
|
|
maxLength={50}
|
|
|
underlineColorAndroid="transparent"
|
|
|
onFocus={() => {
|
|
|
//this.props.onFocus && this.props.onFocus(refId);
|
|
|
}}
|
|
|
/>
|
|
|
<TouchableOpacity activeOpacity={1}
|
|
|
onPress={() => {
|
|
|
// this.props.onPressUseNow && this.props.onPressUseNow(resource)
|
|
|
}}
|
|
|
>
|
|
|
<View style={{marginTop: 10,marginLeft: 10,width: 70,height: 35 * DEVICE_WIDTH_RATIO,backgroundColor: 'red',borderRadius: 5,alignItems: 'center',justifyContent: 'center'}}>
|
|
|
<Text style={styles.text}>确定</Text>
|
|
|
</View>
|
|
|
</TouchableOpacity>
|
|
|
<View style={styles.contentContainer}>
|
|
|
<TextInput
|
|
|
multiline={true}
|
|
|
autoCapitalize={'none'}
|
|
|
clearButtonMode={'always'}
|
|
|
placeholder={'输入优惠劵码'}
|
|
|
onChange={this.textInputChange}
|
|
|
style={styles.textInput}
|
|
|
maxLength={50}
|
|
|
underlineColorAndroid="transparent"
|
|
|
/>
|
|
|
<TouchableOpacity activeOpacity={1}
|
|
|
onPress={() => {
|
|
|
if (!this.state.disable) {
|
|
|
let dismissKeyboard = require('dismissKeyboard');
|
|
|
dismissKeyboard();
|
|
|
this.props.onPressOK && this.props.onPressOK(this.state.text)
|
|
|
}
|
|
|
}}
|
|
|
>
|
|
|
<View style={{marginTop: 10,marginLeft: 10,width: 70,height: 35 * DEVICE_WIDTH_RATIO,backgroundColor: this.state.disable?'gray':'red',borderRadius: 5,alignItems: 'center',justifyContent: 'center'}}>
|
|
|
<Text style={styles.text}>确定</Text>
|
|
|
</View>
|
|
|
</TouchableOpacity>
|
|
|
</View>
|
|
|
{needShowToast ? <Prompt
|
|
|
text={message}
|
|
|
duration={1000}
|
...
|
...
|
@@ -86,6 +95,9 @@ const DEVICE_WIDTH_RATIO = width / 320; |
|
|
|
|
|
let styles = StyleSheet.create({
|
|
|
container: {
|
|
|
flex: 1,
|
|
|
},
|
|
|
contentContainer: {
|
|
|
flexDirection: 'row',
|
|
|
},
|
|
|
textInput: {
|
...
|
...
|
|