Alliance.js 6.39 KB
'use strict';

import React from 'react';
import {AppRegistry} from 'react-native';
import createReactClass from 'create-react-class';

import {Provider} from 'react-redux';

import configureStore from './store/configureStore';

import appInitialState from './reducers/app/appInitialState';
import allianceInitialState from './reducers/alliance/allianceInitialState';
import recommendInitialState from './reducers/recommend/recommendInitialState';
import talentRankInitialState from './reducers/talentRank/talentRankInitialState';
import shareDetailInitialState from './reducers/shareDetail/shareDetailInitialState';

import TabContainer from './containers/TabContainer';
import OrderIncomeContainer from './containers/OrderIncomeContainer';
import OrderDetailContainer from './containers/OrderDetailContainer';
import ActivityOrderDetailContainer from './containers/ActivityOrderDetailContainer';
import WithdrawalRecordContainer from './containers/WithdrawalRecordContainer';
import BankCardContainer from './containers/BankCardContainer';
import BankListContainer from './containers/BankListContainer';
import RecommendContainer from './containers/RecommendContainer';
import TalentRankContainer from './containers/TalentRankContainer';
import ShareDetailContainer from './containers/ShareDetailContainer';
import InvitedFriendsContainer from './containers/InvitedFriendsContainer';
import EstimateDetailContainer from './containers/EstimateDetailContainer';

import {setChannel, setHost, setPlatform, setServiceHost, setproductPool, setSkns} from './reducers/app/appActions';
import {setOrderCode, setActivityId, setSrc, setJumpUrl} from './reducers/alliance/allianceActions';


function getInitialState() {
    const _initState = {
        app: (new appInitialState()),
        alliance: (new allianceInitialState()),
        recommend: (new recommendInitialState()),
        talentRank: new talentRankInitialState(),
        shareDetail: (new shareDetailInitialState()),
    };
    return _initState;
}


export default function native(platform) {

    let YH_MineAlliance = createReactClass({

        render() {
            const store = configureStore(getInitialState());
            store.dispatch(setPlatform(platform));
            store.dispatch(setHost(this.props.host));
            store.dispatch(setChannel(this.props.channelId));
            store.dispatch(setServiceHost(this.props.serviceHost));

            let type = this.props.type;
            if (type === 'myAlliance') {
                return (
                    <Provider store={store}>
                        <TabContainer/>
                    </Provider>
                );
            } else if (type === 'orderIncome') {
                return (
                    <Provider store={store}>
                        <OrderIncomeContainer/>
                    </Provider>
                );
            } else if (type === 'orderDetail') {
                store.dispatch(setOrderCode(this.props.orderCode));
                return (
                    <Provider store={store}>
                        <OrderDetailContainer/>
                    </Provider>
                );
            } else if (type === 'activityOrderDetail') {
            // store.dispatch(setActivityId(this.props.orderCode));
            store.dispatch(setOrderCode(this.props.orderCode));
                 return (
                    <Provider store={store}>
                    <ActivityOrderDetailContainer/>
                    </Provider>
                );
            }   else if (type === 'withdrawalRecord') {
                return (
                    <Provider store={store}>
                        <WithdrawalRecordContainer/>
                    </Provider>
                );
            } else if (type === 'bankCard') {
                //为了不重新定义,此次的orderCode 含义 银行卡是否绑定的表示 1未绑定,2绑定
                store.dispatch(setOrderCode(this.props.orderCode));
                return (
                    <Provider store={store}>
                        <BankCardContainer/>
                    </Provider>
                );
            } else if (type === 'bankList') {
                return (
                    <Provider store={store}>
                        <BankListContainer/>
                    </Provider>
                );
            } else if (type === 'talentRank') {
                return (
                    <Provider store={store}>
                        <TalentRankContainer />
                    </Provider>
                );
            } else if (type === 'shareDetail') {
                return (
                    <Provider store={store}>
                        <ShareDetailContainer
                            product_skn={this.props.product_skn}
                            product_id={this.props.product_id}
                            collage_activity_id={this.props.collage_activity_id}
                            collage_price={this.props.collage_price}
                            collage_rebates_amount={this.props.collage_rebates_amount}/>
                    </Provider>
                );
            } else if (type === 'recommendProduct') {
                store.dispatch(setSrc(this.props.src));
                store.dispatch(setJumpUrl(this.props.jumpUrl));
                this.props.productPool && store.dispatch(setproductPool(this.props.productPool))
                this.props.skns && store.dispatch(setSkns(this.props.skns))
                return (
                    <Provider store={store}>
                        <RecommendContainer/>
                    </Provider>
                );
            } else if (type === 'invitedFriends') {
                return (
                    <Provider store={store}>
                        <InvitedFriendsContainer/>
                    </Provider>
                );
            } else if (type === 'estimateDetails') {
                return (
                    <Provider store={store}>
                        <EstimateDetailContainer
                            time_type={this.props.time_type}
                            tab_type={this.props.tab_type}/>
                    </Provider>
                );
            } else {
                return (
                    <Provider store={store}>
                        <TabContainer/>
                    </Provider>
                );
            }
        }
    });

    AppRegistry.registerComponent('YH_MineAlliance', () => YH_MineAlliance);
}