Authored by 叶弯弯

消息列表接口调试。reviewed by shixiang。

... ... @@ -24,6 +24,9 @@ export default keyMirror({
PWD_MODIFY_SUBMIT:null,
MESSAGE_DETAIL:null,
REQUEST_MSG_LIST: null,
REQUEST_MSG_LIST_SUCCESS: null,
REQUEST_MSG_LIST_FAILURE: null,
LOGIN_REQUEST: null,
LOGIN_SUCCESS: null,
... ...
... ... @@ -49,56 +49,16 @@ class MessageContainer extends Component {
constructor(props) {
super(props);
this.pressRow = this.pressRow.bind(this);
this.messageItems = [
{
type:'1',
title: '公告 商家端APP上线',
time: '2016-03-26',
content: 'xxxxxxx',
},
{
type:'2',
title: '变价通知 昨日已有234件商品价格发生变化',
time: '2016-03-26',
content: 'xxxxxx',
},
{
type:'3',
title: '到货入库 有800件商品到货了',
time: '2016-03-26',
content: 'xxxxxsssssssssssssssssssssssffsssgsggsgsgsgsgsgsgsgsgsgsggsgsgssshahshshshshshshshshhshshshshshshshshshshshshshhshshshshsh',
},
{
type:'4',
title: '对账结算 新的结算订单生成',
time: '2016-03-26',
content: 'xxxxxx',
},
{
type:'4',
title: '对账结算 新的结算订单生成',
time: '2016-03-26',
content: 'xxxxxx',
},
{
type:'4',
title: '对账结算 新的结算订单生成',
time: '2016-03-26',
content: 'xxxxxx',
},
{
type:'4',
title: '对账结算 新的结算订单生成',
time: '2016-03-26',
content: 'xxxxxx',
},
];
}
componentDidMount() {
this.props.actions.getMsgList(this.props.home.brandId);
}
pressRow(rowID){
this.props.actions.checkMessageDetail(this.messageItems[rowID]);
this.props.actions.checkMessageDetail(this.props.message.messageList.toJS()[rowID]);
}
render() {
return (
<View style={styles.container}>
... ... @@ -107,7 +67,7 @@ class MessageContainer extends Component {
barStyle={'light-content'}
/>
<Message
items={this.messageItems}
items={this.props.message.messageList.toJS()}
onPressItem={this.pressRow}
/>
</View>
... ...
... ... @@ -7,11 +7,13 @@
'use strict';
import {Actions} from 'react-native-router-flux';
import AppAuthToken from '../../services/AppAuthToken';
import UserService from '../../services/UserService';
import MessageService from '../../services/MessageService';
const {
MESSAGE_DETAIL,
REQUEST_MSG_LIST,
REQUEST_MSG_LIST_SUCCESS,
REQUEST_MSG_LIST_FAILURE,
} = require('../../constants/actionTypes').default;
export function checkMessageDetail(item) {
... ... @@ -20,4 +22,38 @@ export function checkMessageDetail(item) {
type: MESSAGE_DETAIL,
payload: item,
};
}
\ No newline at end of file
}
export function requestMsgList(shopsId) {
return {
type: REQUEST_MSG_LIST,
payload: shopsId,
}
}
export function requestMsgListSuccess(json) {
return {
type: REQUEST_MSG_LIST_SUCCESS,
payload: json,
}
}
export function requestMsgListFailure(error) {
return {
type: REQUEST_MSG_LIST_FAILURE,
payload: error,
}
}
export function getMsgList(shopsId) {
return dispatch => {
dispatch(requestMsgList(shopsId));
return new MessageService().getMsgList(shopsId)
.then(json => {
dispatch(requestMsgListSuccess(json));
})
.catch(error => {
dispatch(requestMsgListFailure(error));
});
};
}
... ...
/**
* # guideInitialState.js
*
*
*
*/
'use strict';
/**
* ## Import immutable record
*/
import {Record} from 'immutable';
import {Record, List} from 'immutable';
/**
* ## InitialState
*
*
* The fields we're concerned with
*/
let InitialState = Record({
isFetching: false,
error: null,
messageDetail: new (Record({
title: '',
content: '',
time: '',
})),
messageList: List(),
});
export default InitialState;
... ...
... ... @@ -10,12 +10,15 @@
* InitialState
*/
import InitialState from './messageInitialState';
import Immutable, {List, Record} from 'immutable';
const initialState = new InitialState;
const {
MESSAGE_DETAIL,
REQUEST_MSG_LIST,
REQUEST_MSG_LIST_SUCCESS,
REQUEST_MSG_LIST_FAILURE,
} = require('../../constants/actionTypes').default;
/**
* ## guideReducer function
... ... @@ -29,9 +32,24 @@ export default function messageReducer(state = initialState, action) {
case MESSAGE_DETAIL:{
let nextState = state.setIn(['messageDetail', 'title'], action.payload.title)
.setIn(['messageDetail', 'content'], action.payload.content)
.setIn(['messageDetail', 'time'], action.payload.time);
.setIn(['messageDetail', 'time'], action.payload.createTime);
return nextState;
}
case REQUEST_MSG_LIST: {
let nextState = state.set('isFetching', true)
.set('error', null);
return nextState;
}
case REQUEST_MSG_LIST_SUCCESS: {
let nextState = state.set('isFetching', false)
.set('error', null)
.set('messageList', Immutable.fromJS(action.payload.list));
return nextState;
}
case REQUEST_MSG_LIST_FAILURE: {
return state.set('isFetching', false)
.set('error', action.payload);
}
}
... ...
'use strict';
import Request from './Request';
export default class MessageService {
constructor () {
this.api = new Request();
}
async getMsgList(shopsId) {
return this.api.get({
url: '/gateway',
body: {
shopsId: shopsId,
method: 'app.shopInbox.getList',
debug: 'XYZ',
}
})
.then(json => {
return json;
})
.catch(error => {
throw error;
});
}
}
... ...