2017-08-07 19:34:34 +08:00
|
|
|
// Actions
|
|
|
|
const FETCH_NEWS_DATA = 'yapi/news/FETCH_NEWS_DATA';
|
2017-07-17 12:15:21 +08:00
|
|
|
|
2017-08-07 19:34:34 +08:00
|
|
|
// Reducer
|
2017-07-17 12:15:21 +08:00
|
|
|
const initialState = {
|
2017-08-09 16:08:37 +08:00
|
|
|
newsData: {
|
|
|
|
list: [],
|
|
|
|
total: 0
|
|
|
|
},
|
|
|
|
curpage: 1
|
2017-07-17 12:15:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default (state = initialState, action) => {
|
|
|
|
switch (action.type) {
|
|
|
|
case FETCH_NEWS_DATA: {
|
2017-08-09 16:08:37 +08:00
|
|
|
const list = action.payload.data.data.list;
|
|
|
|
state.newsData.list.push(...list);
|
2017-08-09 18:00:45 +08:00
|
|
|
state.newsData.list.sort(function(a,b){
|
|
|
|
return b.add_time - a.add_time;
|
|
|
|
})
|
2017-08-09 16:08:37 +08:00
|
|
|
if(list && list.length){
|
|
|
|
state.curpage++;
|
|
|
|
}
|
2017-07-17 12:15:21 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2017-08-09 16:08:37 +08:00
|
|
|
newsData: {
|
|
|
|
total:action.payload.data.data.total,
|
|
|
|
list: state.newsData.list
|
|
|
|
}
|
2017-07-17 12:15:21 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|
2017-07-18 10:17:07 +08:00
|
|
|
|
2017-08-07 19:34:34 +08:00
|
|
|
// Action Creators
|
|
|
|
import axios from 'axios';
|
|
|
|
import variable from '../../constants/variable';
|
|
|
|
|
2017-08-11 17:49:47 +08:00
|
|
|
export function fetchNewsData (typeid,type,page,limit) {
|
2017-08-07 19:34:34 +08:00
|
|
|
const param = {
|
2017-08-09 18:00:45 +08:00
|
|
|
typeid: typeid,
|
2017-08-11 17:49:47 +08:00
|
|
|
type: type,
|
2017-08-07 19:34:34 +08:00
|
|
|
page: page,
|
2017-08-09 16:08:37 +08:00
|
|
|
limit: limit?limit:variable.PAGE_LIMIT
|
2017-08-07 19:34:34 +08:00
|
|
|
}
|
|
|
|
return {
|
|
|
|
type: FETCH_NEWS_DATA,
|
2017-08-11 10:25:19 +08:00
|
|
|
payload: axios.get('/api/log/list',{
|
2017-08-07 19:34:34 +08:00
|
|
|
params: param
|
|
|
|
})
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-08-09 18:00:45 +08:00
|
|
|
export function getMockUrl(project_id){
|
|
|
|
const params = {id: project_id};
|
|
|
|
return {
|
|
|
|
type:"",
|
2017-08-11 10:25:19 +08:00
|
|
|
payload: axios.get('/api/project/get', {params: params})
|
2017-08-09 18:00:45 +08:00
|
|
|
}
|
|
|
|
|
2017-08-07 19:34:34 +08:00
|
|
|
}
|
2017-08-09 18:00:45 +08:00
|
|
|
|