|
@@ -2,11 +2,37 @@ import * as Types from './types'; |
|
@@ -2,11 +2,37 @@ import * as Types from './types'; |
2
|
|
2
|
|
3
|
export default {
|
3
|
export default {
|
4
|
async getDetail({ commit }, { article_id }) {
|
4
|
async getDetail({ commit }, { article_id }) {
|
5
|
- const result = await this.$api.get('/api/guang/article/detail', {
|
5
|
+ let result = {
|
|
|
6
|
+ getAuthor: {},
|
|
|
7
|
+ getArticle: {},
|
|
|
8
|
+ getArticleContent: {},
|
|
|
9
|
+ };
|
|
|
10
|
+
|
|
|
11
|
+ const data = await this.$api.get('/api/guang/article/detail', {
|
6
|
article_id
|
12
|
article_id
|
7
|
});
|
13
|
});
|
8
|
|
14
|
|
9
|
- console.log(result);
|
15
|
+ if (!data || data.code !== 200) {
|
|
|
16
|
+ result.code = 400;
|
|
|
17
|
+ return result;
|
|
|
18
|
+ }
|
|
|
19
|
+
|
|
|
20
|
+ let article = result.getArticle = data && data.data || {};
|
|
|
21
|
+
|
|
|
22
|
+ let promises = [
|
|
|
23
|
+ this.$api.get('/api/guang/article/author', { author_id: article.author_id }),
|
|
|
24
|
+ this.$api.get('/api/guang/article/content', { article_id })
|
|
|
25
|
+ ];
|
|
|
26
|
+
|
|
|
27
|
+ const [author, content] = await Promise.all(promises);
|
|
|
28
|
+
|
|
|
29
|
+ if (!author) {
|
|
|
30
|
+ result.getAuthor = author;
|
|
|
31
|
+ }
|
|
|
32
|
+
|
|
|
33
|
+ if (!content) {
|
|
|
34
|
+ result.getArticleContent = content;
|
|
|
35
|
+ }
|
10
|
|
36
|
|
11
|
commit(Types.FETCH_GUANG_SUCCESS, result);
|
37
|
commit(Types.FETCH_GUANG_SUCCESS, result);
|
12
|
}
|
38
|
}
|