OrderPage.js 2.79 KB
'use strict';

import React, {Component} from 'react';
import ReactNative, {
    View,
    Text,
    Image,
    StyleSheet,
    Dimensions,
    InteractionManager,
    Platform,
} from 'react-native';

import {Map, Record} from 'immutable';

import OrderList from './OrderList';
import AntiFraudTip from '../detail/AntiFraudTip';
import ScrollableTabView,{DefaultTabBar} from 'react-native-scrollable-tab-view';

export default class OrderPage extends Component {
    constructor(props) {
        super(props);
    }

    render(){

        let list = this.props.resource;
        let initialPage = list.get('defaultPageIndex');
        let showAntiFraud = this.props.showAntiFraud;

        let types = [];
        types.push({type: 'all',name: '全部'});
        types.push({type: 'onPay',name: '待付款'});
        types.push({type: 'onDelivery',name: '待发货'});
        types.push({type: 'onReceive',name: '待收货'});
        return(
            <View style={styles.container}>
                {showAntiFraud ? <AntiFraudTip onPressAntiFraudTip={this.props.onPressAntiFraudTip}/> : null}

                <ScrollableTabView
                    initialPage={initialPage}
                    renderTabBar={() => <DefaultTabBar
                        style={{height:38, borderWidth: 0.5, borderBottomColor: '#ededed', backgroundColor: 'white'}}
                        textStyle={{paddingTop:10, fontFamily: 'STHeitiSC-Light', fontSize: 14, fontWeight: 'normal'}}
                        underlineHeight={0}
                        activeTextColor={'black'}
                        inactiveTextColor={'#b0b0b0'} />
                    }
                    onChangeTab={(obj) => {
                    }}
                >

                {types.map((item, i) => {
                    let type = item.type;
                    let name = item.name;
                    return (
                        <OrderList
                            tabLabel={name}
                            key={i}
                            dataSource={list.get(type)}
                            type={type}
                            onRefresh={this.props.onRefresh}
                            onLoadMore={this.props.onLoadMore}
                            orderAction={this.props.orderAction}
                            onGoDetail={this.props.onGoDetail}
                            onPressDelayNotice={this.props.showDelayDeliveryNotice}
                            onPressEmptyItem={this.props.onPressEmptyItem}
                        />
                    );
                })}

                </ScrollableTabView>
            </View>

        );
    }
}

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

let styles = StyleSheet.create({
    container: {
        flex: 1,
        flexDirection: 'column',
        backgroundColor: '#ededed'
    },
});