Showing
10 changed files
with
77 additions
and
26 deletions
@@ -158,13 +158,14 @@ export default { | @@ -158,13 +158,14 @@ export default { | ||
158 | getItems(reload) { | 158 | getItems(reload) { |
159 | this.loadings.push('pending'); | 159 | this.loadings.push('pending'); |
160 | this.onFetch().then((res) => { | 160 | this.onFetch().then((res) => { |
161 | + if (reload) { | ||
162 | + this.list = []; | ||
163 | + this.items = []; | ||
164 | + } | ||
161 | /* istanbul ignore if */ | 165 | /* istanbul ignore if */ |
162 | if (!res) { | 166 | if (!res) { |
163 | this.noMore = true; | 167 | this.noMore = true; |
164 | this.loadings.pop(); | 168 | this.loadings.pop(); |
165 | - } else if (reload) { | ||
166 | - this.list = res; | ||
167 | - this.items = []; | ||
168 | } else { | 169 | } else { |
169 | this.list = this.list.concat(res); | 170 | this.list = this.list.concat(res); |
170 | } | 171 | } |
@@ -14,18 +14,26 @@ export default { | @@ -14,18 +14,26 @@ export default { | ||
14 | data() { | 14 | data() { |
15 | return { | 15 | return { |
16 | page: 1, | 16 | page: 1, |
17 | - id: 0 | 17 | + id: 0, |
18 | + authorUid: 0, | ||
19 | + authorType: 0, | ||
20 | + type: '' | ||
18 | }; | 21 | }; |
19 | }, | 22 | }, |
20 | created() { | 23 | created() { |
21 | this.id = this.$route.params.id; | 24 | this.id = this.$route.params.id; |
25 | + this.authorUid = this.$route.query.authorUid; | ||
26 | + this.authorType = this.$route.query.authorType; | ||
27 | + this.type = this.$route.query.type; | ||
22 | }, | 28 | }, |
23 | - beforeRouteUpdate(to, from, next) { | ||
24 | - if (this.$route.params.id !== to.params.id) { | ||
25 | - this.id = to.params.id; | 29 | + activated() { |
30 | + if (this.$route.params.id !== this.id) { | ||
31 | + this.id = this.$route.params.id; | ||
32 | + this.authorUid = this.$route.query.authorUid; | ||
33 | + this.authorType = this.$route.query.authorType; | ||
34 | + this.type = this.$route.query.type; | ||
26 | this.init(); | 35 | this.init(); |
27 | } | 36 | } |
28 | - next(); | ||
29 | }, | 37 | }, |
30 | computed: { | 38 | computed: { |
31 | ...mapState(['articleList']), | 39 | ...mapState(['articleList']), |
@@ -51,7 +59,10 @@ export default { | @@ -51,7 +59,10 @@ export default { | ||
51 | } | 59 | } |
52 | const result = await this.fetchArticleList({ | 60 | const result = await this.fetchArticleList({ |
53 | articleId, | 61 | articleId, |
54 | - page: this.page | 62 | + page: this.page, |
63 | + authorUid: this.authorUid, | ||
64 | + authorType: this.authorType, | ||
65 | + type: this.type | ||
55 | }); | 66 | }); |
56 | 67 | ||
57 | if (result.code === 200) { | 68 | if (result.code === 200) { |
1 | <template> | 1 | <template> |
2 | <div class="article-item-intro"> | 2 | <div class="article-item-intro"> |
3 | - <div ref="intro" class="intro hover-opacity" :class="introClass" :style="introStyle" @click="onExpand"> | 3 | + <div ref="intro" v-if="intro" class="intro hover-opacity" :class="introClass" :style="introStyle" @click="onExpand"> |
4 | {{intro}} | 4 | {{intro}} |
5 | <span class="expand" v-if="!isExpand && isEllipsis">…展开</span> | 5 | <span class="expand" v-if="!isExpand && isEllipsis">…展开</span> |
6 | <span class="expand collapse" v-if="isExpand && isEllipsis">收起</span> | 6 | <span class="expand collapse" v-if="isExpand && isEllipsis">收起</span> |
@@ -9,6 +9,9 @@ export default [{ | @@ -9,6 +9,9 @@ export default [{ | ||
9 | path: '/topic/:labelId', | 9 | path: '/topic/:labelId', |
10 | name: 'topic', | 10 | name: 'topic', |
11 | component: () => import(/* webpackChunkName: "article" */ './topic'), | 11 | component: () => import(/* webpackChunkName: "article" */ './topic'), |
12 | + meta: { | ||
13 | + keepAlive: true | ||
14 | + } | ||
12 | }, { | 15 | }, { |
13 | path: '/article/:articleId/comment', | 16 | path: '/article/:articleId/comment', |
14 | name: 'article.comment', | 17 | name: 'article.comment', |
@@ -23,7 +23,6 @@ export default { | @@ -23,7 +23,6 @@ export default { | ||
23 | }, | 23 | }, |
24 | activated() { | 24 | activated() { |
25 | if (this.$route.params.labelId !== this.labelId) { | 25 | if (this.$route.params.labelId !== this.labelId) { |
26 | - console.log('activated init'); | ||
27 | this.labelId = this.$route.params.labelId; | 26 | this.labelId = this.$route.params.labelId; |
28 | this.init(); | 27 | this.init(); |
29 | } | 28 | } |
@@ -3,12 +3,23 @@ import { get } from 'lodash'; | @@ -3,12 +3,23 @@ import { get } from 'lodash'; | ||
3 | import * as guangProcess from './guangProcess'; | 3 | import * as guangProcess from './guangProcess'; |
4 | 4 | ||
5 | export default { | 5 | export default { |
6 | - async fetchArticleList({ commit }, { articleId, limit = 5, page = 1 }) { | ||
7 | - commit(Types.FETCH_ARTICLE_DETAIL_REQUEST); | ||
8 | - const result = await this.$api.get('/api/grass/columnArticleDetail', { | 6 | + async fetchArticleList({ commit }, { articleId, authorUid, authorType, type, limit = 5, page = 1 }) { |
7 | + commit(Types.FETCH_ARTICLE_LIST_REQUEST); | ||
8 | + let api; | ||
9 | + | ||
10 | + if (type === 'fav') { | ||
11 | + api = '/api/grass/userFavouriteArticleDetail'; | ||
12 | + } else if (type === 'publish') { | ||
13 | + api = '/api/grass/userPublishedArticleDetail'; | ||
14 | + } else { | ||
15 | + api = '/api/grass/columnArticleDetail'; | ||
16 | + } | ||
17 | + const result = await this.$api.get(api, { | ||
9 | articleId, | 18 | articleId, |
10 | limit, | 19 | limit, |
11 | page, | 20 | page, |
21 | + authorUid, | ||
22 | + authorType, | ||
12 | columnType: 1001 | 23 | columnType: 1001 |
13 | }); | 24 | }); |
14 | 25 | ||
@@ -16,12 +27,12 @@ export default { | @@ -16,12 +27,12 @@ export default { | ||
16 | if (!result.data.detailList) { | 27 | if (!result.data.detailList) { |
17 | result.data.detailList = []; | 28 | result.data.detailList = []; |
18 | } | 29 | } |
19 | - commit(Types.FETCH_ARTICLE_DETAIL_SUCCESS, { | 30 | + commit(Types.FETCH_ARTICLE_LIST_SUCCESS, { |
20 | data: result.data.detailList, | 31 | data: result.data.detailList, |
21 | page | 32 | page |
22 | }); | 33 | }); |
23 | } else { | 34 | } else { |
24 | - commit(Types.FETCH_ARTICLE_DETAIL_FAILD); | 35 | + commit(Types.FETCH_ARTICLE_LIST_FAILD); |
25 | } | 36 | } |
26 | return result; | 37 | return result; |
27 | }, | 38 | }, |
@@ -3,10 +3,10 @@ import {getArticleImageSize} from 'utils/image-handler'; | @@ -3,10 +3,10 @@ import {getArticleImageSize} from 'utils/image-handler'; | ||
3 | import { get, first } from 'lodash'; | 3 | import { get, first } from 'lodash'; |
4 | 4 | ||
5 | export default { | 5 | export default { |
6 | - [Types.FETCH_ARTICLE_DETAIL_REQUEST](state) { | 6 | + [Types.FETCH_ARTICLE_LIST_REQUEST](state) { |
7 | state.fetchArticleList = true; | 7 | state.fetchArticleList = true; |
8 | }, | 8 | }, |
9 | - [Types.FETCH_ARTICLE_DETAIL_SUCCESS](state, {data, page}) { | 9 | + [Types.FETCH_ARTICLE_LIST_SUCCESS](state, {data, page}) { |
10 | state.fetchArticleList = false; | 10 | state.fetchArticleList = false; |
11 | if (page === 1) { | 11 | if (page === 1) { |
12 | state.articleList = []; | 12 | state.articleList = []; |
@@ -31,7 +31,7 @@ export default { | @@ -31,7 +31,7 @@ export default { | ||
31 | }); | 31 | }); |
32 | }); | 32 | }); |
33 | }, | 33 | }, |
34 | - [Types.FETCH_ARTICLE_DETAIL_FAILD](state) { | 34 | + [Types.FETCH_ARTICLE_LIST_FAILD](state) { |
35 | state.fetchArticleList = false; | 35 | state.fetchArticleList = false; |
36 | }, | 36 | }, |
37 | [Types.FETCH_ARTICLE_PRODUCT_SUCCESS](state, {articles, favs, articleProductType}) { | 37 | [Types.FETCH_ARTICLE_PRODUCT_SUCCESS](state, {articles, favs, articleProductType}) { |
1 | -export const FETCH_ARTICLE_DETAIL_REQUEST = 'FETCH_ARTICLE_DETAIL_REQUEST'; | ||
2 | -export const FETCH_ARTICLE_DETAIL_FAILD = 'FETCH_ARTICLE_DETAIL_FAILD'; | ||
3 | -export const FETCH_ARTICLE_DETAIL_SUCCESS = 'FETCH_ARTICLE_DETAIL_SUCCESS'; | 1 | +export const FETCH_ARTICLE_LIST_REQUEST = 'FETCH_ARTICLE_LIST_REQUEST'; |
2 | +export const FETCH_ARTICLE_LIST_FAILD = 'FETCH_ARTICLE_LIST_FAILD'; | ||
3 | +export const FETCH_ARTICLE_LIST_SUCCESS = 'FETCH_ARTICLE_LIST_SUCCESS'; | ||
4 | + | ||
5 | +export const FETCH_ARTICLE_MINE_LIST_REQUEST = 'FETCH_ARTICLE_MINE_LIST_REQUEST'; | ||
6 | +export const FETCH_ARTICLE_MINE_LIST_FAILD = 'FETCH_ARTICLE_MINE_LIST_FAILD'; | ||
7 | +export const FETCH_ARTICLE_MINE_LIST_SUCCESS = 'FETCH_ARTICLE_MINE_LIST_SUCCESS'; | ||
4 | 8 | ||
5 | export const FETCH_ARTICLE_PRODUCT_SUCCESS = 'FETCH_ARTICLE_PRODUCT_SUCCESS'; | 9 | export const FETCH_ARTICLE_PRODUCT_SUCCESS = 'FETCH_ARTICLE_PRODUCT_SUCCESS'; |
6 | 10 |
1 | -export const FETCH_ARTICLE_DETAIL_REQUEST = 'FETCH_ARTICLE_DETAIL_REQUEST'; | ||
2 | -export const FETCH_ARTICLE_DETAIL_FAILD = 'FETCH_ARTICLE_DETAIL_FAILD'; | ||
3 | -export const FETCH_ARTICLE_DETAIL_SUCCESS = 'FETCH_ARTICLE_DETAIL_SUCCESS'; | ||
1 | +export const FETCH_ARTICLE_LIST_REQUEST = 'FETCH_ARTICLE_LIST_REQUEST'; | ||
2 | +export const FETCH_ARTICLE_LIST_FAILD = 'FETCH_ARTICLE_LIST_FAILD'; | ||
3 | +export const FETCH_ARTICLE_LIST_SUCCESS = 'FETCH_ARTICLE_LIST_SUCCESS'; |
@@ -194,5 +194,27 @@ module.exports = { | @@ -194,5 +194,27 @@ module.exports = { | ||
194 | params: { | 194 | params: { |
195 | productIds: {type: String}, | 195 | productIds: {type: String}, |
196 | } | 196 | } |
197 | - } | 197 | + }, |
198 | + '/api/grass/userPublishedArticleDetail': { | ||
199 | + api: 'app.grass.userPublishedArticleDetail', | ||
200 | + auth: true, | ||
201 | + params: { | ||
202 | + page: {type: Number, require: false}, | ||
203 | + limit: {type: Number, require: false}, | ||
204 | + articleId: {type: Number}, | ||
205 | + authorUid: {type: Number}, | ||
206 | + authorType: {type: Number}, | ||
207 | + } | ||
208 | + }, | ||
209 | + '/api/grass/userFavouriteArticleDetail': { | ||
210 | + api: 'app.grass.userFavouriteArticleDetail', | ||
211 | + auth: true, | ||
212 | + params: { | ||
213 | + page: {type: Number, require: false}, | ||
214 | + limit: {type: Number, require: false}, | ||
215 | + articleId: {type: Number}, | ||
216 | + authorUid: {type: Number}, | ||
217 | + authorType: {type: Number}, | ||
218 | + } | ||
219 | + }, | ||
198 | }; | 220 | }; |
-
Please register or login to post a comment