|
@@ -26,10 +26,70 @@ export default class Ticket extends BasePage {
|
|
|
ticket_data: []
|
|
|
};
|
|
|
renderItem = (item, index) => {
|
|
|
+ return this.choseItem(item);
|
|
|
+ };
|
|
|
+ render() {
|
|
|
return (
|
|
|
- <View style={{}}>
|
|
|
- {item.type === 1 ? (
|
|
|
- // 抵用券
|
|
|
+ <View style={{ flex: 1 }}>
|
|
|
+ <StatusBar barStyle={'dark-content'} backgroundColor={'white'} translucent={true} />
|
|
|
+ <View
|
|
|
+ style={{
|
|
|
+ height: 50,
|
|
|
+ backgroundColor: 'white',
|
|
|
+ marginTop: 30
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <CourseTitle
|
|
|
+ width={this.getWindowWidth()}
|
|
|
+ title="抵用券"
|
|
|
+ lefttype={1}
|
|
|
+ textcolor={'#231F20'}
|
|
|
+ backPress={() => this.goBack()}
|
|
|
+ // backPress={() => alert("左侧按钮")}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <View style={{ flex: 0.1, backgroundColor: 'rgba(242, 242, 242, 1)' }} />
|
|
|
+ <View style={{ flex: 5, backgroundColor: 'rgba(242, 242, 242, 1)' }}>
|
|
|
+ {this.state.ticket_data.length > 0 ? (
|
|
|
+ <FlatList
|
|
|
+ data={this.state.ticket_data}
|
|
|
+ horizontal={false}
|
|
|
+ renderItem={({ item, index }) => this.renderItem(item, index)}
|
|
|
+ keyExtractor={(item, index) => index.toString()}
|
|
|
+ />
|
|
|
+ ) : (
|
|
|
+ <Text
|
|
|
+ style={{ height: '100%', width: '100%', textAlign: 'center', textAlignVertical: 'center' }}
|
|
|
+ >
|
|
|
+ 还没有获取到抵用券
|
|
|
+ </Text>
|
|
|
+ )}
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ );
|
|
|
+ }
|
|
|
+ componentWillMount() {
|
|
|
+ //获取用户优惠券信息
|
|
|
+ this.getVoucher();
|
|
|
+ }
|
|
|
+
|
|
|
+ async getVoucher() {
|
|
|
+ await PayServer.getVoucher().then((result) => {
|
|
|
+ if (result.data.length == 0) {
|
|
|
+ } else {
|
|
|
+ this.setState({
|
|
|
+ ticket_data: result.data
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ choseItem(item) {
|
|
|
+ switch (item.type) {
|
|
|
+ case 1:
|
|
|
+ default:
|
|
|
+ // 抵用券
|
|
|
+ return (
|
|
|
<TouchableOpacity
|
|
|
onPress={() => this.userdiscount(item)}
|
|
|
activeOpacity={1}
|
|
@@ -44,7 +104,7 @@ export default class Ticket extends BasePage {
|
|
|
<View style={styles.topInfo}>
|
|
|
<View style={{ flex: 0.5 }} />
|
|
|
<View style={styles.left2}>
|
|
|
- <Text style={styles.price}>¥{item.price}</Text>
|
|
|
+ <Text style={styles.price}>¥{item.amount}</Text>
|
|
|
<Text style={styles.type}>抵用券</Text>
|
|
|
</View>
|
|
|
<View style={{ flex: 0.2 }} />
|
|
@@ -76,6 +136,7 @@ export default class Ticket extends BasePage {
|
|
|
textAlign: 'center',
|
|
|
textAlignVertical: 'center'
|
|
|
}}
|
|
|
+ onPress={() => this.useTicket(item)}
|
|
|
>
|
|
|
立即使用
|
|
|
</Text>
|
|
@@ -86,12 +147,13 @@ export default class Ticket extends BasePage {
|
|
|
<View style={{ flex: 0.2 }} />
|
|
|
<View style={styles.bottomInfo}>
|
|
|
<Text style={styles.greyText}>注:开通会员时方可使用</Text>
|
|
|
- <Text style={styles.blueText}>查看订单</Text>
|
|
|
+ {/* <Text style={styles.blueText}>查看订单</Text> */}
|
|
|
</View>
|
|
|
</ImageBackground>
|
|
|
</TouchableOpacity>
|
|
|
- ) : (
|
|
|
- // 优惠券
|
|
|
+ );
|
|
|
+ case 2:
|
|
|
+ return (
|
|
|
<ImageBackground
|
|
|
source={require('../images/ticket/coupon-bg.png')}
|
|
|
style={styles.type2}
|
|
@@ -107,74 +169,15 @@ export default class Ticket extends BasePage {
|
|
|
<Text style={styles.greyText}>有效期:{item.time}</Text>
|
|
|
</View>
|
|
|
</ImageBackground>
|
|
|
- )}
|
|
|
- </View>
|
|
|
- );
|
|
|
- };
|
|
|
- render() {
|
|
|
- return (
|
|
|
- <View style={{ flex: 1 }}>
|
|
|
- <StatusBar barStyle={'dark-content'} backgroundColor={'white'} translucent={true} />
|
|
|
- <View
|
|
|
- style={{
|
|
|
- height: 50,
|
|
|
- backgroundColor: 'white',
|
|
|
- marginTop: 30
|
|
|
- }}
|
|
|
- >
|
|
|
- <CourseTitle
|
|
|
- width={this.getWindowWidth()}
|
|
|
- title="抵用券"
|
|
|
- lefttype={1}
|
|
|
- textcolor={'#231F20'}
|
|
|
- backPress={() => this.goBack()}
|
|
|
- // backPress={() => alert("左侧按钮")}
|
|
|
- />
|
|
|
- </View>
|
|
|
- <View style={{ flex: 0.1, backgroundColor: 'rgba(242, 242, 242, 1)' }} />
|
|
|
- <View style={{ flex: 5, backgroundColor: 'rgba(242, 242, 242, 1)' }}>
|
|
|
- {this.state.ticket_data.length > 0 ? (
|
|
|
- <FlatList
|
|
|
- data={this.state.ticket_data}
|
|
|
- horizontal={false}
|
|
|
- renderItem={({ item, index }) => this.renderItem(item, index)}
|
|
|
- keyExtractor={(item, index) => index.toString()}
|
|
|
- />
|
|
|
- ) : (
|
|
|
- <Text
|
|
|
- style={{ height: '100%', width: '100%', textAlign: 'center', textAlignVertical: 'center' }}
|
|
|
- >
|
|
|
- 还没有获取到抵用券
|
|
|
- </Text>
|
|
|
- )}
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- );
|
|
|
- }
|
|
|
- componentWillMount() {
|
|
|
- //获取用户优惠券信息
|
|
|
- this.getVoucher();
|
|
|
- }
|
|
|
-
|
|
|
- async getVoucher() {
|
|
|
- await PayServer.getVoucher().then((result) => {
|
|
|
- console.log('====================================');
|
|
|
- console.log('getVoucher', result);
|
|
|
- console.log('====================================');
|
|
|
- if (result.data.length == 0) {
|
|
|
- } else {
|
|
|
- this.setState({
|
|
|
- ticket_data: result.data
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
userdiscount = (item) => {
|
|
|
- if (this.props.navigation.state.params != undefined) {
|
|
|
- this.props.navigation.state.params.choseTicketCallBack(item);
|
|
|
- this.props.navigation.goBack();
|
|
|
- }
|
|
|
+ this.useTicket(item);
|
|
|
+ };
|
|
|
+ useTicket = (ticket_item) => {
|
|
|
+ this.toNextPage('Buy', { to_ticket: ticket_item });
|
|
|
};
|
|
|
}
|
|
|
|