add 筛选 review by qiangbing
Showing
29 changed files
with
1005 additions
and
18 deletions
@@ -21,6 +21,15 @@ import appInitialState from './reducers/app/appInitialState'; | @@ -21,6 +21,15 @@ import appInitialState from './reducers/app/appInitialState'; | ||
21 | import productListInitialState from './reducers/productList/productListInitialState'; | 21 | import productListInitialState from './reducers/productList/productListInitialState'; |
22 | import ProductListContainer from './containers/ProductListContainer'; | 22 | import ProductListContainer from './containers/ProductListContainer'; |
23 | 23 | ||
24 | +import screenInitialState from './reducers/screen/screenInitialState'; | ||
25 | +import screenCategoryInitialState from './reducers/screenCategory/screenCategoryInitialState'; | ||
26 | +import screenSubInitialState from './reducers/screenSub/screenSubInitialState'; | ||
27 | + | ||
28 | +import ScreenContainer from './containers/ScreenContainer'; | ||
29 | +import ScreenCategoryContainer from './containers/ScreenCategoryContainer'; | ||
30 | +import ScreenSubContainer from './containers/ScreenSubContainer'; | ||
31 | + | ||
32 | + | ||
24 | import { | 33 | import { |
25 | setPlatform, | 34 | setPlatform, |
26 | setChannel, | 35 | setChannel, |
@@ -36,6 +45,9 @@ function getInitialState() { | @@ -36,6 +45,9 @@ function getInitialState() { | ||
36 | const _initState = { | 45 | const _initState = { |
37 | app: (new appInitialState()), | 46 | app: (new appInitialState()), |
38 | productS: (new productListInitialState()), | 47 | productS: (new productListInitialState()), |
48 | + screen: (new screenInitialState()), | ||
49 | + screenCategory: (new screenCategoryInitialState()), | ||
50 | + screenSub: (new screenSubInitialState()), | ||
39 | }; | 51 | }; |
40 | return _initState; | 52 | return _initState; |
41 | } | 53 | } |
@@ -53,11 +65,31 @@ export default function native(platform) { | @@ -53,11 +65,31 @@ export default function native(platform) { | ||
53 | store.dispatch(setType(type)); | 65 | store.dispatch(setType(type)); |
54 | store.dispatch(setBrandId(brand_id)); | 66 | store.dispatch(setBrandId(brand_id)); |
55 | 67 | ||
56 | - return ( | ||
57 | - <Provider store={store}> | ||
58 | - <ProductListContainer /> | ||
59 | - </Provider> | ||
60 | - ); | 68 | + if (type == 'YH_ScreenCategoryView' ) { |
69 | + return ( | ||
70 | + <Provider store={store}> | ||
71 | + <ScreenContainer /> | ||
72 | + </Provider> | ||
73 | + ); | ||
74 | + } else if(type == 'YH_ProductFilterCategoryView' ){ | ||
75 | + return ( | ||
76 | + <Provider store={store}> | ||
77 | + <ScreenCategoryContainer /> | ||
78 | + </Provider> | ||
79 | + ); | ||
80 | + }else if (type == 'YH_ProductFilterSubView' ){ | ||
81 | + return ( | ||
82 | + <Provider store={store}> | ||
83 | + <ScreenSubContainer /> | ||
84 | + </Provider> | ||
85 | + ); | ||
86 | + }else if (type == 'YH_ProductListRNView' ){ | ||
87 | + return ( | ||
88 | + <Provider store={store}> | ||
89 | + <ProductListContainer /> | ||
90 | + </Provider> | ||
91 | + ); | ||
92 | + } | ||
61 | } | 93 | } |
62 | }); | 94 | }); |
63 | 95 |
js/productList/components/screen/Header.js
0 → 100644
1 | +'use strict'; | ||
2 | + | ||
3 | +import React from 'react'; | ||
4 | +import ReactNative from 'react-native'; | ||
5 | +import Immutable, {Map} from 'immutable'; | ||
6 | +import DeviceInfo from 'react-native-device-info'; | ||
7 | + | ||
8 | +const { | ||
9 | + View, | ||
10 | + Text, | ||
11 | + TouchableOpacity, | ||
12 | + Dimensions, | ||
13 | + StyleSheet, | ||
14 | + Platform, | ||
15 | +} = ReactNative; | ||
16 | + | ||
17 | +export default class Header extends React.Component { | ||
18 | + | ||
19 | + constructor(props) { | ||
20 | + super (props); | ||
21 | + } | ||
22 | + | ||
23 | + render() { | ||
24 | + return ( | ||
25 | + <View style={styles.container}> | ||
26 | + <Text style={styles.name}>筛选商品</Text> | ||
27 | + <TouchableOpacity onPress={() => {this.props.cancelAction && this.props.cancelAction()}} > | ||
28 | + <View style={styles.cancelButton}> | ||
29 | + <Text style={styles.cancelText}>清空</Text> | ||
30 | + </View> | ||
31 | + </TouchableOpacity> | ||
32 | + <TouchableOpacity onPress={() => {this.props.okAction && this.props.okAction()}} > | ||
33 | + <View style={styles.okButton}> | ||
34 | + <Text style={styles.okText}>确定</Text> | ||
35 | + </View> | ||
36 | + </TouchableOpacity> | ||
37 | + </View> | ||
38 | + ); | ||
39 | + } | ||
40 | +} | ||
41 | + | ||
42 | +let {width, height} = Dimensions.get('window'); | ||
43 | +let backgroundWidth = width; | ||
44 | +let backgroundHeight = 64; | ||
45 | +let buttonHeight = 30; | ||
46 | +let buttonWidth = 50; | ||
47 | +let rightOffset = 50; | ||
48 | + | ||
49 | +let styles = StyleSheet.create({ | ||
50 | + container: { | ||
51 | + width: backgroundWidth, | ||
52 | + height: backgroundHeight, | ||
53 | + backgroundColor: 'gray', | ||
54 | + flexDirection: 'row', | ||
55 | + }, | ||
56 | + name: { | ||
57 | + fontSize: 14, | ||
58 | + color: 'white', | ||
59 | + marginTop: backgroundHeight - 20 - 10, | ||
60 | + marginLeft: 10, | ||
61 | + width: 100, | ||
62 | + height: buttonHeight, | ||
63 | + backgroundColor: 'transparent', | ||
64 | + }, | ||
65 | + cancelButton: { | ||
66 | + height: buttonHeight, | ||
67 | + width: buttonWidth, | ||
68 | + backgroundColor: 'white', | ||
69 | + marginTop: backgroundHeight - buttonHeight - 10, | ||
70 | + alignItems: 'center', | ||
71 | + justifyContent: 'center', | ||
72 | + marginLeft: width - rightOffset - 110 - 10 - 2*buttonWidth - 10, | ||
73 | + }, | ||
74 | + cancelText: { | ||
75 | + color: 'black', | ||
76 | + }, | ||
77 | + okButton: { | ||
78 | + height: buttonHeight, | ||
79 | + width: buttonWidth, | ||
80 | + backgroundColor: 'black', | ||
81 | + marginTop: backgroundHeight - buttonHeight - 10, | ||
82 | + alignItems: 'center', | ||
83 | + justifyContent: 'center', | ||
84 | + marginLeft: 10, | ||
85 | + }, | ||
86 | + okText: { | ||
87 | + color: 'white', | ||
88 | + }, | ||
89 | +}); |
js/productList/components/screen/Screen.js
0 → 100644
1 | + | ||
2 | +'use strict'; | ||
3 | + | ||
4 | +import React, {Component} from 'react'; | ||
5 | +import ReactNative, { | ||
6 | + View, | ||
7 | + Text, | ||
8 | + Image, | ||
9 | + ListView, | ||
10 | + StyleSheet, | ||
11 | + Dimensions, | ||
12 | + TouchableOpacity, | ||
13 | + Platform, | ||
14 | +} from 'react-native'; | ||
15 | + | ||
16 | +import Header from './Header'; | ||
17 | +import ScreenCell from './ScreenCell'; | ||
18 | + | ||
19 | +export default class Screen extends Component { | ||
20 | + | ||
21 | + constructor(props) { | ||
22 | + super(props); | ||
23 | + this.renderRow = this.renderRow.bind(this); | ||
24 | + this.dataSource = new ListView.DataSource({ | ||
25 | + rowHasChanged: (r1, r2) => !Immutable.is(r1, r2), | ||
26 | + }); | ||
27 | + } | ||
28 | + | ||
29 | + renderRow(rowData,sectionID,rowID,highlightRow) { | ||
30 | + return( | ||
31 | + <ScreenCell resource={rowData} onSelect={this.props.onSelectItem}></ScreenCell> | ||
32 | + ); | ||
33 | + } | ||
34 | + | ||
35 | + render() { | ||
36 | + let {resource} = this.props; | ||
37 | + let list = resource&&resource.get('categoryFilterList')?resource.get('categoryFilterList'):null; | ||
38 | + return ( | ||
39 | + <View style={styles.container}> | ||
40 | + <Header okAction={this.props.okAction} cancelAction={this.props.cancelAction}/> | ||
41 | + {list?<ListView | ||
42 | + ref='ScreenList' | ||
43 | + enableEmptySections={true} | ||
44 | + dataSource={this.dataSource.cloneWithRows(list.toArray())} | ||
45 | + renderRow={this.renderRow} | ||
46 | + />:null} | ||
47 | + </View> | ||
48 | + ); | ||
49 | + } | ||
50 | +} | ||
51 | + | ||
52 | +let {width, height} = Dimensions.get('window'); | ||
53 | + | ||
54 | +let styles = StyleSheet.create({ | ||
55 | + container: { | ||
56 | + flex: 1, | ||
57 | + backgroundColor: '#f4f4f4', | ||
58 | + }, | ||
59 | +}); |
1 | +'use strict'; | ||
2 | + | ||
3 | +import React from 'react'; | ||
4 | +import ReactNative from 'react-native'; | ||
5 | +import Immutable, {Map} from 'immutable'; | ||
6 | +import DeviceInfo from 'react-native-device-info'; | ||
7 | + | ||
8 | +const { | ||
9 | + View, | ||
10 | + Text, | ||
11 | + TouchableOpacity, | ||
12 | + Dimensions, | ||
13 | + StyleSheet, | ||
14 | + Platform, | ||
15 | + Image, | ||
16 | +} = ReactNative; | ||
17 | + | ||
18 | +export default class ScreenCell extends React.Component { | ||
19 | + | ||
20 | + constructor(props) { | ||
21 | + super (props); | ||
22 | + } | ||
23 | + | ||
24 | + render() { | ||
25 | + let resource = this.props.resource?this.props.resource.toJS():null; | ||
26 | + if (!resource) { | ||
27 | + return null; | ||
28 | + } | ||
29 | + let name = resource.name+': '; | ||
30 | + let isTrue = resource.isSelect; | ||
31 | + | ||
32 | + let select = resource.select; | ||
33 | + let value = select?select.name:''; | ||
34 | + let subFilter = resource.subFilter; | ||
35 | + | ||
36 | + return ( | ||
37 | + <View style={styles.container}> | ||
38 | + <TouchableOpacity onPress={() => {this.props.onSelect && this.props.onSelect(subFilter)}} > | ||
39 | + <View style={styles.cell}> | ||
40 | + <Text style={styles.name}>{name}</Text> | ||
41 | + <Text style={{color: isTrue ? 'rgb(146, 146, 146)' : '#444444'}}>{value}</Text> | ||
42 | + <Image style={styles.arrow} source={require('../../images/arrow_gray.png')}></Image> | ||
43 | + </View> | ||
44 | + <View style={{width: width,height: 0.5,backgroundColor: 'rgb(235, 235, 235)'}}/> | ||
45 | + </TouchableOpacity> | ||
46 | + </View> | ||
47 | + ); | ||
48 | + } | ||
49 | +} | ||
50 | + | ||
51 | +let {width, height} = Dimensions.get('window'); | ||
52 | +let backgroundWidth = width; | ||
53 | +let backgroundHeight = 40; | ||
54 | +let rightOffset = 50; | ||
55 | + | ||
56 | +let styles = StyleSheet.create({ | ||
57 | + container: { | ||
58 | + width: backgroundWidth, | ||
59 | + height: backgroundHeight, | ||
60 | + alignItems: 'center', | ||
61 | + }, | ||
62 | + | ||
63 | + cell: { | ||
64 | + width: backgroundWidth, | ||
65 | + height: backgroundHeight-0.5, | ||
66 | + backgroundColor: '#f0f0f0', | ||
67 | + flexDirection: 'row', | ||
68 | + alignItems: 'center', | ||
69 | + }, | ||
70 | + name: { | ||
71 | + marginLeft: 10, | ||
72 | + color: 'rgb(146, 146, 146)' | ||
73 | + }, | ||
74 | + arrow: { | ||
75 | + height: 12, | ||
76 | + position: 'absolute', | ||
77 | + marginVertical: (backgroundHeight - 12 )/2, | ||
78 | + right: 10 + rightOffset, | ||
79 | + }, | ||
80 | +}); |
1 | + | ||
2 | +'use strict'; | ||
3 | + | ||
4 | +import React, {Component} from 'react'; | ||
5 | +import ReactNative, { | ||
6 | + View, | ||
7 | + Text, | ||
8 | + Image, | ||
9 | + ListView, | ||
10 | + StyleSheet, | ||
11 | + Dimensions, | ||
12 | + TouchableOpacity, | ||
13 | + Platform, | ||
14 | +} from 'react-native'; | ||
15 | + | ||
16 | + | ||
17 | +export default class ScreenCategory extends Component { | ||
18 | + | ||
19 | + constructor(props) { | ||
20 | + super(props); | ||
21 | + } | ||
22 | + | ||
23 | + render() { | ||
24 | + let {resource} = this.props; | ||
25 | + return ( | ||
26 | + <View style={styles.container}> | ||
27 | + <Text>aaaaaaa</Text> | ||
28 | + </View> | ||
29 | + ); | ||
30 | + } | ||
31 | +} | ||
32 | + | ||
33 | +let {width, height} = Dimensions.get('window'); | ||
34 | +let styles = StyleSheet.create({ | ||
35 | + container: { | ||
36 | + flex: 1, | ||
37 | + backgroundColor: '#f4f4f4', | ||
38 | + }, | ||
39 | +}); |
1 | + | ||
2 | +'use strict'; | ||
3 | + | ||
4 | +import React, {Component} from 'react'; | ||
5 | +import ScreenSubCell from './ScreenSubCell'; | ||
6 | + | ||
7 | +import ReactNative, { | ||
8 | + View, | ||
9 | + Text, | ||
10 | + Image, | ||
11 | + ListView, | ||
12 | + StyleSheet, | ||
13 | + Dimensions, | ||
14 | + TouchableOpacity, | ||
15 | + Platform, | ||
16 | +} from 'react-native'; | ||
17 | + | ||
18 | + | ||
19 | +export default class ScreenSub extends Component { | ||
20 | + | ||
21 | + constructor(props) { | ||
22 | + super(props); | ||
23 | + | ||
24 | + this.renderRow = this.renderRow.bind(this); | ||
25 | + this.dataSource = new ListView.DataSource({ | ||
26 | + rowHasChanged: (r1, r2) => !Immutable.is(r1, r2), | ||
27 | + }); | ||
28 | + | ||
29 | + } | ||
30 | + | ||
31 | + renderRow(rowData,sectionID,rowID,highlightRow) { | ||
32 | + return( | ||
33 | + <ScreenSubCell resource={rowData} /> | ||
34 | + ); | ||
35 | + } | ||
36 | + | ||
37 | + | ||
38 | + render() { | ||
39 | + let {resource} = this.props; | ||
40 | + let obj = resource&&resource.get('filterSub')?resource.get('filterSub'):null; | ||
41 | + let list = obj?obj.get('list'):null; | ||
42 | + console.log(list?list.toJS():'a'); | ||
43 | + return ( | ||
44 | + <View style={styles.container}> | ||
45 | + {list?<ListView | ||
46 | + ref='ScreenSubList' | ||
47 | + enableEmptySections={true} | ||
48 | + dataSource={this.dataSource.cloneWithRows(list.toArray())} | ||
49 | + renderRow={this.renderRow} | ||
50 | + />:null} | ||
51 | + </View> | ||
52 | + ); | ||
53 | + } | ||
54 | +} | ||
55 | + | ||
56 | +let {width, height} = Dimensions.get('window'); | ||
57 | +let styles = StyleSheet.create({ | ||
58 | + container: { | ||
59 | + flex: 1, | ||
60 | + backgroundColor: '#f4f4f4', | ||
61 | + }, | ||
62 | +}); |
1 | +'use strict'; | ||
2 | + | ||
3 | +import React from 'react'; | ||
4 | +import ReactNative from 'react-native'; | ||
5 | +import Immutable, {Map} from 'immutable'; | ||
6 | +import DeviceInfo from 'react-native-device-info'; | ||
7 | + | ||
8 | +const { | ||
9 | + View, | ||
10 | + Text, | ||
11 | + TouchableOpacity, | ||
12 | + Dimensions, | ||
13 | + StyleSheet, | ||
14 | + Platform, | ||
15 | + Image, | ||
16 | +} = ReactNative; | ||
17 | + | ||
18 | +export default class ScreenSubCell extends React.Component { | ||
19 | + | ||
20 | + constructor(props) { | ||
21 | + super (props); | ||
22 | + } | ||
23 | + | ||
24 | + render() { | ||
25 | + let resource = this.props.resource?this.props.resource.toJS():null; | ||
26 | + if (!resource) { | ||
27 | + return null; | ||
28 | + } | ||
29 | + let isSelect = resource.isSelect; | ||
30 | + let key = resource.key; | ||
31 | + let name = resource.name; | ||
32 | + | ||
33 | + return ( | ||
34 | + <View style={styles.container}> | ||
35 | + <TouchableOpacity onPress={() => {console.log('aaaaaaa');}} > | ||
36 | + <View style={styles.cell}> | ||
37 | + <Text style={styles.name}>{name}</Text> | ||
38 | + <Image style={styles.arrow} source={require('../../images/arrow_gray.png')}></Image> | ||
39 | + </View> | ||
40 | + <View style={{width: width,height: 0.5,backgroundColor: 'rgb(235, 235, 235)'}}/> | ||
41 | + </TouchableOpacity> | ||
42 | + </View> | ||
43 | + ); | ||
44 | + } | ||
45 | +} | ||
46 | + | ||
47 | +let {width, height} = Dimensions.get('window'); | ||
48 | +let backgroundWidth = width; | ||
49 | +let backgroundHeight = 40; | ||
50 | +let rightOffset = 50; | ||
51 | + | ||
52 | +let styles = StyleSheet.create({ | ||
53 | + container: { | ||
54 | + width: backgroundWidth, | ||
55 | + height: backgroundHeight, | ||
56 | + alignItems: 'center', | ||
57 | + }, | ||
58 | + | ||
59 | + cell: { | ||
60 | + width: backgroundWidth, | ||
61 | + height: backgroundHeight-0.5, | ||
62 | + backgroundColor: '#f0f0f0', | ||
63 | + flexDirection: 'row', | ||
64 | + alignItems: 'center', | ||
65 | + }, | ||
66 | + name: { | ||
67 | + marginLeft: 10, | ||
68 | + color: 'rgb(146, 146, 146)' | ||
69 | + }, | ||
70 | + arrow: { | ||
71 | + height: 12, | ||
72 | + position: 'absolute', | ||
73 | + marginVertical: (backgroundHeight - 12 )/2, | ||
74 | + right: 10 + rightOffset, | ||
75 | + }, | ||
76 | +}); |
@@ -5,6 +5,13 @@ export default keyMirror({ | @@ -5,6 +5,13 @@ export default keyMirror({ | ||
5 | SET_PLATFORM: null, | 5 | SET_PLATFORM: null, |
6 | SET_HOST: null, | 6 | SET_HOST: null, |
7 | SET_CHANNEL: null, | 7 | SET_CHANNEL: null, |
8 | + | ||
9 | + SET_DATASOURCE: null, | ||
10 | + SET_DATASOURCE_CATEGORY: null, | ||
11 | + SET_DATASOURCE_SUB: null, | ||
12 | + | ||
13 | + | ||
14 | + | ||
8 | SET_TYPE: null, | 15 | SET_TYPE: null, |
9 | SET_BRANDID: null, | 16 | SET_BRANDID: null, |
10 | GET_BRAND_BANNER_INFO_REQUEST: null, | 17 | GET_BRAND_BANNER_INFO_REQUEST: null, |
1 | +'use strict' | ||
2 | + | ||
3 | +import React, {Component} from 'react'; | ||
4 | +import ReactNative, { | ||
5 | + StyleSheet, | ||
6 | + Dimensions, | ||
7 | + Platform, | ||
8 | + View, | ||
9 | + Text, | ||
10 | + NativeModules, | ||
11 | + InteractionManager, | ||
12 | + NativeAppEventEmitter, | ||
13 | +} from 'react-native' | ||
14 | + | ||
15 | +import {bindActionCreators} from 'redux'; | ||
16 | +import {connect} from 'react-redux'; | ||
17 | +import {Map} from 'immutable'; | ||
18 | +import * as screenCategoryActions from '../reducers/screenCategory/screenCategoryActions'; | ||
19 | +import * as appActions from '../reducers/app/appActions'; | ||
20 | + | ||
21 | +import ScreenCategory from '../components/screenCategory/ScreenCategory'; | ||
22 | + | ||
23 | +const actions = [ | ||
24 | + screenCategoryActions, | ||
25 | + appActions | ||
26 | +]; | ||
27 | + | ||
28 | +function mapStateToProps(state) { | ||
29 | + return { | ||
30 | + ...state | ||
31 | + }; | ||
32 | +} | ||
33 | + | ||
34 | +function mapDispatchToProps(dispatch) { | ||
35 | + | ||
36 | + const creators = Map() | ||
37 | + .merge(...actions) | ||
38 | + .filter(value => typeof value === 'function') | ||
39 | + .toObject(); | ||
40 | + | ||
41 | + return { | ||
42 | + actions: bindActionCreators(creators, dispatch), | ||
43 | + dispatch | ||
44 | + }; | ||
45 | +} | ||
46 | + | ||
47 | +class ScreenCategoryContainer extends Component { | ||
48 | + constructor(props) { | ||
49 | + super(props); | ||
50 | + } | ||
51 | + | ||
52 | + componentWillUnmount() { | ||
53 | + } | ||
54 | + | ||
55 | + render() { | ||
56 | + let {app, sreenCategory} = this.props; | ||
57 | + return ( | ||
58 | + <View style={styles.container}> | ||
59 | + <ScreenCategory | ||
60 | + resource={sreenCategory} | ||
61 | + /> | ||
62 | + </View> | ||
63 | + ); | ||
64 | + } | ||
65 | +} | ||
66 | + | ||
67 | +let {width, height} = Dimensions.get('window'); | ||
68 | + | ||
69 | +let styles = StyleSheet.create({ | ||
70 | + container: { | ||
71 | + flex: 1, | ||
72 | + }, | ||
73 | + | ||
74 | +}); | ||
75 | + | ||
76 | +export default connect(mapStateToProps, mapDispatchToProps)(ScreenCategoryContainer); |
js/productList/containers/ScreenContainer.js
0 → 100644
1 | +'use strict' | ||
2 | + | ||
3 | +import React, {Component} from 'react'; | ||
4 | +import ReactNative, { | ||
5 | + StyleSheet, | ||
6 | + Dimensions, | ||
7 | + Platform, | ||
8 | + View, | ||
9 | + Text, | ||
10 | + NativeModules, | ||
11 | + InteractionManager, | ||
12 | + NativeAppEventEmitter, | ||
13 | +} from 'react-native' | ||
14 | + | ||
15 | +import {bindActionCreators} from 'redux'; | ||
16 | +import {connect} from 'react-redux'; | ||
17 | +import {Map} from 'immutable'; | ||
18 | +import * as screenActions from '../reducers/screen/screenActions'; | ||
19 | +import * as appActions from '../reducers/app/appActions'; | ||
20 | + | ||
21 | +import Screen from '../components/screen/Screen'; | ||
22 | + | ||
23 | +const actions = [ | ||
24 | + screenActions, | ||
25 | + appActions | ||
26 | +]; | ||
27 | + | ||
28 | +function mapStateToProps(state) { | ||
29 | + return { | ||
30 | + ...state | ||
31 | + }; | ||
32 | +} | ||
33 | + | ||
34 | +function mapDispatchToProps(dispatch) { | ||
35 | + | ||
36 | + const creators = Map() | ||
37 | + .merge(...actions) | ||
38 | + .filter(value => typeof value === 'function') | ||
39 | + .toObject(); | ||
40 | + | ||
41 | + return { | ||
42 | + actions: bindActionCreators(creators, dispatch), | ||
43 | + dispatch | ||
44 | + }; | ||
45 | +} | ||
46 | + | ||
47 | +class ScreenContainer extends Component { | ||
48 | + constructor(props) { | ||
49 | + super(props); | ||
50 | + this.updateFilter = this.updateFilter.bind(this); | ||
51 | + this.cancelAction = this.cancelAction.bind(this); | ||
52 | + this.onSelectItem = this.onSelectItem.bind(this); | ||
53 | + this.okAction = this.okAction.bind(this); | ||
54 | + this.subscription = NativeAppEventEmitter.addListener( | ||
55 | + 'updateFilter', | ||
56 | + (dic) => { | ||
57 | + this.updateFilter(dic); | ||
58 | + } | ||
59 | + ); | ||
60 | + | ||
61 | + } | ||
62 | + | ||
63 | + componentWillUnmount() { | ||
64 | + this.subscription && this.subscription.remove(); | ||
65 | + } | ||
66 | + | ||
67 | + okAction() { | ||
68 | + ReactNative.NativeModules.YH_ScreenCategoryViewHelper.okAction(); | ||
69 | + } | ||
70 | + | ||
71 | + cancelAction() { | ||
72 | + ReactNative.NativeModules.YH_ScreenCategoryViewHelper.cancelAction(); | ||
73 | + } | ||
74 | + | ||
75 | + onSelectItem(subFilter) { | ||
76 | + ReactNative.NativeModules.YH_ScreenCategoryViewHelper.didSelectScreenIetmIndex(subFilter); | ||
77 | + } | ||
78 | + | ||
79 | + updateFilter(dic){ | ||
80 | + if (dic) { | ||
81 | + this.props.actions.updateDataSource(dic); | ||
82 | + } | ||
83 | + } | ||
84 | + | ||
85 | + render() { | ||
86 | + let {app, screen} = this.props; | ||
87 | + return ( | ||
88 | + <View style={styles.container}> | ||
89 | + <Screen | ||
90 | + resource={screen} | ||
91 | + okAction={this.okAction} | ||
92 | + cancelAction={this.cancelAction} | ||
93 | + onSelectItem={this.onSelectItem} | ||
94 | + /> | ||
95 | + </View> | ||
96 | + ); | ||
97 | + } | ||
98 | +} | ||
99 | + | ||
100 | +let {width, height} = Dimensions.get('window'); | ||
101 | + | ||
102 | +let styles = StyleSheet.create({ | ||
103 | + container: { | ||
104 | + flex: 1, | ||
105 | + }, | ||
106 | + | ||
107 | +}); | ||
108 | + | ||
109 | +export default connect(mapStateToProps, mapDispatchToProps)(ScreenContainer); |
1 | +'use strict' | ||
2 | + | ||
3 | +import React, {Component} from 'react'; | ||
4 | +import ReactNative, { | ||
5 | + StyleSheet, | ||
6 | + Dimensions, | ||
7 | + Platform, | ||
8 | + View, | ||
9 | + Text, | ||
10 | + NativeModules, | ||
11 | + InteractionManager, | ||
12 | + NativeAppEventEmitter, | ||
13 | +} from 'react-native' | ||
14 | + | ||
15 | +import {bindActionCreators} from 'redux'; | ||
16 | +import {connect} from 'react-redux'; | ||
17 | +import {Map} from 'immutable'; | ||
18 | +import * as screenCategoryActions from '../reducers/screenSub/screenSubActions'; | ||
19 | +import * as appActions from '../reducers/app/appActions'; | ||
20 | + | ||
21 | +import ScreenSub from '../components/screenSub/ScreenSub'; | ||
22 | + | ||
23 | +const actions = [ | ||
24 | + screenCategoryActions, | ||
25 | + appActions | ||
26 | +]; | ||
27 | + | ||
28 | +function mapStateToProps(state) { | ||
29 | + return { | ||
30 | + ...state | ||
31 | + }; | ||
32 | +} | ||
33 | + | ||
34 | +function mapDispatchToProps(dispatch) { | ||
35 | + | ||
36 | + const creators = Map() | ||
37 | + .merge(...actions) | ||
38 | + .filter(value => typeof value === 'function') | ||
39 | + .toObject(); | ||
40 | + | ||
41 | + return { | ||
42 | + actions: bindActionCreators(creators, dispatch), | ||
43 | + dispatch | ||
44 | + }; | ||
45 | +} | ||
46 | + | ||
47 | +class ScreenSubContainer extends Component { | ||
48 | + constructor(props) { | ||
49 | + super(props); | ||
50 | + this.updateFilterSub = this.updateFilterSub.bind(this); | ||
51 | + this.subscription = NativeAppEventEmitter.addListener( | ||
52 | + 'updateFilterSub', | ||
53 | + (dic) => { | ||
54 | + this.updateFilterSub(dic); | ||
55 | + } | ||
56 | + ); | ||
57 | + } | ||
58 | + | ||
59 | + componentWillUnmount() { | ||
60 | + this.subscription && this.subscription.remove(); | ||
61 | + } | ||
62 | + | ||
63 | + updateFilterSub(dic){ | ||
64 | + if (dic) { | ||
65 | + this.props.actions.updateDataSource(dic); | ||
66 | + } | ||
67 | + } | ||
68 | + | ||
69 | + render() { | ||
70 | + let {app, screenSub} = this.props; | ||
71 | + return ( | ||
72 | + <View style={styles.container}> | ||
73 | + <ScreenSub | ||
74 | + resource={screenSub} | ||
75 | + /> | ||
76 | + </View> | ||
77 | + ); | ||
78 | + } | ||
79 | +} | ||
80 | + | ||
81 | +let {width, height} = Dimensions.get('window'); | ||
82 | + | ||
83 | +let styles = StyleSheet.create({ | ||
84 | + container: { | ||
85 | + flex: 1, | ||
86 | + }, | ||
87 | + | ||
88 | +}); | ||
89 | + | ||
90 | +export default connect(mapStateToProps, mapDispatchToProps)(ScreenSubContainer); |
js/productList/images/arrow_gray@2x.png
0 → 100644

1.17 KB
js/productList/images/arrow_gray@3x.png
0 → 100644

1.28 KB
1 | import {combineReducers} from 'redux'; | 1 | import {combineReducers} from 'redux'; |
2 | import app from './app/appReducer'; | 2 | import app from './app/appReducer'; |
3 | import productS from './productList/productListReducer'; | 3 | import productS from './productList/productListReducer'; |
4 | +import screen from './screen/screenReducer'; | ||
5 | +import screenCategory from './screenCategory/screenCategoryReducer'; | ||
6 | +import screenSub from './screenSub/screenSubReducer'; | ||
4 | 7 | ||
5 | const rootReducer = combineReducers({ | 8 | const rootReducer = combineReducers({ |
6 | app, | 9 | app, |
7 | productS, | 10 | productS, |
11 | + screen, | ||
12 | + screenCategory, | ||
13 | + screenSub, | ||
8 | }); | 14 | }); |
9 | 15 | ||
10 | export default rootReducer; | 16 | export default rootReducer; |
@@ -446,6 +446,10 @@ export function getProductList(reload=false) { | @@ -446,6 +446,10 @@ export function getProductList(reload=false) { | ||
446 | let list = [...oldList, ...payload.list]; | 446 | let list = [...oldList, ...payload.list]; |
447 | payload.list = list; | 447 | payload.list = list; |
448 | } | 448 | } |
449 | + let categoryFilterList = payload.categoryFilterList; | ||
450 | + let filterCategoryDetailFilterList = payload.filterCategoryDetailFilterList; | ||
451 | + let filters = parsecategoryFilter({categoryFilterList,filterCategoryDetailFilterList}); | ||
452 | + ReactNative.NativeModules.YH_ProductListRNViewHelper.setFilterData(filters); | ||
449 | dispatch(productListSuccess(payload)); | 453 | dispatch(productListSuccess(payload)); |
450 | }) | 454 | }) |
451 | .catch(error => { | 455 | .catch(error => { |
@@ -465,6 +469,48 @@ function randomString(len) { | @@ -465,6 +469,48 @@ function randomString(len) { | ||
465 | return pwd; | 469 | return pwd; |
466 | } | 470 | } |
467 | 471 | ||
472 | +function parsecategoryFilter(json) { | ||
473 | + let categoryFilterList = json.categoryFilterList; | ||
474 | + let filterCategoryDetailFilterList = json.filterCategoryDetailFilterList; | ||
475 | + | ||
476 | + for (var i = 0; i < categoryFilterList.length; i++) { | ||
477 | + let key = categoryFilterList[i].key; | ||
478 | + let type = 0; | ||
479 | + if (key == 'sort') { | ||
480 | + type = 0; | ||
481 | + }else if (key == 'brand'){ | ||
482 | + type = 1; | ||
483 | + }else if (key == 'color'){ | ||
484 | + type = 2; | ||
485 | + }else if (key == 'sizeKey'){ | ||
486 | + type = 3; | ||
487 | + }else if (key == 'price'){ | ||
488 | + type = 4; | ||
489 | + }else if (key == 'p_d'){ | ||
490 | + type = 5; | ||
491 | + }else if (key == 'gender'){ | ||
492 | + type = 7; | ||
493 | + }else if (key == 'style'){ | ||
494 | + type = 10; | ||
495 | + } | ||
496 | + _.forEach(filterCategoryDetailFilterList, (v, k) => { | ||
497 | + if (k == key) { | ||
498 | + let list = v; | ||
499 | + for (var j = 0; j < list.length; j++) { | ||
500 | + if (list[j].isSelect) { | ||
501 | + categoryFilterList[i].select = list[j]; | ||
502 | + categoryFilterList[i].subFilter = {list,key,type}; | ||
503 | + } | ||
504 | + } | ||
505 | + } | ||
506 | + }); | ||
507 | + } | ||
508 | + | ||
509 | + return{ | ||
510 | + categoryFilterList, | ||
511 | + } | ||
512 | +} | ||
513 | + | ||
468 | function parseProductList(json) { | 514 | function parseProductList(json) { |
469 | let currentPage = json && json.page ? json.page : 1; | 515 | let currentPage = json && json.page ? json.page : 1; |
470 | let pageCount = json && json.page_total ? json.page_total : 0; | 516 | let pageCount = json && json.page_total ? json.page_total : 0; |
@@ -647,6 +693,32 @@ function parseProductList(json) { | @@ -647,6 +693,32 @@ function parseProductList(json) { | ||
647 | filterCategoryDetailFilterList.p_d = newP_dList; | 693 | filterCategoryDetailFilterList.p_d = newP_dList; |
648 | } | 694 | } |
649 | 695 | ||
696 | + if (filter['style']) { | ||
697 | + categoryFilterList.push({ | ||
698 | + key: 'style', | ||
699 | + name: '风格', | ||
700 | + isSelect: false, | ||
701 | + }); | ||
702 | + let p_dObject = filter['style']; | ||
703 | + p_dObject = sortListByField(p_dObject, 'style_name'); // 折扣,价格区间,需要排序 | ||
704 | + let newP_dList = []; | ||
705 | + newP_dList.push({ | ||
706 | + key: '', | ||
707 | + name: '所有风格', | ||
708 | + isSelect: true, | ||
709 | + }); | ||
710 | + _.forEach(p_dObject, (v, k) => { | ||
711 | + newP_dList.push({ | ||
712 | + key: v._key, | ||
713 | + name: v.name, | ||
714 | + isSelect: false, | ||
715 | + }); | ||
716 | + }); | ||
717 | + filterCategoryDetailFilterList.style; | ||
718 | + filterCategoryDetailFilterList.style = newP_dList; | ||
719 | + } | ||
720 | + | ||
721 | + | ||
650 | let recId = randomString(40); | 722 | let recId = randomString(40); |
651 | return { | 723 | return { |
652 | list, | 724 | list, |
@@ -47,6 +47,7 @@ let InitialState = Record({ | @@ -47,6 +47,7 @@ let InitialState = Record({ | ||
47 | p_d: '', //折扣 | 47 | p_d: '', //折扣 |
48 | sort: '', //品类 | 48 | sort: '', //品类 |
49 | brand: '', //品牌 | 49 | brand: '', //品牌 |
50 | + style: '', //风格 | ||
50 | })), | 51 | })), |
51 | filterNameFactors: new (Record({ | 52 | filterNameFactors: new (Record({ |
52 | gender: '所有性别', //性别 | 53 | gender: '所有性别', //性别 |
@@ -56,6 +57,7 @@ let InitialState = Record({ | @@ -56,6 +57,7 @@ let InitialState = Record({ | ||
56 | p_d: '所有折扣', //折扣 | 57 | p_d: '所有折扣', //折扣 |
57 | sort: '所有品类', //品类 | 58 | sort: '所有品类', //品类 |
58 | brand: '所有品牌', //品牌 | 59 | brand: '所有品牌', //品牌 |
60 | + style: '所有风格', //风格 | ||
59 | })), | 61 | })), |
60 | receiveCouponResult: new (Record({ | 62 | receiveCouponResult: new (Record({ |
61 | showMessage: '', | 63 | showMessage: '', |
@@ -80,22 +80,30 @@ export default function productListReducer(state=initialState, action) { | @@ -80,22 +80,30 @@ export default function productListReducer(state=initialState, action) { | ||
80 | .setIn(['productList', 'error'], null); | 80 | .setIn(['productList', 'error'], null); |
81 | } | 81 | } |
82 | case PRODUCT_LIST_SUCCESS: { | 82 | case PRODUCT_LIST_SUCCESS: { |
83 | + | ||
83 | let { | 84 | let { |
84 | - list, | ||
85 | - currentPage, | ||
86 | - pageCount, | ||
87 | - total, | ||
88 | - endReached, | ||
89 | - } = action.payload; | 85 | + list, |
86 | + categoryFilterList, | ||
87 | + filterCategoryDetailFilterList, | ||
88 | + currentPage, | ||
89 | + pageCount, | ||
90 | + total, | ||
91 | + recId, | ||
92 | + endReached, | ||
93 | + } = action.payload; | ||
90 | 94 | ||
91 | let newState = state.setIn(['productList', 'isFetching'], false) | 95 | let newState = state.setIn(['productList', 'isFetching'], false) |
92 | - .setIn(['productList', 'error'], null) | ||
93 | - .setIn(['productList', 'list'], Immutable.fromJS(list)) | ||
94 | - .setIn(['productList', 'currentPage'], currentPage) | ||
95 | - .setIn(['productList', 'pageCount'], pageCount) | ||
96 | - .setIn(['productList', 'total'], total) | ||
97 | - .setIn(['productList', 'endReached'], endReached) | ||
98 | - | 96 | + .setIn(['productList', 'error'], null) |
97 | + .setIn(['productList', 'list'], Immutable.fromJS(list)) | ||
98 | + .setIn(['productList', 'currentPage'], currentPage) | ||
99 | + .setIn(['productList', 'pageCount'], pageCount) | ||
100 | + .setIn(['productList', 'total'], total) | ||
101 | + .setIn(['productList', 'endReached'], endReached); | ||
102 | + | ||
103 | + if (currentPage == 1 && state.categoryFilterList.size == 0 && state.filterCategoryDetailFilterList.size == 0) { | ||
104 | + newState = newState.set('categoryFilterList', Immutable.fromJS(categoryFilterList)) | ||
105 | + .set('filterCategoryDetailFilterList', Immutable.fromJS(filterCategoryDetailFilterList)); | ||
106 | + } | ||
99 | return newState; | 107 | return newState; |
100 | } | 108 | } |
101 | case PRODUCT_LIST_FAILURE: { | 109 | case PRODUCT_LIST_FAILURE: { |
1 | +'use strict'; | ||
2 | + | ||
3 | +import InitialState from './screenInitialState'; | ||
4 | +import Immutable, {Map} from 'immutable'; | ||
5 | + | ||
6 | +const { | ||
7 | + SET_DATASOURCE | ||
8 | +} = require('../../constants/actionTypes').default; | ||
9 | + | ||
10 | +const initialState = new InitialState; | ||
11 | + | ||
12 | +export default function screenReducer(state=initialState, action) { | ||
13 | + switch(action.type){ | ||
14 | + case SET_DATASOURCE: | ||
15 | + { | ||
16 | + return state.set('categoryFilterList',Immutable.fromJS(action.payload.categoryFilterList)) | ||
17 | + .set('filterCategoryDetailFilterList',Immutable.fromJS(action.payload.filterCategoryDetailFilterList)) | ||
18 | + .set('dataSourceType', action.payload.dataSourceType); | ||
19 | + } | ||
20 | + } | ||
21 | + return state; | ||
22 | +} |
1 | +'use strict'; | ||
2 | + | ||
3 | +import InitialState from './screenCategoryInitialState'; | ||
4 | +import Immutable, {Map} from 'immutable'; | ||
5 | + | ||
6 | +const { | ||
7 | + SET_DATASOURCE_CATEGORY | ||
8 | +} = require('../../constants/actionTypes').default; | ||
9 | + | ||
10 | +const initialState = new InitialState; | ||
11 | + | ||
12 | +export default function screenCategoryReducer(state=initialState, action) { | ||
13 | + switch(action.type){ | ||
14 | + case SET_DATASOURCE_CATEGORY: | ||
15 | + { | ||
16 | + return state.set('screenList',Immutable.fromJS(action.payload.dataList)).set('dataSourceType', action.payload.dataSourceType); | ||
17 | + } | ||
18 | + } | ||
19 | + return state; | ||
20 | +} |
1 | +'use strict'; | ||
2 | + | ||
3 | +import InitialState from './screenSubInitialState'; | ||
4 | +import Immutable, {Map} from 'immutable'; | ||
5 | + | ||
6 | +const { | ||
7 | + SET_DATASOURCE_SUB | ||
8 | +} = require('../../constants/actionTypes').default; | ||
9 | + | ||
10 | +const initialState = new InitialState; | ||
11 | + | ||
12 | +export default function screenSubReducer(state=initialState, action) { | ||
13 | + switch(action.type){ | ||
14 | + case SET_DATASOURCE_SUB: | ||
15 | + { | ||
16 | + return state.setIn(['filterSub', 'key'], action.payload.key) | ||
17 | + .setIn(['filterSub', 'list'], Immutable.fromJS(action.payload.list)); | ||
18 | + } | ||
19 | + } | ||
20 | + return state; | ||
21 | +} |
js/productList/services/ScreenService.js
0 → 100644
js/productList/services/ScreenSubService.js
0 → 100644
-
Please register or login to post a comment