修改 数据传输方式 review by chenlin
Showing
6 changed files
with
23 additions
and
30 deletions
@@ -50,6 +50,15 @@ import { | @@ -50,6 +50,15 @@ import { | ||
50 | setActivityId, | 50 | setActivityId, |
51 | } from './reducers/app/appActions'; | 51 | } from './reducers/app/appActions'; |
52 | 52 | ||
53 | +import { | ||
54 | + updateDataSource | ||
55 | +} from './reducers/screenSub/screenSubActions'; | ||
56 | + | ||
57 | +import { | ||
58 | + updateCategoryDataSource | ||
59 | +} from './reducers/screenCategory/screenCategoryActions'; | ||
60 | + | ||
61 | + | ||
53 | function getInitialState() { | 62 | function getInitialState() { |
54 | const _initState = { | 63 | const _initState = { |
55 | app: (new appInitialState()), | 64 | app: (new appInitialState()), |
@@ -71,8 +80,7 @@ export default function native(platform) { | @@ -71,8 +80,7 @@ export default function native(platform) { | ||
71 | render() { | 80 | render() { |
72 | const store = configureStore(getInitialState()); | 81 | const store = configureStore(getInitialState()); |
73 | store.dispatch(setPlatform(platform)); | 82 | store.dispatch(setPlatform(platform)); |
74 | - let {host, serviceHost, channel, type, brand_id, shop_id, dictParams, saleType, activityId} = this.props; | ||
75 | - | 83 | + let {host, serviceHost, channel, type, brand_id, shop_id, dictParams, saleType, activityId, filterSubMap} = this.props; |
76 | store.dispatch(setHost(host)); | 84 | store.dispatch(setHost(host)); |
77 | store.dispatch(setServiceHost(serviceHost)); | 85 | store.dispatch(setServiceHost(serviceHost)); |
78 | store.dispatch(setChannel(channel)); | 86 | store.dispatch(setChannel(channel)); |
@@ -90,12 +98,14 @@ export default function native(platform) { | @@ -90,12 +98,14 @@ export default function native(platform) { | ||
90 | </Provider> | 98 | </Provider> |
91 | ); | 99 | ); |
92 | } else if(type == 'YH_ProductFilterCategoryView' ){ | 100 | } else if(type == 'YH_ProductFilterCategoryView' ){ |
101 | + store.dispatch(updateCategoryDataSource(filterSubMap)); | ||
93 | return ( | 102 | return ( |
94 | <Provider store={store}> | 103 | <Provider store={store}> |
95 | <ScreenCategoryContainer /> | 104 | <ScreenCategoryContainer /> |
96 | </Provider> | 105 | </Provider> |
97 | ); | 106 | ); |
98 | } else if (type == 'YH_ProductFilterSubView' ){ | 107 | } else if (type == 'YH_ProductFilterSubView' ){ |
108 | + store.dispatch(updateDataSource(filterSubMap)); | ||
99 | return ( | 109 | return ( |
100 | <Provider store={store}> | 110 | <Provider store={store}> |
101 | <ScreenSubContainer /> | 111 | <ScreenSubContainer /> |
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | import React, {Component} from 'react'; | 3 | import React, {Component} from 'react'; |
4 | -import { | 4 | +import ReactNative,{ |
5 | StyleSheet, | 5 | StyleSheet, |
6 | Dimensions, | 6 | Dimensions, |
7 | Platform, | 7 | Platform, |
8 | View, | 8 | View, |
9 | Text, | 9 | Text, |
10 | ListView, | 10 | ListView, |
11 | + NativeAppEventEmitter, | ||
11 | } from 'react-native'; | 12 | } from 'react-native'; |
12 | 13 | ||
13 | import {Map} from 'immutable'; | 14 | import {Map} from 'immutable'; |
@@ -121,6 +122,11 @@ export default class ProductListForShop extends Component { | @@ -121,6 +122,11 @@ export default class ProductListForShop extends Component { | ||
121 | dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)} | 122 | dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)} |
122 | renderRow={this.renderRow} | 123 | renderRow={this.renderRow} |
123 | renderSectionHeader={this.renderSectionHeader} | 124 | renderSectionHeader={this.renderSectionHeader} |
125 | + onScroll={(event) => { | ||
126 | + console.log('onScrollonScrollonScroll') | ||
127 | + console.log(event.nativeEvent.contentOffset.y) | ||
128 | + ReactNative.NativeModules.YH_ProductListRNViewHelper.hideNavigationBar(true); | ||
129 | + }} | ||
124 | renderFooter={()=>{ | 130 | renderFooter={()=>{ |
125 | if (endReached) { | 131 | if (endReached) { |
126 | return <View style={styles.placeholder} />; | 132 | return <View style={styles.placeholder} />; |
@@ -49,13 +49,6 @@ class ScreenCategoryContainer extends Component { | @@ -49,13 +49,6 @@ class ScreenCategoryContainer extends Component { | ||
49 | super(props); | 49 | super(props); |
50 | this.selectItem = this.selectItem.bind(this); | 50 | this.selectItem = this.selectItem.bind(this); |
51 | this.selectSubItem = this.selectSubItem.bind(this); | 51 | this.selectSubItem = this.selectSubItem.bind(this); |
52 | - this.updateFilterCategory = this.updateFilterCategory.bind(this); | ||
53 | - this.subscription = NativeAppEventEmitter.addListener( | ||
54 | - 'updateFilterCategoryView', | ||
55 | - (dic) => { | ||
56 | - this.updateFilterCategory(dic); | ||
57 | - } | ||
58 | - ); | ||
59 | } | 52 | } |
60 | 53 | ||
61 | componentWillUnmount() { | 54 | componentWillUnmount() { |
@@ -72,12 +65,6 @@ class ScreenCategoryContainer extends Component { | @@ -72,12 +65,6 @@ class ScreenCategoryContainer extends Component { | ||
72 | ReactNative.NativeModules.YH_FilterHelper.didSelectCategoryItemFilter({data,key}); | 65 | ReactNative.NativeModules.YH_FilterHelper.didSelectCategoryItemFilter({data,key}); |
73 | } | 66 | } |
74 | 67 | ||
75 | - updateFilterCategory(dic){ | ||
76 | - if (dic) { | ||
77 | - this.props.actions.updateDataSource(dic); | ||
78 | - } | ||
79 | - } | ||
80 | - | ||
81 | render() { | 68 | render() { |
82 | let {app, screenCategory} = this.props; | 69 | let {app, screenCategory} = this.props; |
83 | return ( | 70 | return ( |
@@ -48,25 +48,12 @@ class ScreenSubContainer extends Component { | @@ -48,25 +48,12 @@ class ScreenSubContainer extends Component { | ||
48 | constructor(props) { | 48 | constructor(props) { |
49 | super(props); | 49 | super(props); |
50 | this.selectItem = this.selectItem.bind(this); | 50 | this.selectItem = this.selectItem.bind(this); |
51 | - this.updateFilterSub = this.updateFilterSub.bind(this); | ||
52 | - this.subscription = NativeAppEventEmitter.addListener( | ||
53 | - 'updateFilterSub', | ||
54 | - (dic) => { | ||
55 | - this.updateFilterSub(dic); | ||
56 | - } | ||
57 | - ); | ||
58 | } | 51 | } |
59 | 52 | ||
60 | componentWillUnmount() { | 53 | componentWillUnmount() { |
61 | this.subscription && this.subscription.remove(); | 54 | this.subscription && this.subscription.remove(); |
62 | } | 55 | } |
63 | 56 | ||
64 | - updateFilterSub(dic){ | ||
65 | - if (dic) { | ||
66 | - this.props.actions.updateDataSource(dic); | ||
67 | - } | ||
68 | - } | ||
69 | - | ||
70 | selectItem(data,key){ | 57 | selectItem(data,key){ |
71 | this.props.actions.selectItem(data,key); | 58 | this.props.actions.selectItem(data,key); |
72 | ReactNative.NativeModules.YH_FilterHelper.didSelectFilterSubItem({data,key}); | 59 | ReactNative.NativeModules.YH_FilterHelper.didSelectFilterSubItem({data,key}); |
@@ -9,7 +9,7 @@ const { | @@ -9,7 +9,7 @@ const { | ||
9 | } = require('../../constants/actionTypes').default; | 9 | } = require('../../constants/actionTypes').default; |
10 | 10 | ||
11 | 11 | ||
12 | -export function updateDataSource(data) { | 12 | +export function updateCategoryDataSource(data) { |
13 | return { | 13 | return { |
14 | type: SET_DATASOURCE_CATEGORY, | 14 | type: SET_DATASOURCE_CATEGORY, |
15 | payload: data | 15 | payload: data |
@@ -9,6 +9,9 @@ const { | @@ -9,6 +9,9 @@ const { | ||
9 | 9 | ||
10 | 10 | ||
11 | export function updateDataSource(data) { | 11 | export function updateDataSource(data) { |
12 | + if (!data) { | ||
13 | + return; | ||
14 | + } | ||
12 | let key = data?data.key:''; | 15 | let key = data?data.key:''; |
13 | let json = data; | 16 | let json = data; |
14 | if (key == 'brand') { | 17 | if (key == 'brand') { |
-
Please register or login to post a comment