Authored by 陈峰

commit

... ... @@ -158,13 +158,14 @@ export default {
getItems(reload) {
this.loadings.push('pending');
this.onFetch().then((res) => {
if (reload) {
this.list = [];
this.items = [];
}
/* istanbul ignore if */
if (!res) {
this.noMore = true;
this.loadings.pop();
} else if (reload) {
this.list = res;
this.items = [];
} else {
this.list = this.list.concat(res);
}
... ...
... ... @@ -14,18 +14,26 @@ export default {
data() {
return {
page: 1,
id: 0
id: 0,
authorUid: 0,
authorType: 0,
type: ''
};
},
created() {
this.id = this.$route.params.id;
this.authorUid = this.$route.query.authorUid;
this.authorType = this.$route.query.authorType;
this.type = this.$route.query.type;
},
beforeRouteUpdate(to, from, next) {
if (this.$route.params.id !== to.params.id) {
this.id = to.params.id;
activated() {
if (this.$route.params.id !== this.id) {
this.id = this.$route.params.id;
this.authorUid = this.$route.query.authorUid;
this.authorType = this.$route.query.authorType;
this.type = this.$route.query.type;
this.init();
}
next();
},
computed: {
...mapState(['articleList']),
... ... @@ -51,7 +59,10 @@ export default {
}
const result = await this.fetchArticleList({
articleId,
page: this.page
page: this.page,
authorUid: this.authorUid,
authorType: this.authorType,
type: this.type
});
if (result.code === 200) {
... ...
<template>
<div class="article-item-intro">
<div ref="intro" class="intro hover-opacity" :class="introClass" :style="introStyle" @click="onExpand">
<div ref="intro" v-if="intro" class="intro hover-opacity" :class="introClass" :style="introStyle" @click="onExpand">
{{intro}}
<span class="expand" v-if="!isExpand && isEllipsis">…展开</span>
<span class="expand collapse" v-if="isExpand && isEllipsis">收起</span>
... ...
... ... @@ -9,6 +9,9 @@ export default [{
path: '/topic/:labelId',
name: 'topic',
component: () => import(/* webpackChunkName: "article" */ './topic'),
meta: {
keepAlive: true
}
}, {
path: '/article/:articleId/comment',
name: 'article.comment',
... ...
... ... @@ -23,7 +23,6 @@ export default {
},
activated() {
if (this.$route.params.labelId !== this.labelId) {
console.log('activated init');
this.labelId = this.$route.params.labelId;
this.init();
}
... ...
... ... @@ -3,12 +3,23 @@ import { get } from 'lodash';
import * as guangProcess from './guangProcess';
export default {
async fetchArticleList({ commit }, { articleId, limit = 5, page = 1 }) {
commit(Types.FETCH_ARTICLE_DETAIL_REQUEST);
const result = await this.$api.get('/api/grass/columnArticleDetail', {
async fetchArticleList({ commit }, { articleId, authorUid, authorType, type, limit = 5, page = 1 }) {
commit(Types.FETCH_ARTICLE_LIST_REQUEST);
let api;
if (type === 'fav') {
api = '/api/grass/userFavouriteArticleDetail';
} else if (type === 'publish') {
api = '/api/grass/userPublishedArticleDetail';
} else {
api = '/api/grass/columnArticleDetail';
}
const result = await this.$api.get(api, {
articleId,
limit,
page,
authorUid,
authorType,
columnType: 1001
});
... ... @@ -16,12 +27,12 @@ export default {
if (!result.data.detailList) {
result.data.detailList = [];
}
commit(Types.FETCH_ARTICLE_DETAIL_SUCCESS, {
commit(Types.FETCH_ARTICLE_LIST_SUCCESS, {
data: result.data.detailList,
page
});
} else {
commit(Types.FETCH_ARTICLE_DETAIL_FAILD);
commit(Types.FETCH_ARTICLE_LIST_FAILD);
}
return result;
},
... ...
... ... @@ -3,10 +3,10 @@ import {getArticleImageSize} from 'utils/image-handler';
import { get, first } from 'lodash';
export default {
[Types.FETCH_ARTICLE_DETAIL_REQUEST](state) {
[Types.FETCH_ARTICLE_LIST_REQUEST](state) {
state.fetchArticleList = true;
},
[Types.FETCH_ARTICLE_DETAIL_SUCCESS](state, {data, page}) {
[Types.FETCH_ARTICLE_LIST_SUCCESS](state, {data, page}) {
state.fetchArticleList = false;
if (page === 1) {
state.articleList = [];
... ... @@ -31,7 +31,7 @@ export default {
});
});
},
[Types.FETCH_ARTICLE_DETAIL_FAILD](state) {
[Types.FETCH_ARTICLE_LIST_FAILD](state) {
state.fetchArticleList = false;
},
[Types.FETCH_ARTICLE_PRODUCT_SUCCESS](state, {articles, favs, articleProductType}) {
... ...
export const FETCH_ARTICLE_DETAIL_REQUEST = 'FETCH_ARTICLE_DETAIL_REQUEST';
export const FETCH_ARTICLE_DETAIL_FAILD = 'FETCH_ARTICLE_DETAIL_FAILD';
export const FETCH_ARTICLE_DETAIL_SUCCESS = 'FETCH_ARTICLE_DETAIL_SUCCESS';
export const FETCH_ARTICLE_LIST_REQUEST = 'FETCH_ARTICLE_LIST_REQUEST';
export const FETCH_ARTICLE_LIST_FAILD = 'FETCH_ARTICLE_LIST_FAILD';
export const FETCH_ARTICLE_LIST_SUCCESS = 'FETCH_ARTICLE_LIST_SUCCESS';
export const FETCH_ARTICLE_MINE_LIST_REQUEST = 'FETCH_ARTICLE_MINE_LIST_REQUEST';
export const FETCH_ARTICLE_MINE_LIST_FAILD = 'FETCH_ARTICLE_MINE_LIST_FAILD';
export const FETCH_ARTICLE_MINE_LIST_SUCCESS = 'FETCH_ARTICLE_MINE_LIST_SUCCESS';
export const FETCH_ARTICLE_PRODUCT_SUCCESS = 'FETCH_ARTICLE_PRODUCT_SUCCESS';
... ...
export const FETCH_ARTICLE_DETAIL_REQUEST = 'FETCH_ARTICLE_DETAIL_REQUEST';
export const FETCH_ARTICLE_DETAIL_FAILD = 'FETCH_ARTICLE_DETAIL_FAILD';
export const FETCH_ARTICLE_DETAIL_SUCCESS = 'FETCH_ARTICLE_DETAIL_SUCCESS';
\ No newline at end of file
export const FETCH_ARTICLE_LIST_REQUEST = 'FETCH_ARTICLE_LIST_REQUEST';
export const FETCH_ARTICLE_LIST_FAILD = 'FETCH_ARTICLE_LIST_FAILD';
export const FETCH_ARTICLE_LIST_SUCCESS = 'FETCH_ARTICLE_LIST_SUCCESS';
\ No newline at end of file
... ...
... ... @@ -194,5 +194,27 @@ module.exports = {
params: {
productIds: {type: String},
}
}
},
'/api/grass/userPublishedArticleDetail': {
api: 'app.grass.userPublishedArticleDetail',
auth: true,
params: {
page: {type: Number, require: false},
limit: {type: Number, require: false},
articleId: {type: Number},
authorUid: {type: Number},
authorType: {type: Number},
}
},
'/api/grass/userFavouriteArticleDetail': {
api: 'app.grass.userFavouriteArticleDetail',
auth: true,
params: {
page: {type: Number, require: false},
limit: {type: Number, require: false},
articleId: {type: Number},
authorUid: {type: Number},
authorType: {type: Number},
}
},
};
... ...