ActivityOrderDetail.js 4.39 KB
/**活动订单详情页*/

'use strict';

import React, {Component} from 'react';
import {Dimensions, Image, ListView, StyleSheet, Text, TouchableOpacity, View} from 'react-native';
import {Immutable} from 'immutable';

export default class ActivityOrderDetail extends Component {

    constructor(props) {
        super(props);

        // this._renderRow = this._renderRow.bind(this);
        this._renderHeader = this._renderHeader.bind(this);
        // this.dataSource = new ListView.DataSource({
        //     rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
        // });
    }

    _renderHeader() {
        let orderCodes = this.props.orderDetail.orderCodes ? this.props.orderDetail.orderCodes.toArray() : [];
        let orderCodeStr = '';

        orderCodes&& orderCodes.map((orderCode, itemindex) =>
            orderCodeStr = orderCodeStr + orderCode + (itemindex < orderCodes.length - 1 ? '\n' : '')
        )

        return (
            <View>
                <View style={styles.header}>
                    <Text style={[styles.headerText]}>{this.props.orderDetail.statusStr}</Text>
                </View>
                <View style={styles.lineView}/>
                <View style={styles.content}>
                    <Text style={styles.contentText}>活动名称:{this.props.orderDetail.activityName}</Text>
                    <View style={{flexDirection: 'row',width:width, overflow:'hidden'}}>
                        <Text style={styles.contentText}>活动时间:</Text>
                        <Text style={styles.contentText} numberOfLines={2}>{this.props.orderDetail.timeStr}</Text>
                    </View>
                    <View style={{flexDirection: 'row'}}>
                        <Text style={styles.contentText}>佣金金额:</Text>
                        <Text style={[styles.contentText, {fontWeight: 'bold', color: '#D0021B'}]}>{this.props.orderDetail.amountStr}</Text>
                    </View>
                    <View style={{flexDirection: 'row'}}>
                        <Text style={styles.contentText}>订单编号:</Text>
                        <Text style={[styles.contentText, {lineHeight: 18, paddingBottom: 0}]} numberOfLines={orderCodes.length}>{orderCodeStr}</Text>
                    </View>

                </View>
            </View>
        )
    }

    render() {
        let {orderDetail} = this.props;
        let productList = orderDetail.productList ? orderDetail.productList.toArray() : [];
        return (
            <View style={styles.container}>

                {this._renderHeader()}

            </View>
        );
    }

}

let {width, height} = Dimensions.get('window');

let styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#f0f0f0',
        alignItems: 'center'
    },
    contentContainer: {
        width: width,
        backgroundColor: 'white'
    },
    header: {
        width: width,
        height: 50,
        flexDirection: 'row',
        alignItems: 'center',
        backgroundColor: '#FFFFFF',
    },
    content: {
        width: width,
        // height: 180,
        overflow:'hidden',
        padding: 15,
        backgroundColor: '#FFFFFF',
    },
    headerText: {
        fontFamily: 'PingFang-SC-Regular',
        fontSize: 17,
        paddingLeft: 15,
        color: '#444444',
        letterSpacing: -0,
        fontWeight: 'bold',
    },
    contentText: {
        fontFamily: 'PingFang-SC-Regular',
        fontSize: 14,
        paddingBottom: 10,
        color: '#444444',
        letterSpacing: -0,
    },
    rowView: {
        width: width,
        height: 86,
        flexDirection: 'row',
        padding: 10,
    },
    picImage: {
        width: 50,
        height: 66,
        marginLeft: 5,
    },
    titleText: {
        flex:1,
        marginLeft: 10,
        fontSize: 14,
        color: '#444444',
        letterSpacing: -0,
        lineHeight: 18,
        fontFamily: 'PingFang-SC-Regular',
    },
    priceText: {
        fontFamily: 'PingFang-SC-Regular',
        fontSize: 14,
        color: '#D0021B',
        textAlign: 'right',
        letterSpacing: -0.4,
    },
    numText: {
        marginTop: 5,
        fontSize: 12,
        color: '#B0B0B0',
        letterSpacing: -0.34,
        textAlign: 'right',
        fontFamily: 'PingFang-SC-Medium',
    },
    lineView: {
        width: width,
        height: 0.5,
        backgroundColor: '#e0e0e0'
    },
    rightView: {
        width: 95,
    }
});