Authored by htoooth

add article detail

@@ -31,7 +31,7 @@ export default { @@ -31,7 +31,7 @@ export default {
31 articleId: { 31 articleId: {
32 type: [Number, String], 32 type: [Number, String],
33 default() { 33 default() {
34 - return 68671; 34 + return 87723;
35 } 35 }
36 } 36 }
37 }, 37 },
@@ -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 }
@@ -117,13 +117,5 @@ module.exports = { @@ -117,13 +117,5 @@ module.exports = {
117 params: { 117 params: {
118 article_id: {type: String} 118 article_id: {type: String}
119 } 119 }
120 - },  
121 - '/api/guang/article/brand': {  
122 - service: true,  
123 - api: URI_PACKAGE_ARTICLE,  
124 - path: 'getBrand',  
125 - params: {  
126 - article_id: {type: String}  
127 - }  
128 } 120 }
129 }; 121 };