Authored by 孙凯

解决重复请求 review by 红魔

... ... @@ -71,8 +71,39 @@ class BrandContainer extends Component {
}
_onChannelPressFliter(value){
this.props.actions.getBrandList(value);
this.props.actions.getBrandResource(value);
let {
brandListForBoy,
brandListForGirl,
brandListForKid,
brandListForLifeStyle,
reourceForBoy,
reourceForGirl,
reourceForKid,
reourceForLifeStyle,
} = this.props.brand;
let brandListNeedRequest;
let reourceNeedRequest;
if (value == 0) {
brandListNeedRequest = brandListForBoy.get('hasSuccess');
reourceNeedRequest = reourceForBoy.get('hasSuccess');
}else if (value == 1) {
brandListNeedRequest = brandListForGirl.get('hasSuccess');
reourceNeedRequest = reourceForGirl.get('hasSuccess');
}else if (value == 2) {
brandListNeedRequest = brandListForKid.get('hasSuccess');
reourceNeedRequest = reourceForKid.get('hasSuccess');
}else if (value == 3) {
brandListNeedRequest = brandListForLifeStyle.get('hasSuccess');
reourceNeedRequest = reourceForLifeStyle.get('hasSuccess');
}
if (!brandListNeedRequest) {
this.props.actions.getBrandList(value);
}
if (!brandListNeedRequest) {
this.props.actions.getBrandResource(value);
}
this.props.actions.setChannelFilter(value);
}
... ... @@ -89,6 +120,7 @@ class BrandContainer extends Component {
reourceForKid,
reourceForLifeStyle,
} = this.props.brand;
console.log(this.props.brand);
return (
<View style={styles.container}>
<Brand
... ...
... ... @@ -9,41 +9,49 @@ let InitialState = Record({
all_list: Map(),
hot_list: List(),
new_list: List(),
hasSuccess: false,
})),
brandListForGirl: new (Record({
all_list: Map(),
hot_list: List(),
new_list: List(),
hasSuccess: false,
})),
brandListForKid: new (Record({
all_list: Map(),
hot_list: List(),
new_list: List(),
hasSuccess: false,
})),
brandListForLifeStyle: new (Record({
all_list: Map(),
hot_list: List(),
new_list: List(),
hasSuccess: false,
})),
reourceForBoy: new (Record({
banner: Map(),
custom_brands: Map(),
brandsText: List(),
hasSuccess: false,
})),
reourceForGirl: new (Record({
banner: Map(),
custom_brands: Map(),
brandsText: List(),
hasSuccess: false,
})),
reourceForKid: new (Record({
banner: Map(),
custom_brands: Map(),
brandsText: List(),
hasSuccess: false,
})),
reourceForLifeStyle: new (Record({
banner: Map(),
custom_brands: Map(),
brandsText: List(),
hasSuccess: false,
})),
});
... ...
... ... @@ -73,11 +73,13 @@ export default function brandReducer(state=initialState, action) {
return state.setIn(['brandListForBoy', 'all_list'], Immutable.fromJS(all_list))
.setIn(['brandListForBoy', 'hot_list'], Immutable.fromJS(hot_list))
.setIn(['brandListForBoy', 'new_list'], Immutable.fromJS(new_list));
.setIn(['brandListForBoy', 'new_list'], Immutable.fromJS(new_list))
.setIn(['brandListForBoy', 'hasSuccess'], true);
}
case GET_BRAND_LIST_FOR_BOY_FAILURE:
{
return state;
return state.setIn(['brandListForBoy', 'hasSuccess'], false);
}
case GET_BRAND_LIST_FOR_GIRL_REQUEST:
{
... ... @@ -93,11 +95,12 @@ export default function brandReducer(state=initialState, action) {
return state.setIn(['brandListForGirl', 'all_list'], Immutable.fromJS(all_list))
.setIn(['brandListForGirl', 'hot_list'], Immutable.fromJS(hot_list))
.setIn(['brandListForGirl', 'new_list'], Immutable.fromJS(new_list));
.setIn(['brandListForGirl', 'new_list'], Immutable.fromJS(new_list))
.setIn(['brandListForGirl', 'hasSuccess'], true);
}
case GET_BRAND_LIST_FOR_GIRL_FAILURE:
{
return state;
return state.setIn(['brandListForGirl', 'hasSuccess'], false);
}
case GET_BRAND_LIST_FOR_KID_REQUEST:
{
... ... @@ -113,11 +116,12 @@ export default function brandReducer(state=initialState, action) {
return state.setIn(['brandListForKid', 'all_list'], Immutable.fromJS(all_list))
.setIn(['brandListForKid', 'hot_list'], Immutable.fromJS(hot_list))
.setIn(['brandListForKid', 'new_list'], Immutable.fromJS(new_list));
.setIn(['brandListForKid', 'new_list'], Immutable.fromJS(new_list))
.setIn(['brandListForKid', 'hasSuccess'], true);
}
case GET_BRAND_LIST_FOR_KID_FAILURE:
{
return state;
return state.setIn(['brandListForKid', 'hasSuccess'], false);
}
case GET_BRAND_LIST_FOR_LIFESTYLE_REQUEST:
{
... ... @@ -133,11 +137,12 @@ export default function brandReducer(state=initialState, action) {
return state.setIn(['brandListForLifeStyle', 'all_list'], Immutable.fromJS(all_list))
.setIn(['brandListForLifeStyle', 'hot_list'], Immutable.fromJS(hot_list))
.setIn(['brandListForLifeStyle', 'new_list'], Immutable.fromJS(new_list));
.setIn(['brandListForLifeStyle', 'new_list'], Immutable.fromJS(new_list))
.setIn(['brandListForLifeStyle', 'hasSuccess'], true);
}
case GET_BRAND_LIST_FOR_LIFESTYLE_FAILURE:
{
return state;
return state.setIn(['brandListForLifeStyle', 'hasSuccess'], false);
}
case GET_BRAND_RESOURCE_FOR_BOY_REQUEST:
{
... ... @@ -154,10 +159,11 @@ export default function brandReducer(state=initialState, action) {
return state.setIn(['reourceForBoy', 'banner'], Immutable.fromJS(banner))
.setIn(['reourceForBoy', 'custom_brands'], Immutable.fromJS(custom_brands))
.setIn(['reourceForBoy', 'brandsText'], Immutable.fromJS(brandsText))
.setIn(['reourceForBoy', 'hasSuccess'], true);
}
case GET_BRAND_RESOURCE_FOR_BOY_FAILURE:
{
return state;
return state.setIn(['reourceForBoy', 'hasSuccess'], false);
}
case GET_BRAND_RESOURCE_FOR_GIRL_REQUEST:
... ... @@ -175,10 +181,11 @@ export default function brandReducer(state=initialState, action) {
return state.setIn(['reourceForGirl', 'banner'], Immutable.fromJS(banner))
.setIn(['reourceForGirl', 'custom_brands'], Immutable.fromJS(custom_brands))
.setIn(['reourceForGirl', 'brandsText'], Immutable.fromJS(brandsText))
.setIn(['reourceForGirl', 'hasSuccess'], true);
}
case GET_BRAND_RESOURCE_FOR_GIRL_FAILURE:
{
return state;
return state.setIn(['reourceForGirl', 'hasSuccess'], false);
}
case GET_BRAND_RESOURCE_FOR_KID_REQUEST:
... ... @@ -196,10 +203,11 @@ export default function brandReducer(state=initialState, action) {
return state.setIn(['reourceForKid', 'banner'], Immutable.fromJS(banner))
.setIn(['reourceForKid', 'custom_brands'], Immutable.fromJS(custom_brands))
.setIn(['reourceForKid', 'brandsText'], Immutable.fromJS(brandsText))
.setIn(['reourceForKid', 'hasSuccess'], true);
}
case GET_BRAND_RESOURCE_FOR_KID_FAILURE:
{
return state;
return state.setIn(['reourceForKid', 'hasSuccess'], false);
}
case GET_BRAND_RESOURCE_FOR_LIFESTYLE_REQUEST:
... ... @@ -217,10 +225,11 @@ export default function brandReducer(state=initialState, action) {
return state.setIn(['reourceForLifeStyle', 'banner'], Immutable.fromJS(banner))
.setIn(['reourceForLifeStyle', 'custom_brands'], Immutable.fromJS(custom_brands))
.setIn(['reourceForLifeStyle', 'brandsText'], Immutable.fromJS(brandsText))
.setIn(['reourceForLifeStyle', 'hasSuccess'], true);
}
case GET_BRAND_RESOURCE_FOR_LIFESTYLE_FAILURE:
{
return state;
return state.setIn(['reourceForLifeStyle', 'hasSuccess'], false);
}
}
... ...