ticket.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. *
  3. */
  4. import React, { Component } from "react";
  5. import {
  6. Platform,
  7. StyleSheet,
  8. Text,
  9. View,
  10. Image,
  11. TouchableOpacity,
  12. FlatList,
  13. TouchableHighlight,
  14. DeviceEventEmitter,
  15. ScrollView,
  16. ImageBackground
  17. } from "react-native";
  18. import BasePage from "../BasePage";
  19. import Dimensions from '../utils/dimensions';
  20. export default class Ticket extends BasePage {
  21. state = {
  22. data: [
  23. {
  24. type: 1,
  25. price: 12,
  26. num: 6,
  27. time: '2019-12-12'
  28. },
  29. {
  30. type: 2,
  31. price: 50,
  32. limit: '199',
  33. time: '2019-12-12'
  34. }
  35. ]
  36. };
  37. renderItem = (item, index) => {
  38. return (
  39. <View>
  40. {
  41. item.type === 1
  42. ? // 抵用券
  43. <ImageBackground
  44. source={require('../images/ticket/discount-bg.png')}
  45. style={styles.type1}
  46. >
  47. <View style={styles.topInfo}>
  48. <View style={styles.left2}>
  49. <Text style={styles.price}>
  50. ¥{item.price}
  51. </Text>
  52. <Text style={styles.type}>抵用券</Text>
  53. </View>
  54. <View style={styles.right2}>
  55. <Text style={styles.greyText}>购买{item.num}个单课程的奖励</Text>
  56. <Text style={styles.greyText}>有效期:{item.time}</Text>
  57. </View>
  58. </View>
  59. <View style={styles.bottomInfo}>
  60. <Text style={styles.greyText}>注:开通会员时方可使用</Text>
  61. <Text style={styles.blueText}>查看订单</Text>
  62. </View>
  63. </ImageBackground>
  64. : // 优惠券
  65. <ImageBackground
  66. source={require('../images/ticket/coupon-bg.png')}
  67. style={styles.type2}
  68. >
  69. <View style={styles.left2}>
  70. <Text style={styles.price}>
  71. ¥{item.price}
  72. </Text>
  73. <Text style={styles.type}>优惠券</Text>
  74. </View>
  75. <View style={styles.right2}>
  76. <Text style={styles.greyText}>满{item.limit}可用</Text>
  77. <Text style={styles.greyText}>有效期:{item.time}</Text>
  78. </View>
  79. </ImageBackground>
  80. }
  81. </View>
  82. )
  83. }
  84. render() {
  85. return (
  86. <FlatList
  87. data={this.state.data}
  88. horizontal={false}
  89. renderItem={({ item, index }) => this.renderItem(item, index)}
  90. keyExtractor={(item, index) => index.toString()}
  91. />
  92. )
  93. }
  94. }
  95. const styles = StyleSheet.create({
  96. type1: {
  97. width: 343,
  98. height: 144,
  99. flexDirection: 'column',
  100. justifyContent: 'space-between',
  101. alignItems: 'center',
  102. paddingTop: 12,
  103. paddingBottom: 14
  104. },
  105. type2: {
  106. width: 343,
  107. height: 100,
  108. flexDirection: 'row',
  109. justifyContent: 'flex-start',
  110. alignItems: 'center',
  111. paddingLeft: 27
  112. },
  113. left2: {
  114. flexDirection: 'column',
  115. },
  116. price: {
  117. color: '#ff6d2f',
  118. fontSize: 19,
  119. fontWeight: '500'
  120. },
  121. type: {
  122. color: '#ff6d2f',
  123. fontSize: 18,
  124. fontWeight: '500'
  125. },
  126. right2: {
  127. flexDirection: 'column'
  128. },
  129. topInfo: {
  130. flexDirection: 'row',
  131. alignItems: 'center'
  132. },
  133. bottomInfo: {
  134. width: '100%',
  135. paddingHorizontal: 12,
  136. flexDirection: 'row',
  137. alignItems: 'center',
  138. justifyContent: 'space-between'
  139. },
  140. greyText: {
  141. fontSize: 14,
  142. color: '#888'
  143. },
  144. blueText: {
  145. color: '#4a90e2',
  146. fontSize: 14
  147. }
  148. })