...
|
...
|
@@ -3,13 +3,13 @@ import {getArticleImageSize} from 'utils/image-handler'; |
|
|
import { get } from 'lodash';
|
|
|
import Vue from 'vue';
|
|
|
|
|
|
function articlefield(type) {
|
|
|
function articlefield(type, thumb) {
|
|
|
if (type === 'article') {
|
|
|
return 'articleList';
|
|
|
return `article${thumb ? 'Thumb' : ''}List`;
|
|
|
} else if (type === 'topic') {
|
|
|
return 'articleListByTopic';
|
|
|
return `article${thumb ? 'Thumb' : ''}ListByTopic`;
|
|
|
} else if (type === 'userArticle') {
|
|
|
return 'articleUserList';
|
|
|
return `articleUser${thumb ? 'Thumb' : ''}List`;
|
|
|
}
|
|
|
return '';
|
|
|
}
|
...
|
...
|
@@ -25,7 +25,7 @@ function updateArticleState(state, item) { |
|
|
});
|
|
|
}
|
|
|
|
|
|
function setArticleList(state, data, type) {
|
|
|
function setArticleList(state, data, type, thumb) {
|
|
|
data.forEach((item, index) => {
|
|
|
get(item, 'productList', []).forEach(product => {
|
|
|
product.favorite = false;
|
...
|
...
|
@@ -34,11 +34,22 @@ function setArticleList(state, data, type) { |
|
|
item.lazy = index >= 1;
|
|
|
item.isExpand = false;
|
|
|
item.introHeight = 0;
|
|
|
updateArticleState(state, item);
|
|
|
item.introCollapseHeight = 0;
|
|
|
if (!thumb) {
|
|
|
updateArticleState(state, item);
|
|
|
} else {
|
|
|
item.comments = [];
|
|
|
item.hasAttention = 'N';
|
|
|
item.hasFavor = 'N';
|
|
|
item.hasPraise = 'N';
|
|
|
item.commentCount = 0;
|
|
|
item.favoriteCount = 0;
|
|
|
item.praiseCount = 0;
|
|
|
}
|
|
|
});
|
|
|
state[articlefield(type)] = state[articlefield(type)].concat(data);
|
|
|
state[articlefield(type, thumb)] = state[articlefield(type, thumb)].concat(data);
|
|
|
|
|
|
state[articlefield(type)].forEach((item, index) => {
|
|
|
state[articlefield(type, thumb)].forEach((item, index) => {
|
|
|
const imageBlocks = get(item, 'blockList', []).filter(block => block.templateKey === 'image');
|
|
|
|
|
|
imageBlocks.forEach((img, inx) => {
|
...
|
...
|
@@ -62,9 +73,9 @@ export default { |
|
|
state.articleList = [];
|
|
|
}
|
|
|
},
|
|
|
[Types.FETCH_ARTICLE_LIST_SUCCESS](state, {data}) {
|
|
|
[Types.FETCH_ARTICLE_LIST_SUCCESS](state, {data, thumb}) {
|
|
|
state.fetchArticleList = false;
|
|
|
setArticleList(state, data, 'article');
|
|
|
setArticleList(state, data, 'article', thumb);
|
|
|
},
|
|
|
[Types.FETCH_ARTICLE_LIST_FAILD](state) {
|
|
|
state.fetchArticleList = false;
|
...
|
...
|
@@ -75,9 +86,9 @@ export default { |
|
|
state.articleUserList = [];
|
|
|
}
|
|
|
},
|
|
|
[Types.FETCH_ARTICLE_LIST_USER_SUCCESS](state, {data}) {
|
|
|
[Types.FETCH_ARTICLE_LIST_USER_SUCCESS](state, {data, thumb}) {
|
|
|
state.fetchArticleUserList = false;
|
|
|
setArticleList(state, data, 'userArticle');
|
|
|
setArticleList(state, data, 'userArticle', thumb);
|
|
|
},
|
|
|
[Types.FETCH_ARTICLE_LIST_USER_FAILD](state) {
|
|
|
state.fetchArticleUserList = false;
|
...
|
...
|
@@ -159,11 +170,12 @@ export default { |
|
|
find.isExpand = isExpand;
|
|
|
}
|
|
|
},
|
|
|
[Types.CHANGE_ARTICLE_LIST_INTRO_HEIGHT](state, {articleId, introHeight, type}) {
|
|
|
[Types.CHANGE_ARTICLE_LIST_INTRO_HEIGHT](state, {articleId, introHeight, introCollapseHeight, type}) {
|
|
|
const find = state[articlefield(type)].find(article => article.articleId === articleId);
|
|
|
|
|
|
if (find) {
|
|
|
find.introHeight = introHeight || find.introHeight;
|
|
|
find.introCollapseHeight = introCollapseHeight || find.introCollapseHeight;
|
|
|
}
|
|
|
}
|
|
|
}; |
...
|
...
|
|