api.js
export async function queryClubTotalInfo(action) {
let browseRet = {}, noticeRet = {}, newestActRet = {}, blogRet = {};
let browseResponse = await http.post('acc/club/clubInfo/' + action.browseParams);
let noticeResponse = await http.post('act/blog/blogList',action.noticeParams);
let newestActResponse = await http.post('act/activity/getNewActivity/' + action.newestActParams);
let blogResponse = await http.post('act/blog/blogList',action.blogParams);
if (browseResponse !== undefined){
browseRet = browseResponse;
console.log('%s %O', '社群浏览信息', browseResponse);
// alert(JSON.stringify(browseResponse) + '-/1/-' + JSON.stringify(action.browseParams))
}
if (noticeResponse !== undefined){
noticeRet = noticeResponse;
console.log('%s %O', '查询公告列表', noticeResponse);
// alert(JSON.stringify(noticeResponse) + '-/2/-' + JSON.stringify(action.noticeParams))
}
if (newestActResponse !== undefined){
newestActRet = newestActResponse;
console.log('%s %O', '查询最新活动', newestActResponse);
// alert(JSON.stringify(newestActResponse) + '-/3/-' + JSON.stringify(action.newestActParams))
}
if (blogResponse !== undefined){
blogRet = blogResponse;
console.log('%s %O', '查询动态列表', blogResponse);
// alert(JSON.stringify(blogResponse) + '-/4/-' + JSON.stringify(action.blogParams))
}
return [browseRet,noticeRet,newestActRet,blogRet];
}
reduce.js
const initQueryClubTotalInfoState = {
status: types.CLUB_QUERY_TOTAL_INFO_END,
// browseParams: null,
browseId: null,
noticeParams: null,
newestActParams: null,
blogParams: null,
browseResult: null,
noticeResult: {data: []},
newestActResult: null,
blogResult: {data: []},
message: null,
};
export const queryClubTotalInfoState = (state = initQueryClubTotalInfoState, action) => {
switch (action.type) {
case types.CLUB_QUERY_TOTAL_INFO_END:
return Object.assign({}, state, {
status: types.CLUB_QUERY_TOTAL_INFO_END,
});
case types.CLUB_QUERY_TOTAL_INFO_SUCCESS:
return Object.assign({}, state, {
status: types.CLUB_QUERY_TOTAL_INFO_SUCCESS,
browseParams: action.browseParams,
noticeParams: action.noticeParams,
newestActParams: action.newestActParams,
blogParams: action.blogParams,
browseResult: action.browseResult,
noticeResult: action.noticeResult,
newestActResult: action.newestActResult,
blogResult: action.blogResult,
});
case types.CLUB_QUERY_TOTAL_INFO_ERROR:
return Object.assign({}, state, {
status: types.CLUB_QUERY_TOTAL_INFO_ERROR,
message: action.message,
})
}
return state
};
sagas.js
const queryClubTotalInfoRequest = function* queryClubTotalInfoRequest(action) {
let data = yield call(queryClubTotalInfo,action);
if (data[0].code === 0 && data[1].code === 0 && data[2].code === 0 && data[3].code === 0) {
yield put({
type: types.CLUB_QUERY_TOTAL_INFO_SUCCESS,
browseResult: data[0].result,
noticeResult: data[1].result,
newestActResult: data[2].result,
blogResult: data[3].result,
})
} else {
yield put({
type: types.CLUB_QUERY_TOTAL_INFO_ERROR,
message: data[0].message,
})
}
};
网友评论