Vip.js 2.56 KB
'use strict';

import React from 'react';
import ReactNative, {
	AppRegistry,
	Platform,
	StyleSheet,
	Dimensions,
	TouchableOpacity,
	View,
} from 'react-native';

import {
	Provider,
	connect
} from 'react-redux';

import configureStore from './store/configureStore';
import {Record, List, Map} from 'immutable';

import appInitialState from './reducers/app/appInitialState';
import yearActivityInitialState from './reducers/yearActivity/yearActivityInitialState';
import YearActivityContainer from './containers/yearActivityContainer';
import fastExpressInitialState from './reducers/fastExpress/fastExpressInitialState';
import FastExpressContainer from './containers/fastExpressContainer';
import birthInitialState from './reducers/birth/birthInitialState';
import BirthContainer from './containers/birthContainer';
import MagazineContainer from './containers/magazineContainer';

import {
	setPlatform,
	setHost,
	setServiceHost,
	setPrivilegeId,
	setUserLevel,
	setChannel,
} from './reducers/app/appActions';



function getInitialState() {
	const _initState = {
		app: (new appInitialState()),
		yearActivity: (new yearActivityInitialState()),
		fastExpress: (new fastExpressInitialState()),
		birth: (new birthInitialState()),
	};
	return _initState;
}

export default function native(platform) {

	let YH_Vip = React.createClass({

		_renderContainer() {
			console.log(this.props.privilegeId);
			//VIP年度优惠特权触达页
            if (this.props.privilegeId == 4) {
                return <YearActivityContainer />;
            }
            //VIP快速送达特权触达页
            else if (this.props.privilegeId == 5) {
                return <FastExpressContainer />;
            }
            //VIP电子杂志特权触达页
            else if (this.props.privilegeId == 6) {
                return <MagazineContainer />;
            }
            //VIP生日特惠特权触达页
            else if (this.props.privilegeId == 8) {
                return <BirthContainer />;
            }
            else
                return <View/>
		},

		render() {
		  	const store = configureStore(getInitialState());
			store.dispatch(setPlatform(platform));
			store.dispatch(setHost(this.props.host));
			store.dispatch(setServiceHost(this.props.serviceHost));
			store.dispatch(setPrivilegeId(this.props.privilegeId));
			store.dispatch(setUserLevel(this.props.userLevel));
			store.dispatch(setChannel(this.props.channel));


			return (
				<Provider store={store}>
					{this._renderContainer()}
				</Provider>
			);
		}
	});

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