ActivityOrderDetail.js 4.88 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' : '')
        )

        let isNewActity = this.props.orderDetail.type === 1 ? true : false;

        let activityName = '活动名称:';
        let activityTime = isNewActity ? '发放时间:' : '活动时间:';
        let activityPrice = isNewActity ? '收益金额:' : '佣金金额:';
        let activityAuth = isNewActity ? '被邀请人:' : '订单编号:';

        let numOfLines = isNewActity ? 1 : orderCodes.length;
        let lastText = isNewActity ? this.props.orderDetail.nickname : orderCodeStr;

        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}>{activityName}{this.props.orderDetail.activityName}</Text>
                    <View style={{flexDirection: 'row',width:width, overflow:'hidden'}}>
                        <Text style={styles.contentText}>{activityTime}</Text>
                        <Text style={styles.contentText} numberOfLines={2}>{this.props.orderDetail.timeStr}</Text>
                    </View>
                    <View style={{flexDirection: 'row'}}>
                        <Text style={styles.contentText}>{activityPrice}</Text>
                        <Text style={[styles.contentText, {fontWeight: 'bold', color: '#D0021B'}]}>{this.props.orderDetail.amountStr}</Text>
                    </View>
                    <View style={{flexDirection: 'row'}}>
                        <Text style={styles.contentText}>{activityAuth}</Text>
                        <Text style={[styles.contentText, {lineHeight: 18, paddingBottom: 0}]} numberOfLines={numOfLines}>{lastText}</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,
    }
});