detailReducer.js
2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
'use strict';
import InitialState from './detailInitialState';
import Immutable, {Map} from 'immutable';
const {
BRAND_INFO_REQUEST,
BRAND_INFO_SUCCESS,
BRAND_INFO_FAILURE,
JUMP_WITH_URL,
SET_BRAND_ID,
SET_GENDER,
SET_UDID,
BRADN_FAV_REQUEST,
BRADN_FAV_SUCCESS,
BRADN_FAV_FAILURE,
NEW_ARRIVE_REQUEST,
NEW_ARRIVE_SUCCESS,
NEW_ARRIVE_FAILURE,
ARTICLE_BY_BRAND_REQUEST,
ARTICLE_BY_BRAND_SUCCESS,
ARTICLE_BY_BRAND_FAILURE,
ADD_FAVORITE_REQUEST,
ADD_FAVORITE_SUCCESS,
ADD_FAVORITE_FAILURE,
CANCEL_FAVORITE_REQUEST,
CANCEL_FAVORITE_SUCCESS,
CANCEL_FAVORITE_FAILURE,
PRAISE_ARTICLE_REQUEST,
PRAISE_ARTICLE_SUCCESS,
PRAISE_ARTICLE_FAILURE,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
export default function plustarReducer(state=initialState, action) {
switch(action.type) {
case BRAND_INFO_REQUEST: {
return state.setIn(['brandInfo', 'isFetching'], true)
.setIn(['brandInfo', 'error'], null);
}
case BRAND_INFO_SUCCESS: {
return state.setIn(['brandInfo', 'detail'], Immutable.fromJS(action.payload))
.setIn(['brandInfo', 'isFetching'], false)
.setIn(['brandInfo', 'error'], null);
}
case BRAND_INFO_FAILURE: {
return state.setIn(['brandInfo', 'isFetching'], false)
.setIn(['brandInfo', 'error'], action.payload);
}
case SET_BRAND_ID:{
return state.set('brandId', action.payload);
}
case SET_UDID:{
return state.set('udid', action.payload);
}
case NEW_ARRIVE_SUCCESS:{
return state.set('productList', Immutable.fromJS(action.payload));
}
case ARTICLE_BY_BRAND_SUCCESS:{
return state.set('articleList', Immutable.fromJS(action.payload));
}
case PRAISE_ARTICLE_SUCCESS:{
console.log("chenlin", "PRAISE_ARTICLE_SUCCESS:" + JSON.stringify(action.payload));
}
case PRAISE_ARTICLE_FAILURE:{
console.log("chenlin", "PRAISE_ARTICLE_FAILURE:" + JSON.stringify(action.payload));
}
}
return state;
}