Authored by 孙凯

接 筛选 确认 清除 事件 review by qiangbing

@@ -16,6 +16,7 @@ export default keyMirror({ @@ -16,6 +16,7 @@ export default keyMirror({
16 SET_TYPE: null, 16 SET_TYPE: null,
17 SET_BRANDID: null, 17 SET_BRANDID: null,
18 SET_SHOP: null, 18 SET_SHOP: null,
  19 + CANCEL_SELECT: null,
19 GET_BRAND_BANNER_INFO_REQUEST: null, 20 GET_BRAND_BANNER_INFO_REQUEST: null,
20 GET_BRAND_BANNER_INFO_SUCCESS: null, 21 GET_BRAND_BANNER_INFO_SUCCESS: null,
21 GET_BRAND_BANNER_INFO_FAILURE: null, 22 GET_BRAND_BANNER_INFO_FAILURE: null,
@@ -45,6 +45,14 @@ class ProductListContainer extends Component { @@ -45,6 +45,14 @@ class ProductListContainer extends Component {
45 this._onLongPressProduct = this._onLongPressProduct.bind(this); 45 this._onLongPressProduct = this._onLongPressProduct.bind(this);
46 this._onPressFindSimilar = this._onPressFindSimilar.bind(this); 46 this._onPressFindSimilar = this._onPressFindSimilar.bind(this);
47 this._onPressProductCell = this._onPressProductCell.bind(this); 47 this._onPressProductCell = this._onPressProductCell.bind(this);
  48 + this.subscription = NativeAppEventEmitter.addListener(
  49 + 'updateProductByFilter',
  50 + (array) => {
  51 + // this.props.actions.getProductList();
  52 + console.log(array);
  53 + console.log('ssssssssssssss');
  54 + }
  55 + );
48 } 56 }
49 57
50 componentDidMount() { 58 componentDidMount() {
@@ -55,6 +63,7 @@ class ProductListContainer extends Component { @@ -55,6 +63,7 @@ class ProductListContainer extends Component {
55 } 63 }
56 64
57 componentWillUnmount() { 65 componentWillUnmount() {
  66 + this.subscription && this.subscription.remove();
58 } 67 }
59 68
60 _onPressCoupon(rowData) { 69 _onPressCoupon(rowData) {
@@ -45,6 +45,14 @@ class ProductListForShopContainer extends Component { @@ -45,6 +45,14 @@ class ProductListForShopContainer extends Component {
45 this._onLongPressProduct = this._onLongPressProduct.bind(this); 45 this._onLongPressProduct = this._onLongPressProduct.bind(this);
46 this._onPressFindSimilar = this._onPressFindSimilar.bind(this); 46 this._onPressFindSimilar = this._onPressFindSimilar.bind(this);
47 this._onPressProductCell = this._onPressProductCell.bind(this); 47 this._onPressProductCell = this._onPressProductCell.bind(this);
  48 + this.subscription = NativeAppEventEmitter.addListener(
  49 + 'updateProductByFilter',
  50 + (array) => {
  51 + // this.props.actions.getProductList();
  52 + console.log(array);
  53 + console.log('ssssssssssssss');
  54 + }
  55 + );
48 } 56 }
49 57
50 componentDidMount() { 58 componentDidMount() {
@@ -55,6 +63,7 @@ class ProductListForShopContainer extends Component { @@ -55,6 +63,7 @@ class ProductListForShopContainer extends Component {
55 } 63 }
56 64
57 componentWillUnmount() { 65 componentWillUnmount() {
  66 + this.subscription && this.subscription.remove();
58 } 67 }
59 68
60 _onPressCoupon(rowData) { 69 _onPressCoupon(rowData) {
@@ -106,11 +106,24 @@ class ScreenContainer extends Component { @@ -106,11 +106,24 @@ class ScreenContainer extends Component {
106 } 106 }
107 107
108 okAction() { 108 okAction() {
109 - ReactNative.NativeModules.YH_ScreenCategoryViewHelper.okAction(); 109 + //刷新页面
  110 + let {app, screen} = this.props;
  111 + let categoryFilterList = screen&&screen.get('categoryFilterList')?screen.get('categoryFilterList').toJS():'';
  112 + let hasSelect = [];
  113 + for (let i = 0; i < categoryFilterList.length; i++) {
  114 + let obj = categoryFilterList[i];
  115 + hasSelect.push({
  116 + 'key': obj.key,
  117 + 'name': obj.select.name,
  118 + 'keyCode': obj.select.key,
  119 + });
  120 + }
  121 + ReactNative.NativeModules.YH_ScreenCategoryViewHelper.okAction(hasSelect);
110 } 122 }
111 123
112 cancelAction() { 124 cancelAction() {
113 - 125 + //清空数据
  126 + this.props.actions.cancelSelect();
114 } 127 }
115 128
116 onSelectItem(subFilter) { 129 onSelectItem(subFilter) {
@@ -5,6 +5,7 @@ import ReactNative from 'react-native'; @@ -5,6 +5,7 @@ import ReactNative from 'react-native';
5 const { 5 const {
6 SET_DATASOURCE, 6 SET_DATASOURCE,
7 SET_SELECTLIST, 7 SET_SELECTLIST,
  8 + CANCEL_SELECT,
8 } = require('../../constants/actionTypes').default; 9 } = require('../../constants/actionTypes').default;
9 10
10 11
@@ -22,3 +23,19 @@ export function setSelectItem(list) { @@ -22,3 +23,19 @@ export function setSelectItem(list) {
22 payload: list 23 payload: list
23 }; 24 };
24 } 25 }
  26 +
  27 +export function cancelSelectDispath(json) {
  28 + return {
  29 + type: CANCEL_SELECT,
  30 + payload: json
  31 + };
  32 +}
  33 +
  34 +export function cancelSelect() {
  35 + return (dispatch, getState) => {
  36 + let {app, screen} = getState();
  37 + let {origincategoryFilterList} = screen;
  38 + let json = origincategoryFilterList?origincategoryFilterList.toJS():[];
  39 + dispatch(cancelSelectDispath(json));
  40 + };
  41 +}
@@ -6,5 +6,6 @@ let InitialState = Record({ @@ -6,5 +6,6 @@ let InitialState = Record({
6 categoryFilterList: List(), 6 categoryFilterList: List(),
7 filterCategoryDetailFilterList: List(), 7 filterCategoryDetailFilterList: List(),
8 dataSourceType: 0, 8 dataSourceType: 0,
  9 + origincategoryFilterList: List(),//包括初始化选择属性
9 }); 10 });
10 export default InitialState; 11 export default InitialState;
@@ -6,6 +6,7 @@ import Immutable, {Map} from 'immutable'; @@ -6,6 +6,7 @@ import Immutable, {Map} from 'immutable';
6 const { 6 const {
7 SET_DATASOURCE, 7 SET_DATASOURCE,
8 SET_SELECTLIST, 8 SET_SELECTLIST,
  9 + CANCEL_SELECT,
9 } = require('../../constants/actionTypes').default; 10 } = require('../../constants/actionTypes').default;
10 11
11 const initialState = new InitialState; 12 const initialState = new InitialState;
@@ -15,6 +16,7 @@ export default function screenReducer(state=initialState, action) { @@ -15,6 +16,7 @@ export default function screenReducer(state=initialState, action) {
15 case SET_DATASOURCE: 16 case SET_DATASOURCE:
16 { 17 {
17 return state.set('categoryFilterList',Immutable.fromJS(action.payload.categoryFilterList)) 18 return state.set('categoryFilterList',Immutable.fromJS(action.payload.categoryFilterList))
  19 + .set('origincategoryFilterList',Immutable.fromJS(action.payload.categoryFilterList))
18 .set('filterCategoryDetailFilterList',Immutable.fromJS(action.payload.filterCategoryDetailFilterList)) 20 .set('filterCategoryDetailFilterList',Immutable.fromJS(action.payload.filterCategoryDetailFilterList))
19 .set('dataSourceType', action.payload.dataSourceType); 21 .set('dataSourceType', action.payload.dataSourceType);
20 } 22 }
@@ -22,6 +24,10 @@ export default function screenReducer(state=initialState, action) { @@ -22,6 +24,10 @@ export default function screenReducer(state=initialState, action) {
22 { 24 {
23 return state.set('categoryFilterList',Immutable.fromJS(action.payload)); 25 return state.set('categoryFilterList',Immutable.fromJS(action.payload));
24 } 26 }
  27 + case CANCEL_SELECT:
  28 + {
  29 + return state.set('categoryFilterList',Immutable.fromJS(action.payload));
  30 + }
25 } 31 }
26 return state; 32 return state;
27 } 33 }