appReducer.js
1.35 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
'use strict';
import InitialState from './appInitialState';
const {
SET_PLATFORM,
SET_CHANNEL,
SET_HOST,
SET_TYPE,
SET_SHOP,
SET_BRANDID,
SET_ORIGINPARAMS,
SET_SALETYPE,
SET_SERVICE_HOST,
SET_ACTIVITY_ID,
SET_BANNER_URL,
SET_LIST_TYPE,
} = require('../../constants/actionTypes').default;
const initialState = new InitialState;
export default function appReducer(state = initialState, action) {
if (!(state instanceof InitialState)) return initialState.merge(state);
switch (action.type) {
case SET_PLATFORM:
return state.set('platform', action.payload);
case SET_CHANNEL:
return state.set('channel', action.payload);
case SET_HOST:
return state.set('host', action.payload);
case SET_SERVICE_HOST:
return state.set('serviceHost', action.payload);
case SET_TYPE:
return state.set('type', action.payload);
case SET_SHOP:
return state.set('shop_id', action.payload);
case SET_BRANDID:
return state.set('brand_id', action.payload);
case SET_ORIGINPARAMS:
return state.set('originParams', action.payload);
case SET_SALETYPE:
return state.set('saleType', action.payload);
case SET_ACTIVITY_ID:
return state.set('activityId', action.payload);
case SET_BANNER_URL:
return state.set('bannerUrl', action.payload);
case SET_LIST_TYPE:
return state.set('listType', action.payload);
}
return state;
}