ProductList.js 4.13 KB
'use strict';

import React from 'react';
import ReactNative, {
	AppRegistry,
	Platform,
	StyleSheet,
	Dimensions,
	TouchableOpacity,
} 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 productListForBrandInitialState from './reducers/productListForBrand/productListForBrandInitialState';
import ProductListForBrandContainer from './containers/ProductListForBrandContainer';
import productListForShopInitialState from './reducers/productListForShop/productListForShopInitialState';
import ProductListForShopContainer from './containers/ProductListForShopContainer';
import ProductListPoolContainer from './containers/ProductListPoolContainer';
import ProductListPoolInitialState from './reducers/productListPool/productListPoolInitialState';
import CategoryProListInitialState from './reducers/categoryProList/categoryProListInitialState';

import screenInitialState from './reducers/screen/screenInitialState';
import screenCategoryInitialState from './reducers/screenCategory/screenCategoryInitialState';
import screenSubInitialState from './reducers/screenSub/screenSubInitialState';

import ScreenContainer from './containers/ScreenContainer';
import ScreenCategoryContainer from './containers/ScreenCategoryContainer';
import ScreenSubContainer from './containers/ScreenSubContainer';

import CategoryProductListContainer from './containers/CategoryProListContainer'


import {
	setPlatform,
	setChannel,
	setHost,
	setServiceHost,
	setType,
	setShop,
	setBrandId,
	setoriginParams,
	setSaleType,
	setActivityId,
} from './reducers/app/appActions';

function getInitialState() {
	const _initState = {
		app: (new appInitialState()),
    	productForBrand: (new productListForBrandInitialState()),
		screen: (new screenInitialState()),
		screenCategory: (new screenCategoryInitialState()),
		screenSub: (new screenSubInitialState()),
		productListForShop: (new productListForShopInitialState()),
		productListPool: (new ProductListPoolInitialState()),
		categoryProList: (new CategoryProListInitialState()),
	};
	return _initState;
}

export default function native(platform) {

	let YH_ProductListRNView = React.createClass({

		render() {
		  	const store = configureStore(getInitialState());
			store.dispatch(setPlatform(platform));
			let {host,serviceHost, channel,type,brand_id,shop_id,dictParams,saleType,activityId} = this.props;

			store.dispatch(setHost(host));
			store.dispatch(setServiceHost(serviceHost));
			store.dispatch(setChannel(channel));
			store.dispatch(setType(type));
			store.dispatch(setBrandId(brand_id));
			store.dispatch(setShop(shop_id));
			store.dispatch(setoriginParams(dictParams));
			store.dispatch(setSaleType(saleType));
			store.dispatch(setActivityId(activityId));

			if (type == 'YH_ScreenCategoryView' ) {
				return (
					<Provider store={store}>
						<ScreenContainer />
					</Provider>
				);
			} else if(type == 'YH_ProductFilterCategoryView' ){
				return (
					<Provider store={store}>
						<ScreenCategoryContainer />
					</Provider>
				);
			} else if (type == 'YH_ProductFilterSubView' ){
				return (
					<Provider store={store}>
						<ScreenSubContainer />
					</Provider>
				);
			} else if (type == 'YH_ProductListForBrandRNView' ){
				return (
					<Provider store={store}>
						<ProductListForBrandContainer />
					</Provider>
				);
			} else if (type == 'YH_ProductListForShopRNView' ){
				return (
					<Provider store={store}>
						<ProductListForShopContainer />
					</Provider>
				);
			} else if (type == 'YH_ProductListPoolView' || type == 'YH_VipProListVC' || type == 'YH_PromotionProductListVC' || type == 'YH_OutLetProListVC') {
				return (
					<Provider store={store}>
						<ProductListPoolContainer />
					</Provider>
				);
			} else if (type == 'YH_CategoryProList') {
				return (
					<Provider store={store}>
						<CategoryProductListContainer />
					</Provider>
				);
			}

			return null;
		}
	});

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

let styles = StyleSheet.create({

});