repayDetailReducer.js
1.37 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
'use strict';
import InitialState from './repayDetailInitialState';
import Immutable, {Map} from 'immutable';
const {
SET_REPAY_ORDER_NO,
SET_TIP_MESSAGE,
SET_ERROR,
QUERY_REPAY_RECORD_LIST_REQUEST,
QUERY_REPAY_RECORD_LIST_FAILURE,
QUERY_REPAY_RECORD_LIST_SUCCESS,
} = 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_REPAY_ORDER_NO:
return state.set('repayOrderNo', action.payload);
case SET_TIP_MESSAGE:
return state.set('tipMessage', action.payload);
case QUERY_REPAY_RECORD_LIST_REQUEST:
return state.set('isFetching', true);
case QUERY_REPAY_RECORD_LIST_SUCCESS:
return state.set('repayList', Immutable.fromJS(action.payload.detailInfoList))
.set('currentPage', action.payload.currentPage)
.set('pageTotal', action.payload.pageTotal)
.set('isFetching', false);
case QUERY_REPAY_RECORD_LIST_FAILURE:
return state.set('isFetching', false)
.set('tipMessage', error.message||'暂未获取到数据');
case SET_ERROR:
return state.set('error', action.payload);
}
return state;
}