order.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. *
  3. */
  4. import React, { Component } from 'react';
  5. import {
  6. Platform,
  7. StyleSheet,
  8. Text,
  9. View,
  10. Image,
  11. TouchableOpacity,
  12. StatusBar,
  13. FlatList,
  14. BackHandler,
  15. TouchableHighlight,
  16. DeviceEventEmitter,
  17. ScrollView
  18. } from 'react-native';
  19. import BasePage from '../BasePage';
  20. import Dimensions from '../utils/dimensions';
  21. import TopicTitle from '../components/TopicTitle';
  22. import CourseTitle from '../components/CourseTitle';
  23. import NoDataView from '../components/NoDataView';
  24. export default class Order extends BasePage {
  25. state = {
  26. data: [
  27. // { title: '生活好榜样', time: '2019-10-01' },
  28. // { title: '生活好榜样2', time: '2019-10-01' },
  29. // { title: '生活好榜样3', time: '2019-10-01' },
  30. // { title: '生活好榜样第二期', time: '2019-10-01' }
  31. ]
  32. };
  33. renderItem = (item, index) => {
  34. return (
  35. <View>
  36. {/* {index === 0 ? <TopicTitle title={this.state.data.title} ifTubeShow={true} /> : null} */}
  37. <View style={styles.item}>
  38. <View style={styles.left}>
  39. <Text style={styles.title}>{item.title}</Text>
  40. <Text style={styles.time}>购买日期:{item.time}</Text>
  41. </View>
  42. <View style={styles.right}>
  43. <Text style={styles.study}>去学习</Text>
  44. </View>
  45. </View>
  46. </View>
  47. );
  48. };
  49. render() {
  50. return (
  51. <View style={{ flex: 1 }}>
  52. <StatusBar barStyle={'dark-content'} backgroundColor={'white'} translucent={true} />
  53. <View
  54. style={{
  55. height: 50,
  56. backgroundColor: 'white',
  57. marginTop: 30
  58. }}
  59. >
  60. <CourseTitle
  61. width={this.getWindowWidth()}
  62. title="我的订单"
  63. lefttype={1}
  64. textcolor={'#231F20'}
  65. backPress={() => this.goBack()}
  66. // backPress={() => alert("左侧按钮")}
  67. />
  68. </View>
  69. <View style={{ flex: 0.1, backgroundColor: 'rgba(242, 242, 242, 1)' }} />
  70. <View style={{ flex: 5, backgroundColor: 'rgba(242, 242, 242, 1)' }}>
  71. {this.state.data.length > 0 ? (
  72. <FlatList
  73. data={this.state.data}
  74. horizontal={false}
  75. renderItem={({ item, index }) => this.renderItem(item, index)}
  76. keyExtractor={(item, index) => index.toString()}
  77. />
  78. ) : (
  79. <NoDataView style={{ width: '100%', height: '100%' }} text={'你还没有相关订单哦'} />
  80. )}
  81. </View>
  82. </View>
  83. );
  84. }
  85. componentWillMount() {
  86. BackHandler.addEventListener('hardwareBackPress', this.onBackAndroid);
  87. }
  88. componentWillUnmount() {
  89. BackHandler.removeEventListener('hardwareBackPress', this.onBackAndroid);
  90. }
  91. onBackAndroid = () => {
  92. this.goBack();
  93. return true;
  94. };
  95. }
  96. const styles = StyleSheet.create({
  97. item: {
  98. width: Dimensions.width,
  99. height: Dimensions.getHeight(79),
  100. flexDirection: 'row',
  101. justifyContent: 'space-between',
  102. marginBottom: 6,
  103. alignItems: 'center',
  104. paddingHorizontal: 14,
  105. // borderTopWidth: 1,
  106. backgroundColor: 'rgba(255, 255, 255, 1)'
  107. // borderColor: '#f0f1f5'
  108. },
  109. left: {
  110. flexDirection: 'column'
  111. },
  112. title: {
  113. fontSize: 18,
  114. color: '#151515'
  115. },
  116. time: {
  117. fontSize: 14,
  118. color: '#555'
  119. },
  120. right: {
  121. width: Dimensions.getWidth(83),
  122. height: Dimensions.getHeight(27),
  123. borderRadius: 14,
  124. backgroundColor: '#ffae59',
  125. justifyContent: 'center',
  126. alignItems: 'center'
  127. },
  128. study: {
  129. color: '#fff',
  130. fontSize: 16
  131. }
  132. });