CouponAlertView.js
4.24 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
'use strict';
import React from 'react';
import ReactNative, {
View,
Text,
Image,
StyleSheet,
Dimensions,
PixelRatio,
TouchableOpacity,
Alert,
} from 'react-native';
import Immutable, {Map} from 'immutable';
export default class CouponAlertView extends React.Component {
constructor(props) {
super(props);
// this.getAlertType = this.getAlertType.bind(this);
}
render() {
let {notSupportReasons, notSupportReasonsTitle, notSupportReasonsMessage} = this.props;
let image = this.getAlertType(notSupportReasons);
return(
<View style={styles.container}>
<TouchableOpacity style={styles.bgContainer} activeOpacity={1} onPress={() => {
this.props.onPressClose && this.props.onPressClose();}}>
</TouchableOpacity>
{
image ?
<View style={styles.imageContainer}>
<Image style={styles.image} source={image}/>
<TouchableOpacity style={styles.closeBtnContainer} activeOpacity={1} onPress={() => {
this.props.onPressClose && this.props.onPressClose();}}>
<Image style={styles.closeBtn} source={require('../../images/close_btn.png')} />
</TouchableOpacity>
{
notSupportReasons == '1' ?
<View style={styles.notSupportContainer}>
<Text style={styles.notSupportTitle}>{notSupportReasonsTitle}</Text>
<Text style={styles.notSupportMessage}>{notSupportReasonsMessage}</Text>
</View>
: null
}
</View>
:
null
}
</View>
);
}
/**
*获取弹框背景图, //1:已领取 2:信息未完善 3:非VIP 4:非生日期间
**/
getAlertType(type){
let img;
switch(type){
case '1':
img = require('../../images/alert_getted.png');
break;
case '2':
img = require('../../images/alert_complete.png');
break;
case '3':
img = require('../../images/alert_vip.png');
break;
case '4':
img = require('../../images/alert_notime.png');
break;
}
return img;
}
};
let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
height = height - 44 * DEVICE_WIDTH_RATIO;
let styles = StyleSheet.create({
container: {
position:'absolute',
top: 0,
left: 0,
height: height,
width: width,
justifyContent: 'center',
alignItems: 'center',
},
bgContainer: {
position:'absolute',
top: 0,
left: 0,
backgroundColor:'rgba(44, 44, 44, 0.5)',
height: height,
width: width,
},
imageContainer: {
width: 240 * DEVICE_WIDTH_RATIO,
height: 240 * DEVICE_WIDTH_RATIO,
},
image: {
position:'absolute',
top: 0,
left: 0,
width: 240 * DEVICE_WIDTH_RATIO,
height: 240 * DEVICE_WIDTH_RATIO,
},
closeBtnContainer: {
position:'absolute',
top: 24 * DEVICE_WIDTH_RATIO,
right: 16 * DEVICE_WIDTH_RATIO,
},
closeBtn: {
width: 16 * DEVICE_WIDTH_RATIO,
height: 16 * DEVICE_WIDTH_RATIO,
},
notSupportContainer: {
position:'absolute',
top: 110 * DEVICE_WIDTH_RATIO,
width: 240 * DEVICE_WIDTH_RATIO,
alignItems: 'center',
justifyContent: 'center',
},
notSupportTitle: {
fontSize: 12,
color: '#ffffff',
fontWeight: 'bold',
textAlign: 'center',
},
notSupportMessage: {
fontSize: 9,
color: '#ffffff',
fontWeight: 'bold',
textAlign: 'center',
marginTop: 8 * DEVICE_WIDTH_RATIO,
marginLeft: 5 * DEVICE_WIDTH_RATIO,
},
});