|
@@ -19,33 +19,15 @@ import {
|
|
|
import BasePage from '../BasePage';
|
|
|
import Dimensions from '../utils/dimensions';
|
|
|
import CourseTitle from '../components/CourseTitle';
|
|
|
+import PayServer from '../services/Pay';
|
|
|
|
|
|
export default class Ticket extends BasePage {
|
|
|
state = {
|
|
|
- data: [
|
|
|
- {
|
|
|
- type: 1,
|
|
|
- price: 12,
|
|
|
- num: 6,
|
|
|
- time: '2019-12-12'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 1,
|
|
|
- price: 33,
|
|
|
- num: 9,
|
|
|
- time: '2019-12-12'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 1,
|
|
|
- price: 50,
|
|
|
- limit: '199',
|
|
|
- time: '2019-12-12'
|
|
|
- }
|
|
|
- ]
|
|
|
+ ticket_data: []
|
|
|
};
|
|
|
renderItem = (item, index) => {
|
|
|
return (
|
|
|
- <View style={{ justifyContent: 'center', alignItems: 'center' }}>
|
|
|
+ <View style={{}}>
|
|
|
{item.type === 1 ? (
|
|
|
// 抵用券
|
|
|
<TouchableOpacity
|
|
@@ -60,12 +42,12 @@ export default class Ticket extends BasePage {
|
|
|
>
|
|
|
<View style={{ flex: 0.3 }} />
|
|
|
<View style={styles.topInfo}>
|
|
|
- <View style={{ flex: 1.3 }} />
|
|
|
+ <View style={{ flex: 0.5 }} />
|
|
|
<View style={styles.left2}>
|
|
|
<Text style={styles.price}>¥{item.price}</Text>
|
|
|
<Text style={styles.type}>抵用券</Text>
|
|
|
</View>
|
|
|
- <View style={{ flex: 0.05 }} />
|
|
|
+ <View style={{ flex: 0.2 }} />
|
|
|
<View style={styles.right2}>
|
|
|
<Text style={{ fontSize: 16, color: 'rgba(22, 22, 22, 1)' }}>
|
|
|
购买{item.num}个单课程的奖励
|
|
@@ -99,15 +81,12 @@ export default class Ticket extends BasePage {
|
|
|
</Text>
|
|
|
</ImageBackground>
|
|
|
</View>
|
|
|
- <View style={{ flex: 1.5 }} />
|
|
|
+ <View style={{ flex: 1 }} />
|
|
|
</View>
|
|
|
<View style={{ flex: 0.2 }} />
|
|
|
<View style={styles.bottomInfo}>
|
|
|
- <View style={{ flex: 1 }} />
|
|
|
<Text style={styles.greyText}>注:开通会员时方可使用</Text>
|
|
|
- <View style={{ flex: 1 }} />
|
|
|
<Text style={styles.blueText}>查看订单</Text>
|
|
|
- <View style={{ flex: 1 }} />
|
|
|
</View>
|
|
|
</ImageBackground>
|
|
|
</TouchableOpacity>
|
|
@@ -154,16 +133,42 @@ export default class Ticket extends BasePage {
|
|
|
</View>
|
|
|
<View style={{ flex: 0.1, backgroundColor: 'rgba(242, 242, 242, 1)' }} />
|
|
|
<View style={{ flex: 5, backgroundColor: 'rgba(242, 242, 242, 1)' }}>
|
|
|
- <FlatList
|
|
|
- data={this.state.data}
|
|
|
- horizontal={false}
|
|
|
- renderItem={({ item, index }) => this.renderItem(item, index)}
|
|
|
- keyExtractor={(item, index) => index.toString()}
|
|
|
- />
|
|
|
+ {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) {
|
|
@@ -190,7 +195,7 @@ const styles = StyleSheet.create({
|
|
|
alignItems: 'center'
|
|
|
},
|
|
|
left2: {
|
|
|
- flex: 1,
|
|
|
+ flex: 1.2,
|
|
|
flexDirection: 'column'
|
|
|
},
|
|
|
price: {
|
|
@@ -204,7 +209,7 @@ const styles = StyleSheet.create({
|
|
|
fontWeight: '500'
|
|
|
},
|
|
|
right2: {
|
|
|
- flex: 2.8,
|
|
|
+ flex: 3.5,
|
|
|
flexDirection: 'column',
|
|
|
marginTop: 10
|
|
|
},
|
|
@@ -214,9 +219,9 @@ const styles = StyleSheet.create({
|
|
|
alignItems: 'center'
|
|
|
},
|
|
|
bottomInfo: {
|
|
|
- width: '100%',
|
|
|
+ width: '90%',
|
|
|
flex: 1,
|
|
|
- paddingHorizontal: 12,
|
|
|
+ // paddingHorizontal: 12,
|
|
|
flexDirection: 'row',
|
|
|
alignItems: 'center',
|
|
|
justifyContent: 'space-between'
|