Authored by 孙凯

解决重复请求 review by 红魔

@@ -71,8 +71,39 @@ class BrandContainer extends Component { @@ -71,8 +71,39 @@ class BrandContainer extends Component {
71 } 71 }
72 72
73 _onChannelPressFliter(value){ 73 _onChannelPressFliter(value){
74 - this.props.actions.getBrandList(value);  
75 - this.props.actions.getBrandResource(value); 74 +
  75 + let {
  76 + brandListForBoy,
  77 + brandListForGirl,
  78 + brandListForKid,
  79 + brandListForLifeStyle,
  80 + reourceForBoy,
  81 + reourceForGirl,
  82 + reourceForKid,
  83 + reourceForLifeStyle,
  84 + } = this.props.brand;
  85 + let brandListNeedRequest;
  86 + let reourceNeedRequest;
  87 + if (value == 0) {
  88 + brandListNeedRequest = brandListForBoy.get('hasSuccess');
  89 + reourceNeedRequest = reourceForBoy.get('hasSuccess');
  90 + }else if (value == 1) {
  91 + brandListNeedRequest = brandListForGirl.get('hasSuccess');
  92 + reourceNeedRequest = reourceForGirl.get('hasSuccess');
  93 + }else if (value == 2) {
  94 + brandListNeedRequest = brandListForKid.get('hasSuccess');
  95 + reourceNeedRequest = reourceForKid.get('hasSuccess');
  96 + }else if (value == 3) {
  97 + brandListNeedRequest = brandListForLifeStyle.get('hasSuccess');
  98 + reourceNeedRequest = reourceForLifeStyle.get('hasSuccess');
  99 + }
  100 +
  101 + if (!brandListNeedRequest) {
  102 + this.props.actions.getBrandList(value);
  103 + }
  104 + if (!brandListNeedRequest) {
  105 + this.props.actions.getBrandResource(value);
  106 + }
76 this.props.actions.setChannelFilter(value); 107 this.props.actions.setChannelFilter(value);
77 } 108 }
78 109
@@ -89,6 +120,7 @@ class BrandContainer extends Component { @@ -89,6 +120,7 @@ class BrandContainer extends Component {
89 reourceForKid, 120 reourceForKid,
90 reourceForLifeStyle, 121 reourceForLifeStyle,
91 } = this.props.brand; 122 } = this.props.brand;
  123 + console.log(this.props.brand);
92 return ( 124 return (
93 <View style={styles.container}> 125 <View style={styles.container}>
94 <Brand 126 <Brand
@@ -9,41 +9,49 @@ let InitialState = Record({ @@ -9,41 +9,49 @@ let InitialState = Record({
9 all_list: Map(), 9 all_list: Map(),
10 hot_list: List(), 10 hot_list: List(),
11 new_list: List(), 11 new_list: List(),
  12 + hasSuccess: false,
12 })), 13 })),
13 brandListForGirl: new (Record({ 14 brandListForGirl: new (Record({
14 all_list: Map(), 15 all_list: Map(),
15 hot_list: List(), 16 hot_list: List(),
16 new_list: List(), 17 new_list: List(),
  18 + hasSuccess: false,
17 })), 19 })),
18 brandListForKid: new (Record({ 20 brandListForKid: new (Record({
19 all_list: Map(), 21 all_list: Map(),
20 hot_list: List(), 22 hot_list: List(),
21 new_list: List(), 23 new_list: List(),
  24 + hasSuccess: false,
22 })), 25 })),
23 brandListForLifeStyle: new (Record({ 26 brandListForLifeStyle: new (Record({
24 all_list: Map(), 27 all_list: Map(),
25 hot_list: List(), 28 hot_list: List(),
26 new_list: List(), 29 new_list: List(),
  30 + hasSuccess: false,
27 })), 31 })),
28 reourceForBoy: new (Record({ 32 reourceForBoy: new (Record({
29 banner: Map(), 33 banner: Map(),
30 custom_brands: Map(), 34 custom_brands: Map(),
31 brandsText: List(), 35 brandsText: List(),
  36 + hasSuccess: false,
32 })), 37 })),
33 reourceForGirl: new (Record({ 38 reourceForGirl: new (Record({
34 banner: Map(), 39 banner: Map(),
35 custom_brands: Map(), 40 custom_brands: Map(),
36 brandsText: List(), 41 brandsText: List(),
  42 + hasSuccess: false,
37 })), 43 })),
38 reourceForKid: new (Record({ 44 reourceForKid: new (Record({
39 banner: Map(), 45 banner: Map(),
40 custom_brands: Map(), 46 custom_brands: Map(),
41 brandsText: List(), 47 brandsText: List(),
  48 + hasSuccess: false,
42 })), 49 })),
43 reourceForLifeStyle: new (Record({ 50 reourceForLifeStyle: new (Record({
44 banner: Map(), 51 banner: Map(),
45 custom_brands: Map(), 52 custom_brands: Map(),
46 brandsText: List(), 53 brandsText: List(),
  54 + hasSuccess: false,
47 })), 55 })),
48 }); 56 });
49 57
@@ -73,11 +73,13 @@ export default function brandReducer(state=initialState, action) { @@ -73,11 +73,13 @@ export default function brandReducer(state=initialState, action) {
73 73
74 return state.setIn(['brandListForBoy', 'all_list'], Immutable.fromJS(all_list)) 74 return state.setIn(['brandListForBoy', 'all_list'], Immutable.fromJS(all_list))
75 .setIn(['brandListForBoy', 'hot_list'], Immutable.fromJS(hot_list)) 75 .setIn(['brandListForBoy', 'hot_list'], Immutable.fromJS(hot_list))
76 - .setIn(['brandListForBoy', 'new_list'], Immutable.fromJS(new_list)); 76 + .setIn(['brandListForBoy', 'new_list'], Immutable.fromJS(new_list))
  77 + .setIn(['brandListForBoy', 'hasSuccess'], true);
  78 +
77 } 79 }
78 case GET_BRAND_LIST_FOR_BOY_FAILURE: 80 case GET_BRAND_LIST_FOR_BOY_FAILURE:
79 { 81 {
80 - return state; 82 + return state.setIn(['brandListForBoy', 'hasSuccess'], false);
81 } 83 }
82 case GET_BRAND_LIST_FOR_GIRL_REQUEST: 84 case GET_BRAND_LIST_FOR_GIRL_REQUEST:
83 { 85 {
@@ -93,11 +95,12 @@ export default function brandReducer(state=initialState, action) { @@ -93,11 +95,12 @@ export default function brandReducer(state=initialState, action) {
93 95
94 return state.setIn(['brandListForGirl', 'all_list'], Immutable.fromJS(all_list)) 96 return state.setIn(['brandListForGirl', 'all_list'], Immutable.fromJS(all_list))
95 .setIn(['brandListForGirl', 'hot_list'], Immutable.fromJS(hot_list)) 97 .setIn(['brandListForGirl', 'hot_list'], Immutable.fromJS(hot_list))
96 - .setIn(['brandListForGirl', 'new_list'], Immutable.fromJS(new_list)); 98 + .setIn(['brandListForGirl', 'new_list'], Immutable.fromJS(new_list))
  99 + .setIn(['brandListForGirl', 'hasSuccess'], true);
97 } 100 }
98 case GET_BRAND_LIST_FOR_GIRL_FAILURE: 101 case GET_BRAND_LIST_FOR_GIRL_FAILURE:
99 { 102 {
100 - return state; 103 + return state.setIn(['brandListForGirl', 'hasSuccess'], false);
101 } 104 }
102 case GET_BRAND_LIST_FOR_KID_REQUEST: 105 case GET_BRAND_LIST_FOR_KID_REQUEST:
103 { 106 {
@@ -113,11 +116,12 @@ export default function brandReducer(state=initialState, action) { @@ -113,11 +116,12 @@ export default function brandReducer(state=initialState, action) {
113 116
114 return state.setIn(['brandListForKid', 'all_list'], Immutable.fromJS(all_list)) 117 return state.setIn(['brandListForKid', 'all_list'], Immutable.fromJS(all_list))
115 .setIn(['brandListForKid', 'hot_list'], Immutable.fromJS(hot_list)) 118 .setIn(['brandListForKid', 'hot_list'], Immutable.fromJS(hot_list))
116 - .setIn(['brandListForKid', 'new_list'], Immutable.fromJS(new_list)); 119 + .setIn(['brandListForKid', 'new_list'], Immutable.fromJS(new_list))
  120 + .setIn(['brandListForKid', 'hasSuccess'], true);
117 } 121 }
118 case GET_BRAND_LIST_FOR_KID_FAILURE: 122 case GET_BRAND_LIST_FOR_KID_FAILURE:
119 { 123 {
120 - return state; 124 + return state.setIn(['brandListForKid', 'hasSuccess'], false);
121 } 125 }
122 case GET_BRAND_LIST_FOR_LIFESTYLE_REQUEST: 126 case GET_BRAND_LIST_FOR_LIFESTYLE_REQUEST:
123 { 127 {
@@ -133,11 +137,12 @@ export default function brandReducer(state=initialState, action) { @@ -133,11 +137,12 @@ export default function brandReducer(state=initialState, action) {
133 137
134 return state.setIn(['brandListForLifeStyle', 'all_list'], Immutable.fromJS(all_list)) 138 return state.setIn(['brandListForLifeStyle', 'all_list'], Immutable.fromJS(all_list))
135 .setIn(['brandListForLifeStyle', 'hot_list'], Immutable.fromJS(hot_list)) 139 .setIn(['brandListForLifeStyle', 'hot_list'], Immutable.fromJS(hot_list))
136 - .setIn(['brandListForLifeStyle', 'new_list'], Immutable.fromJS(new_list)); 140 + .setIn(['brandListForLifeStyle', 'new_list'], Immutable.fromJS(new_list))
  141 + .setIn(['brandListForLifeStyle', 'hasSuccess'], true);
137 } 142 }
138 case GET_BRAND_LIST_FOR_LIFESTYLE_FAILURE: 143 case GET_BRAND_LIST_FOR_LIFESTYLE_FAILURE:
139 { 144 {
140 - return state; 145 + return state.setIn(['brandListForLifeStyle', 'hasSuccess'], false);
141 } 146 }
142 case GET_BRAND_RESOURCE_FOR_BOY_REQUEST: 147 case GET_BRAND_RESOURCE_FOR_BOY_REQUEST:
143 { 148 {
@@ -154,10 +159,11 @@ export default function brandReducer(state=initialState, action) { @@ -154,10 +159,11 @@ export default function brandReducer(state=initialState, action) {
154 return state.setIn(['reourceForBoy', 'banner'], Immutable.fromJS(banner)) 159 return state.setIn(['reourceForBoy', 'banner'], Immutable.fromJS(banner))
155 .setIn(['reourceForBoy', 'custom_brands'], Immutable.fromJS(custom_brands)) 160 .setIn(['reourceForBoy', 'custom_brands'], Immutable.fromJS(custom_brands))
156 .setIn(['reourceForBoy', 'brandsText'], Immutable.fromJS(brandsText)) 161 .setIn(['reourceForBoy', 'brandsText'], Immutable.fromJS(brandsText))
  162 + .setIn(['reourceForBoy', 'hasSuccess'], true);
157 } 163 }
158 case GET_BRAND_RESOURCE_FOR_BOY_FAILURE: 164 case GET_BRAND_RESOURCE_FOR_BOY_FAILURE:
159 { 165 {
160 - return state; 166 + return state.setIn(['reourceForBoy', 'hasSuccess'], false);
161 } 167 }
162 168
163 case GET_BRAND_RESOURCE_FOR_GIRL_REQUEST: 169 case GET_BRAND_RESOURCE_FOR_GIRL_REQUEST:
@@ -175,10 +181,11 @@ export default function brandReducer(state=initialState, action) { @@ -175,10 +181,11 @@ export default function brandReducer(state=initialState, action) {
175 return state.setIn(['reourceForGirl', 'banner'], Immutable.fromJS(banner)) 181 return state.setIn(['reourceForGirl', 'banner'], Immutable.fromJS(banner))
176 .setIn(['reourceForGirl', 'custom_brands'], Immutable.fromJS(custom_brands)) 182 .setIn(['reourceForGirl', 'custom_brands'], Immutable.fromJS(custom_brands))
177 .setIn(['reourceForGirl', 'brandsText'], Immutable.fromJS(brandsText)) 183 .setIn(['reourceForGirl', 'brandsText'], Immutable.fromJS(brandsText))
  184 + .setIn(['reourceForGirl', 'hasSuccess'], true);
178 } 185 }
179 case GET_BRAND_RESOURCE_FOR_GIRL_FAILURE: 186 case GET_BRAND_RESOURCE_FOR_GIRL_FAILURE:
180 { 187 {
181 - return state; 188 + return state.setIn(['reourceForGirl', 'hasSuccess'], false);
182 } 189 }
183 190
184 case GET_BRAND_RESOURCE_FOR_KID_REQUEST: 191 case GET_BRAND_RESOURCE_FOR_KID_REQUEST:
@@ -196,10 +203,11 @@ export default function brandReducer(state=initialState, action) { @@ -196,10 +203,11 @@ export default function brandReducer(state=initialState, action) {
196 return state.setIn(['reourceForKid', 'banner'], Immutable.fromJS(banner)) 203 return state.setIn(['reourceForKid', 'banner'], Immutable.fromJS(banner))
197 .setIn(['reourceForKid', 'custom_brands'], Immutable.fromJS(custom_brands)) 204 .setIn(['reourceForKid', 'custom_brands'], Immutable.fromJS(custom_brands))
198 .setIn(['reourceForKid', 'brandsText'], Immutable.fromJS(brandsText)) 205 .setIn(['reourceForKid', 'brandsText'], Immutable.fromJS(brandsText))
  206 + .setIn(['reourceForKid', 'hasSuccess'], true);
199 } 207 }
200 case GET_BRAND_RESOURCE_FOR_KID_FAILURE: 208 case GET_BRAND_RESOURCE_FOR_KID_FAILURE:
201 { 209 {
202 - return state; 210 + return state.setIn(['reourceForKid', 'hasSuccess'], false);
203 } 211 }
204 212
205 case GET_BRAND_RESOURCE_FOR_LIFESTYLE_REQUEST: 213 case GET_BRAND_RESOURCE_FOR_LIFESTYLE_REQUEST:
@@ -217,10 +225,11 @@ export default function brandReducer(state=initialState, action) { @@ -217,10 +225,11 @@ export default function brandReducer(state=initialState, action) {
217 return state.setIn(['reourceForLifeStyle', 'banner'], Immutable.fromJS(banner)) 225 return state.setIn(['reourceForLifeStyle', 'banner'], Immutable.fromJS(banner))
218 .setIn(['reourceForLifeStyle', 'custom_brands'], Immutable.fromJS(custom_brands)) 226 .setIn(['reourceForLifeStyle', 'custom_brands'], Immutable.fromJS(custom_brands))
219 .setIn(['reourceForLifeStyle', 'brandsText'], Immutable.fromJS(brandsText)) 227 .setIn(['reourceForLifeStyle', 'brandsText'], Immutable.fromJS(brandsText))
  228 + .setIn(['reourceForLifeStyle', 'hasSuccess'], true);
220 } 229 }
221 case GET_BRAND_RESOURCE_FOR_LIFESTYLE_FAILURE: 230 case GET_BRAND_RESOURCE_FOR_LIFESTYLE_FAILURE:
222 { 231 {
223 - return state; 232 + return state.setIn(['reourceForLifeStyle', 'hasSuccess'], false);
224 } 233 }
225 234
226 } 235 }