...
|
...
|
@@ -54,47 +54,6 @@ export function likeMessageFailue(error) { |
|
|
};
|
|
|
}
|
|
|
|
|
|
export function likeMessage(ptr = false) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {user, message} = getState();
|
|
|
|
|
|
// 接口请求跳出的条件:
|
|
|
// 前置条件:下拉刷新优先级高于上拉加载
|
|
|
if (ptr) {
|
|
|
//下拉刷新直接执行
|
|
|
} else {
|
|
|
// 1.当次请求不是下拉刷新,同时正在进行下拉刷新的请求,跳出
|
|
|
// 2.当次请求不是下拉刷新,同时接口请求正在加载中, 跳出
|
|
|
// 3.当次请求不是下拉刷新,数据已全部加载完成,跳出
|
|
|
if (message.like.ptr || message.like.isFetching || message.like.endReached || message.like.error) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
dispatch(likeMessageRequest(ptr));
|
|
|
|
|
|
let uid = user.profile.uid;
|
|
|
let lastedTime = 0;
|
|
|
if (!ptr) {
|
|
|
lastedTime = message.like.lastedTime;
|
|
|
}
|
|
|
let type = 2; // 点赞列表
|
|
|
let limit = 10;
|
|
|
|
|
|
return new MessageService().messageList(uid, type, lastedTime, limit)
|
|
|
.then(json => {
|
|
|
let payload = parseLikeMessage(json);
|
|
|
if (!ptr) {
|
|
|
let oldList = message.like.list.toJS();
|
|
|
let list = [...oldList, ...payload.list];
|
|
|
payload.list = list;
|
|
|
}
|
|
|
dispatch(likeMessageSuccess(payload));
|
|
|
});
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function messageInfoRequest(ptr) {
|
|
|
return {
|
|
|
type: MESSAGE_INFO_REQUEST,
|
...
|
...
|
@@ -137,6 +96,71 @@ export function replyMessageFailue(error) { |
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
export function systemMessageRequest(ptr) {
|
|
|
return {
|
|
|
type: MESSAGE_SYST_REQUEST,
|
|
|
payload: ptr,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function systemMessageSuccess(json) {
|
|
|
return {
|
|
|
type: MESSAGE_SYST_SUCCESS,
|
|
|
payload: json,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function systemMessageFailue(error) {
|
|
|
return {
|
|
|
type: MESSAGE_SYST_FAILURE,
|
|
|
payload: error,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function likeMessage(ptr = false) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {user, message} = getState();
|
|
|
|
|
|
// 接口请求跳出的条件:
|
|
|
// 前置条件:下拉刷新优先级高于上拉加载
|
|
|
if (ptr) {
|
|
|
//下拉刷新直接执行
|
|
|
} else {
|
|
|
// 1.当次请求不是下拉刷新,同时正在进行下拉刷新的请求,跳出
|
|
|
// 2.当次请求不是下拉刷新,同时接口请求正在加载中, 跳出
|
|
|
// 3.当次请求不是下拉刷新,数据已全部加载完成,跳出
|
|
|
if (message.like.ptr || message.like.isFetching || message.like.endReached || message.like.error) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
dispatch(likeMessageRequest(ptr));
|
|
|
|
|
|
let uid = user.profile.uid;
|
|
|
let lastedTime = 0;
|
|
|
if (!ptr) {
|
|
|
lastedTime = message.like.lastedTime;
|
|
|
}
|
|
|
let limit = 10;
|
|
|
|
|
|
return new MessageService().messageList(uid, 2, lastedTime, limit)
|
|
|
.then(json => {
|
|
|
let payload = parseMessageList(json);
|
|
|
if (!ptr) {
|
|
|
let oldList = message.like.list.toJS();
|
|
|
let list = [...oldList, ...payload.list];
|
|
|
payload.list = list;
|
|
|
}
|
|
|
dispatch(likeMessageSuccess(payload));
|
|
|
});
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
export function messageInfo(ptr = false) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {user, message} = getState();
|
...
|
...
|
@@ -148,7 +172,6 @@ export function messageInfo(ptr = false) { |
|
|
.then(json => {
|
|
|
// console.log('');
|
|
|
let payload = parseMessageInfo(json);
|
|
|
console.log('message info paylod = ' + payload);
|
|
|
dispatch(messageInfoSuccess(payload));
|
|
|
})
|
|
|
.catch(error => {
|
...
|
...
|
@@ -168,11 +191,24 @@ export function replyMessage(ptr = false) { |
|
|
lastedTime = message.centerMsg.lastedTime;
|
|
|
}
|
|
|
|
|
|
if (!ptr) {
|
|
|
if (message.centerMsg.ptr || message.centerMsg.isFetching || message.centerMsg.endReached || message.centerMsg.error) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
dispatch(replyMessageRequest(ptr));
|
|
|
|
|
|
return new MessageService().messageList(3, uid, lastedTime, limit)
|
|
|
return new MessageService().messageList(uid, 3, lastedTime, limit)
|
|
|
.then(json => {
|
|
|
let payload = parseMessageList(json);
|
|
|
|
|
|
if (!ptr) {
|
|
|
let oldList = message.centerMsg.list.toJS();
|
|
|
let list = [...oldList, ...payload.list];
|
|
|
payload.list = list;
|
|
|
}
|
|
|
|
|
|
dispatch(replyMessageSuccess(payload));
|
|
|
})
|
|
|
.catch(error => {
|
...
|
...
|
@@ -181,28 +217,91 @@ export function replyMessage(ptr = false) { |
|
|
};
|
|
|
}
|
|
|
|
|
|
export function systemMessage() {
|
|
|
export function systemMessage(ptr = false) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {user} = getState();
|
|
|
dispatch();
|
|
|
let limit = 10;
|
|
|
let {user, message} = getState();
|
|
|
let uid = user.profile.uid;
|
|
|
|
|
|
return new MessageService().messageList(1, uid)
|
|
|
.then(json => {
|
|
|
let lastedTime = 0;
|
|
|
if (!ptr) {
|
|
|
lastedTime = message.system.lastedTime;
|
|
|
}
|
|
|
|
|
|
if (!ptr) {
|
|
|
if (message.system.ptr || message.system.isFetching || message.system.endReached || message.system.error) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
dispatch(systemMessageRequest(ptr));
|
|
|
|
|
|
return new MessageService().messageList(uid, 1, lastedTime, limit)
|
|
|
.then(json => {
|
|
|
let payload = parseMessageList(json);
|
|
|
if (!ptr) {
|
|
|
let oldList = message.system.list.toJS();
|
|
|
let list = [...oldList, ...payload.list];
|
|
|
payload.list = list;
|
|
|
}
|
|
|
dispatch(systemMessageSuccess(payload));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
|
|
|
dispatch(systemMessageFailue(error));
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function goToLikeMessage() {
|
|
|
Actions.LikeMessage();
|
|
|
return {
|
|
|
type: GO_TO_LIKE_MESSAGE,
|
|
|
// payload:
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function goToSystemMessage() {
|
|
|
Actions.SystemMessage();
|
|
|
return {
|
|
|
type: GO_TO_SYS_MESSAGE,
|
|
|
// payload:
|
|
|
};
|
|
|
}
|
|
|
|
|
|
function parseMessageInfo(json) {
|
|
|
let {praiseMsg, systemMsg} = json;
|
|
|
|
|
|
let like={} , sys={};
|
|
|
|
|
|
function parseLikeMessage(json) {
|
|
|
if (praiseMsg) {
|
|
|
like = {
|
|
|
tips: praiseMsg.title || '',
|
|
|
isRead: (praiseMsg.isRead === 'N')?false:true,
|
|
|
timeagoStr:timeago(praiseMsg.createTime),
|
|
|
};
|
|
|
}
|
|
|
|
|
|
if (systemMsg) {
|
|
|
sys = {
|
|
|
tips: systemMsg.title || '',
|
|
|
isRead: (systemMsg.isRead === 'N')?false:true,
|
|
|
timeagoStr:timeago(systemMsg.createTime),
|
|
|
};
|
|
|
}
|
|
|
let result = {
|
|
|
likeMsg: like,
|
|
|
sysMsg: sys,
|
|
|
};
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
function parseMessageList(json) {
|
|
|
let {lastedTime, list} = json;
|
|
|
let messages = [];
|
|
|
list && list.map((item, i) => {
|
|
|
let messages = [];
|
|
|
|
|
|
list && list.map((item, i) => {
|
|
|
|
|
|
let id = item.id ? item.id : 0;
|
|
|
let title = item.title ? item.title : '';
|
...
|
...
|
@@ -214,6 +313,7 @@ function parseLikeMessage(json) { |
|
|
let user = {};
|
|
|
let post = {};
|
|
|
let {content} = item;
|
|
|
let {subTitle} = content;
|
|
|
if (content) {
|
|
|
let {userInfo, postInfo} = content;
|
|
|
if (userInfo) {
|
...
|
...
|
@@ -231,14 +331,16 @@ function parseLikeMessage(json) { |
|
|
};
|
|
|
}
|
|
|
if (postInfo) {
|
|
|
let sectionId = postInfo.sectionId ? postInfo.sectionId : '';
|
|
|
let sectionId = postInfo.forumCode ? postInfo.forumCode : '';
|
|
|
let postId = postInfo.postId ? postInfo.postId : 0;
|
|
|
let sectionName = postInfo.forumName ? postInfo.forumName : '';
|
|
|
postId = parseInt(postId);
|
|
|
let thumb = postInfo.content ? postInfo.content : '';
|
|
|
post = {
|
|
|
id: postId,
|
|
|
thumb,
|
|
|
sectionId,
|
|
|
sectionName,
|
|
|
};
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -252,6 +354,7 @@ function parseLikeMessage(json) { |
|
|
timeago: timeagoStr,
|
|
|
user,
|
|
|
post,
|
|
|
subTitle,
|
|
|
};
|
|
|
|
|
|
messages.push(message);
|
...
|
...
|
@@ -264,37 +367,3 @@ function parseLikeMessage(json) { |
|
|
endReached,
|
|
|
};
|
|
|
} |
|
|
|
|
|
function parseMessageInfo(json) {
|
|
|
let {praiseMsg, systemMsg} = json;
|
|
|
|
|
|
let like={} , sys={};
|
|
|
|
|
|
if (praiseMsg) {
|
|
|
like = {
|
|
|
tips: praiseMsg.title || '',
|
|
|
isRead: (praiseMsg.isRead === 'N')?false:true,
|
|
|
timeagoStr:timeago(praiseMsg.createTime),
|
|
|
};
|
|
|
}
|
|
|
|
|
|
if (systemMsg) {
|
|
|
sys = {
|
|
|
tips: systemMsg.title || '',
|
|
|
isRead: (systemMsg.isRead === 'N')?false:true,
|
|
|
timeagoStr:timeago(systemMsg.createTime),
|
|
|
};
|
|
|
}
|
|
|
let result = {
|
|
|
likeMsg: like,
|
|
|
sysMsg: sys,
|
|
|
};
|
|
|
|
|
|
console.log('result ======== ' + result);
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
function parseMessageList(json) {
|
|
|
console.log('========>', json);
|
|
|
} |
...
|
...
|
|