123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- /*
- *
- */
- import React, { Component } from "react";
- import {
- Platform,
- StyleSheet,
- Text,
- View,
- Image,
- TouchableOpacity,
- FlatList,
- TouchableHighlight,
- DeviceEventEmitter,
- ScrollView,
- ImageBackground
- } from "react-native";
- import BasePage from "../BasePage";
- import Dimensions from '../utils/dimensions';
- export default class Ticket extends BasePage {
- state = {
- data: [
- {
- type: 1,
- price: 12,
- num: 6,
- time: '2019-12-12'
- },
- {
- type: 2,
- price: 50,
- limit: '199',
- time: '2019-12-12'
- }
- ]
- };
- renderItem = (item, index) => {
- return (
- <View>
- {
- item.type === 1
- ? // 抵用券
- <ImageBackground
- source={require('../images/ticket/discount-bg.png')}
- style={styles.type1}
- >
- <View style={styles.topInfo}>
- <View style={styles.left2}>
- <Text style={styles.price}>
- ¥{item.price}
- </Text>
- <Text style={styles.type}>抵用券</Text>
- </View>
- <View style={styles.right2}>
- <Text style={styles.greyText}>购买{item.num}个单课程的奖励</Text>
- <Text style={styles.greyText}>有效期:{item.time}</Text>
- </View>
- </View>
- <View style={styles.bottomInfo}>
- <Text style={styles.greyText}>注:开通会员时方可使用</Text>
- <Text style={styles.blueText}>查看订单</Text>
- </View>
- </ImageBackground>
- : // 优惠券
- <ImageBackground
- source={require('../images/ticket/coupon-bg.png')}
- style={styles.type2}
- >
- <View style={styles.left2}>
- <Text style={styles.price}>
- ¥{item.price}
- </Text>
- <Text style={styles.type}>优惠券</Text>
- </View>
- <View style={styles.right2}>
- <Text style={styles.greyText}>满{item.limit}可用</Text>
- <Text style={styles.greyText}>有效期:{item.time}</Text>
- </View>
- </ImageBackground>
- }
- </View>
- )
- }
- render() {
- return (
- <FlatList
- data={this.state.data}
- horizontal={false}
- renderItem={({ item, index }) => this.renderItem(item, index)}
- keyExtractor={(item, index) => index.toString()}
- />
- )
- }
- }
- const styles = StyleSheet.create({
- type1: {
- width: 343,
- height: 144,
- flexDirection: 'column',
- justifyContent: 'space-between',
- alignItems: 'center',
- paddingTop: 12,
- paddingBottom: 14
- },
- type2: {
- width: 343,
- height: 100,
- flexDirection: 'row',
- justifyContent: 'flex-start',
- alignItems: 'center',
- paddingLeft: 27
- },
- left2: {
- flexDirection: 'column',
- },
- price: {
- color: '#ff6d2f',
- fontSize: 19,
- fontWeight: '500'
- },
- type: {
- color: '#ff6d2f',
- fontSize: 18,
- fontWeight: '500'
- },
- right2: {
- flexDirection: 'column'
- },
- topInfo: {
- flexDirection: 'row',
- alignItems: 'center'
- },
- bottomInfo: {
- width: '100%',
- paddingHorizontal: 12,
- flexDirection: 'row',
- alignItems: 'center',
- justifyContent: 'space-between'
- },
- greyText: {
- fontSize: 14,
- color: '#888'
- },
- blueText: {
- color: '#4a90e2',
- fontSize: 14
- }
- })
|