Merge branch 'master' of http://git.yoho.cn/fe/yoho-community-web
Showing
13 changed files
with
158 additions
and
63 deletions
@@ -18,7 +18,7 @@ export default { | @@ -18,7 +18,7 @@ export default { | ||
18 | this.$emit('click', {uid: user.uid}); | 18 | this.$emit('click', {uid: user.uid}); |
19 | } else { | 19 | } else { |
20 | this.$emit('cancel'); | 20 | this.$emit('cancel'); |
21 | - this.$sdk.goLogin(); | 21 | + this.$yoho.goLogin(); |
22 | } | 22 | } |
23 | } | 23 | } |
24 | }, | 24 | }, |
@@ -193,26 +193,29 @@ export default { | @@ -193,26 +193,29 @@ export default { | ||
193 | 193 | ||
194 | if (this.viewOption.canSelect) { | 194 | if (this.viewOption.canSelect) { |
195 | this.changeBtnStatus(); | 195 | this.changeBtnStatus(); |
196 | - const backFn = (res) => { | ||
197 | - this.syncing = false; | ||
198 | - | ||
199 | - if (res.code !== 200) { | ||
200 | - this.changeBtnStatus(); | ||
201 | - this.$createToast && this.$createToast({ | ||
202 | - txt: res.message || '服务器开小差了', | ||
203 | - type: 'warn', | ||
204 | - time: 1000 | ||
205 | - }).show(); | ||
206 | - } | ||
207 | - }; | ||
208 | - | ||
209 | - this.syncing = true; | ||
210 | - | ||
211 | - this.syncService(this.syncFnName, { | ||
212 | - articleId: this.articleId, | ||
213 | - commentId: this.commentId, | ||
214 | - status: this.btnSelected | ||
215 | - }).then(backFn).catch(backFn); | 196 | + |
197 | + if (this.syncFnName) { | ||
198 | + const backFn = (res) => { | ||
199 | + this.syncing = false; | ||
200 | + | ||
201 | + if (res.code !== 200) { | ||
202 | + this.changeBtnStatus(); | ||
203 | + this.$createToast && this.$createToast({ | ||
204 | + txt: res.message || '服务器开小差了', | ||
205 | + type: 'warn', | ||
206 | + time: 1000 | ||
207 | + }).show(); | ||
208 | + } | ||
209 | + }; | ||
210 | + | ||
211 | + this.syncing = true; | ||
212 | + | ||
213 | + this.syncService(this.syncFnName, { | ||
214 | + articleId: this.articleId, | ||
215 | + commentId: this.commentId, | ||
216 | + status: this.btnSelected | ||
217 | + }).then(backFn).catch(backFn); | ||
218 | + } | ||
216 | } | 219 | } |
217 | 220 | ||
218 | this.viewOption.emitName && this.$emit(this.viewOption.emitName, evt); | 221 | this.viewOption.emitName && this.$emit(this.viewOption.emitName, evt); |
1 | <template> | 1 | <template> |
2 | - <Article ref="article" :on-fetch="onFetch" @on-follow="onFollow" @on-slide="onSlide" @on-scroll-change="onScrollChange"></Article> | 2 | + <Article |
3 | + ref="article" | ||
4 | + :on-fetch="onFetch" | ||
5 | + @on-follow="onFollow" | ||
6 | + @on-slide="onSlide" | ||
7 | + @on-comment="onComment" | ||
8 | + @on-scroll-change="onScrollChange"> | ||
9 | + </Article> | ||
3 | </template> | 10 | </template> |
4 | 11 | ||
5 | <script> | 12 | <script> |
@@ -46,7 +53,7 @@ export default { | @@ -46,7 +53,7 @@ export default { | ||
46 | }, | 53 | }, |
47 | methods: { | 54 | methods: { |
48 | ...mapMutations(['CHANGE_AUTHOR_FOLLOW', 'CHANGE_ARTICLE_LIST_SLIDE', 'CHANGE_ARTICLE_LIST_SCROLL']), | 55 | ...mapMutations(['CHANGE_AUTHOR_FOLLOW', 'CHANGE_ARTICLE_LIST_SLIDE', 'CHANGE_ARTICLE_LIST_SCROLL']), |
49 | - ...mapActions(['fetchArticleList', 'fetchArticleProductFavs']), | 56 | + ...mapActions(['fetchArticleList', 'fetchArticleProductFavs', 'fetchArticleListUpdate']), |
50 | init() { | 57 | init() { |
51 | this.page = 1; | 58 | this.page = 1; |
52 | this.$refs.article.init(); | 59 | this.$refs.article.init(); |
@@ -90,6 +97,12 @@ export default { | @@ -90,6 +97,12 @@ export default { | ||
90 | }, | 97 | }, |
91 | onScrollChange({articleId}) { | 98 | onScrollChange({articleId}) { |
92 | this.CHANGE_ARTICLE_LIST_SCROLL({articleId}); | 99 | this.CHANGE_ARTICLE_LIST_SCROLL({articleId}); |
100 | + }, | ||
101 | + async onComment({articleId}) { | ||
102 | + await this.fetchArticleListUpdate({ | ||
103 | + articleId, | ||
104 | + }); | ||
105 | + this.$refs.article.resize(); | ||
93 | } | 106 | } |
94 | }, | 107 | }, |
95 | components: { | 108 | components: { |
@@ -17,12 +17,13 @@ | @@ -17,12 +17,13 @@ | ||
17 | class="comment-input hover-opacity" | 17 | class="comment-input hover-opacity" |
18 | :dest-id="data.articleId" | 18 | :dest-id="data.articleId" |
19 | :add-type="0" | 19 | :add-type="0" |
20 | - :column-type="1001"> | 20 | + :column-type="1001" |
21 | + @on-comment="onComment"> | ||
21 | 添加回复:赞美是一种美德 | 22 | 添加回复:赞美是一种美德 |
22 | </CommentPlaceholder> | 23 | </CommentPlaceholder> |
23 | </div> | 24 | </div> |
24 | <div class="total-comment"> | 25 | <div class="total-comment"> |
25 | - <div class="total hover-opacity" @click="onGoComment">查看{{data.commentCount}}条评论</div> | 26 | + <div class="total hover-opacity" @click="onShowComment">查看{{data.commentCount}}条评论</div> |
26 | <div class="last-time">{{data.date}}</div> | 27 | <div class="last-time">{{data.date}}</div> |
27 | </div> | 28 | </div> |
28 | </div> | 29 | </div> |
@@ -44,16 +45,13 @@ export default { | @@ -44,16 +45,13 @@ export default { | ||
44 | }, | 45 | }, |
45 | methods: { | 46 | methods: { |
46 | ...mapActions(['postComment']), | 47 | ...mapActions(['postComment']), |
47 | - onGoComment() { | ||
48 | - this.$emit('on-comment'); | 48 | + onShowComment() { |
49 | + if (this.data.commentCount) { | ||
50 | + this.$emit('on-show-comment'); | ||
51 | + } | ||
49 | }, | 52 | }, |
50 | onComment() { | 53 | onComment() { |
51 | - this.postComment({ | ||
52 | - content: '这还是一条测试回复', | ||
53 | - destId: this.data.articleId, | ||
54 | - addType: 0, | ||
55 | - columnType: this.columnType | ||
56 | - }); | 54 | + this.$emit('on-comment'); |
57 | } | 55 | } |
58 | }, | 56 | }, |
59 | components: {CubeInput: Input} | 57 | components: {CubeInput: Input} |
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | <div class="article-item-header"> | 2 | <div class="article-item-header"> |
3 | <router-link class="avatar" :to="`/grass/author/${data.authorType}/${data.authorUid}`"> | 3 | <router-link class="avatar" :to="`/grass/author/${data.authorType}/${data.authorUid}`"> |
4 | <WidgetAvatar :lazy="lazy" class="widget-avatar" :src="data.authorHeadIco" :width="70" :height="70"></WidgetAvatar> | 4 | <WidgetAvatar :lazy="lazy" class="widget-avatar" :src="data.authorHeadIco" :width="70" :height="70"></WidgetAvatar> |
5 | - <span class="name">{{data.authorName}}</span> | 5 | + <span class="user-name">{{data.authorName}}</span> |
6 | </router-link> | 6 | </router-link> |
7 | <div class="opts"> | 7 | <div class="opts"> |
8 | <WidgetFollow :author-uid="data.authorUid" :authorType="data.authorType" :follow="data.hasAttention === 'Y'" @on-follow="onFollow"></WidgetFollow> | 8 | <WidgetFollow :author-uid="data.authorUid" :authorType="data.authorType" :follow="data.hasAttention === 'Y'" @on-follow="onFollow"></WidgetFollow> |
@@ -62,9 +62,13 @@ export default { | @@ -62,9 +62,13 @@ export default { | ||
62 | overflow: hidden; | 62 | overflow: hidden; |
63 | background-color: #fff; | 63 | background-color: #fff; |
64 | 64 | ||
65 | - .name { | 65 | + .user-name { |
66 | font-size: 24px; | 66 | font-size: 24px; |
67 | margin-left: 20px; | 67 | margin-left: 20px; |
68 | + max-width: 250px; | ||
69 | + overflow: hidden; | ||
70 | + text-overflow: ellipsis; | ||
71 | + white-space: nowrap; | ||
68 | } | 72 | } |
69 | 73 | ||
70 | .widget-avatar { | 74 | .widget-avatar { |
@@ -2,8 +2,8 @@ | @@ -2,8 +2,8 @@ | ||
2 | <div class="article-item-intro"> | 2 | <div class="article-item-intro"> |
3 | <div ref="intro" v-if="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> | ||
6 | - <span class="expand collapse" v-if="isExpand && isEllipsis">收起</span> | 5 | + <span class="expand" v-if="showExpand">…展开</span> |
6 | + <span class="expand collapse" v-if="showCollapse">收起</span> | ||
7 | </div> | 7 | </div> |
8 | <div class="topics"> | 8 | <div class="topics"> |
9 | <WidgetTopic | 9 | <WidgetTopic |
@@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
20 | <div class="opts"> | 20 | <div class="opts"> |
21 | <WidgetFav :num="data.praiseCount" :article-id="data.articleId" :option="praiseOption"></WidgetFav> | 21 | <WidgetFav :num="data.praiseCount" :article-id="data.articleId" :option="praiseOption"></WidgetFav> |
22 | <WidgetLike :num="data.favoriteCount" :article-id="data.articleId" :option="favoriteOption"></WidgetLike> | 22 | <WidgetLike :num="data.favoriteCount" :article-id="data.articleId" :option="favoriteOption"></WidgetLike> |
23 | - <WidgetComment :num="data.commentCount" @click.native="onComment"></WidgetComment> | 23 | + <WidgetComment :num="data.commentCount" @click.native="onShowComment"></WidgetComment> |
24 | </div> | 24 | </div> |
25 | </div> | 25 | </div> |
26 | </div> | 26 | </div> |
@@ -41,19 +41,22 @@ export default { | @@ -41,19 +41,22 @@ export default { | ||
41 | }, | 41 | }, |
42 | data() { | 42 | data() { |
43 | return { | 43 | return { |
44 | - isEllipsis: true, | ||
45 | isExpand: false, | 44 | isExpand: false, |
46 | isExpanding: false, | 45 | isExpanding: false, |
47 | introCollapseHeight: 0, | 46 | introCollapseHeight: 0, |
48 | introHeight: 0 | 47 | introHeight: 0 |
49 | }; | 48 | }; |
50 | }, | 49 | }, |
51 | - created() { | ||
52 | - if (this.data.intro.length < 66) { | ||
53 | - this.isEllipsis = false; | ||
54 | - } | ||
55 | - }, | ||
56 | computed: { | 50 | computed: { |
51 | + showExpand() { | ||
52 | + return (!this.isExpand && this.isEllipsis) || this.data.articleType === 2; | ||
53 | + }, | ||
54 | + showCollapse() { | ||
55 | + return this.isExpand && this.isEllipsis; | ||
56 | + }, | ||
57 | + isEllipsis() { | ||
58 | + return this.data.intro.length >= 66; | ||
59 | + }, | ||
57 | intro() { | 60 | intro() { |
58 | if (this.isExpand || this.data.intro.length < 66) { | 61 | if (this.isExpand || this.data.intro.length < 66) { |
59 | return this.data.intro; | 62 | return this.data.intro; |
@@ -64,6 +67,7 @@ export default { | @@ -64,6 +67,7 @@ export default { | ||
64 | introClass() { | 67 | introClass() { |
65 | return { | 68 | return { |
66 | 'intro-expand': this.isExpand, | 69 | 'intro-expand': this.isExpand, |
70 | + 'no-more': !this.isEllipsis | ||
67 | }; | 71 | }; |
68 | }, | 72 | }, |
69 | introStyle() { | 73 | introStyle() { |
@@ -101,14 +105,14 @@ export default { | @@ -101,14 +105,14 @@ export default { | ||
101 | this.$yoho.share({ | 105 | this.$yoho.share({ |
102 | title: '逛资讯', | 106 | title: '逛资讯', |
103 | imgUrl: this.data.imageUrl, | 107 | imgUrl: this.data.imageUrl, |
104 | - link: `http://yoho-community-web.test3.ingress.dev.yohocorp.com/article/${this.data.articleId}`, | 108 | + link: `http://yoho-community-web.test3.ingress.dev.yohocorp.com/article/${this.data.articleId}?isShare=1`, |
105 | desc: this.data.intro, | 109 | desc: this.data.intro, |
110 | + hideType: ['7', '8', '9'] | ||
106 | }); | 111 | }); |
107 | }, | 112 | }, |
108 | onExpand() { | 113 | onExpand() { |
109 | if (this.data.articleType === 2) { | 114 | if (this.data.articleType === 2) { |
110 | - this.$emit('on-expand'); | ||
111 | - return; | 115 | + return this.$emit('on-expand'); |
112 | } | 116 | } |
113 | if (!this.isEllipsis) { | 117 | if (!this.isEllipsis) { |
114 | return; | 118 | return; |
@@ -128,8 +132,10 @@ export default { | @@ -128,8 +132,10 @@ export default { | ||
128 | resizeScroll() { | 132 | resizeScroll() { |
129 | this.$emit('on-resize'); | 133 | this.$emit('on-resize'); |
130 | }, | 134 | }, |
131 | - onComment() { | ||
132 | - this.$emit('on-comment'); | 135 | + onShowComment() { |
136 | + if (this.data.commentCount) { | ||
137 | + this.$emit('on-show-comment'); | ||
138 | + } | ||
133 | } | 139 | } |
134 | } | 140 | } |
135 | }; | 141 | }; |
@@ -160,6 +166,10 @@ export default { | @@ -160,6 +166,10 @@ export default { | ||
160 | padding-bottom: 40px; | 166 | padding-bottom: 40px; |
161 | // overflow-y: auto; | 167 | // overflow-y: auto; |
162 | } | 168 | } |
169 | + | ||
170 | + &.no-more { | ||
171 | + height: auto; | ||
172 | + } | ||
163 | } | 173 | } |
164 | 174 | ||
165 | .expand { | 175 | .expand { |
@@ -3,8 +3,8 @@ | @@ -3,8 +3,8 @@ | ||
3 | <ArticleItemHeader :data="headerData" :lazy="lazy" @on-follow="onFollow"></ArticleItemHeader> | 3 | <ArticleItemHeader :data="headerData" :lazy="lazy" @on-follow="onFollow"></ArticleItemHeader> |
4 | <ArticleItemSlide :data="slideData" :slide-index="data.blockIndex" :lazy="lazy" @on-slide="onSlide"></ArticleItemSlide> | 4 | <ArticleItemSlide :data="slideData" :slide-index="data.blockIndex" :lazy="lazy" @on-slide="onSlide"></ArticleItemSlide> |
5 | <ProductGroup v-if="productListData.length" :data="productListData" :lazy="lazy"></ProductGroup> | 5 | <ProductGroup v-if="productListData.length" :data="productListData" :lazy="lazy"></ProductGroup> |
6 | - <ArticleItemIntro :data="introData" @on-resize="onResize" @on-resizeing="onResizeing" @on-expand="onExpand" @on-comment="onComment"></ArticleItemIntro> | ||
7 | - <ArticleItemComment :data="commentData" @on-comment="onComment"></ArticleItemComment> | 6 | + <ArticleItemIntro :data="introData" @on-resize="onResize" @on-resizeing="onResizeing" @on-expand="onExpand" @on-show-comment="onShowComment"></ArticleItemIntro> |
7 | + <ArticleItemComment :data="commentData" @on-show-comment="onShowComment" @on-comment="onComment"></ArticleItemComment> | ||
8 | <div class="line"></div> | 8 | <div class="line"></div> |
9 | </div> | 9 | </div> |
10 | </template> | 10 | </template> |
@@ -86,11 +86,14 @@ export default { | @@ -86,11 +86,14 @@ export default { | ||
86 | onExpand() { | 86 | onExpand() { |
87 | this.$emit('on-expand', {articleId: this.data.relateId, grassId: this.data.articleId}); | 87 | this.$emit('on-expand', {articleId: this.data.relateId, grassId: this.data.articleId}); |
88 | }, | 88 | }, |
89 | - onComment() { | ||
90 | - this.$emit('on-comment', this.data); | 89 | + onShowComment() { |
90 | + this.$emit('on-show-comment', this.data); | ||
91 | }, | 91 | }, |
92 | onSlide({index}) { | 92 | onSlide({index}) { |
93 | this.$emit('on-slide', {articleId: this.data.articleId, index}); | 93 | this.$emit('on-slide', {articleId: this.data.articleId, index}); |
94 | + }, | ||
95 | + onComment() { | ||
96 | + this.$emit('on-comment', this.data); | ||
94 | } | 97 | } |
95 | }, | 98 | }, |
96 | components: {ArticleItemHeader, ArticleItemSlide, ArticleItemIntro, ArticleItemComment} | 99 | components: {ArticleItemHeader, ArticleItemSlide, ArticleItemIntro, ArticleItemComment} |
@@ -22,6 +22,7 @@ | @@ -22,6 +22,7 @@ | ||
22 | @on-resizeing="onResizeing(data)" | 22 | @on-resizeing="onResizeing(data)" |
23 | @on-follow="follow => onFollow(data, follow)" | 23 | @on-follow="follow => onFollow(data, follow)" |
24 | @on-expand="onExpand" | 24 | @on-expand="onExpand" |
25 | + @on-show-comment="onShowComment" | ||
25 | @on-comment="onComment" | 26 | @on-comment="onComment" |
26 | @on-slide="onSlide"></ArticleItem> | 27 | @on-slide="onSlide"></ArticleItem> |
27 | <div :id="`ph${data.index}`"></div> | 28 | <div :id="`ph${data.index}`"></div> |
@@ -80,7 +81,7 @@ export default { | @@ -80,7 +81,7 @@ export default { | ||
80 | } | 81 | } |
81 | }, | 82 | }, |
82 | methods: { | 83 | methods: { |
83 | - onComment({articleId}) { | 84 | + onShowComment({articleId}) { |
84 | this.articleId = articleId; | 85 | this.articleId = articleId; |
85 | this.showCommentAction = true; | 86 | this.showCommentAction = true; |
86 | this.$nextTick(() => { | 87 | this.$nextTick(() => { |
@@ -88,6 +89,9 @@ export default { | @@ -88,6 +89,9 @@ export default { | ||
88 | this.$refs.commentAction.show(); | 89 | this.$refs.commentAction.show(); |
89 | }); | 90 | }); |
90 | }, | 91 | }, |
92 | + onComment({articleId}) { | ||
93 | + this.$emit('on-comment', {articleId}); | ||
94 | + }, | ||
91 | onClose() { | 95 | onClose() { |
92 | this.$refs.commentAction.hide(); | 96 | this.$refs.commentAction.hide(); |
93 | }, | 97 | }, |
@@ -131,6 +135,9 @@ export default { | @@ -131,6 +135,9 @@ export default { | ||
131 | 135 | ||
132 | $phItem.innerHTML = ''; | 136 | $phItem.innerHTML = ''; |
133 | $phItem.status = 0; | 137 | $phItem.status = 0; |
138 | + this.resize(); | ||
139 | + }, | ||
140 | + resize() { | ||
134 | this.$refs.scroll.resize(); | 141 | this.$refs.scroll.resize(); |
135 | }, | 142 | }, |
136 | onResizeing(data) { | 143 | onResizeing(data) { |
@@ -194,5 +201,9 @@ export default { | @@ -194,5 +201,9 @@ export default { | ||
194 | margin-left: 10px; | 201 | margin-left: 10px; |
195 | font-size: 24px; | 202 | font-size: 24px; |
196 | color: #000; | 203 | color: #000; |
204 | + max-width: 250px; | ||
205 | + overflow: hidden; | ||
206 | + text-overflow: ellipsis; | ||
207 | + white-space: nowrap; | ||
197 | } | 208 | } |
198 | </style> | 209 | </style> |
1 | <template> | 1 | <template> |
2 | - <Article ref="article" :on-fetch="onFetch" @on-follow="onFollow" @on-slide="onSlide" @on-scroll-change="onScrollChange"></Article> | 2 | + <Article |
3 | + ref="article" | ||
4 | + :on-fetch="onFetch" | ||
5 | + @on-follow="onFollow" | ||
6 | + @on-slide="onSlide" | ||
7 | + @on-comment="onComment" | ||
8 | + @on-scroll-change="onScrollChange"> | ||
9 | + </Article> | ||
3 | </template> | 10 | </template> |
4 | 11 | ||
5 | <script> | 12 | <script> |
@@ -36,16 +43,10 @@ export default { | @@ -36,16 +43,10 @@ export default { | ||
36 | }, | 43 | }, |
37 | computed: { | 44 | computed: { |
38 | ...mapState(['articleListByTopic']), | 45 | ...mapState(['articleListByTopic']), |
39 | - currentList() { | ||
40 | - if (this.articleListByTopic.length > 2) { | ||
41 | - return this.articleListByTopic.slice(0, 2); | ||
42 | - } | ||
43 | - return this.articleListByTopic; | ||
44 | - } | ||
45 | }, | 46 | }, |
46 | methods: { | 47 | methods: { |
47 | ...mapMutations(['CHANGE_AUTHOR_TOPIC_FOLLOW', 'CHANGE_ARTICLE_TOPIC_SLIDE', 'CHANGE_ARTICLE_TOPIC_SCROLL']), | 48 | ...mapMutations(['CHANGE_AUTHOR_TOPIC_FOLLOW', 'CHANGE_ARTICLE_TOPIC_SLIDE', 'CHANGE_ARTICLE_TOPIC_SCROLL']), |
48 | - ...mapActions(['fetchArticleListByTopic']), | 49 | + ...mapActions(['fetchArticleListByTopic', 'fetchArticleProductFavs', 'fetchArticleTopicUpdate']), |
49 | init() { | 50 | init() { |
50 | this.page = 1; | 51 | this.page = 1; |
51 | this.$refs.article.init(); | 52 | this.$refs.article.init(); |
@@ -64,6 +65,9 @@ export default { | @@ -64,6 +65,9 @@ export default { | ||
64 | if (result.code === 200) { | 65 | if (result.code === 200) { |
65 | if (get(result, 'data.detailList', []).length) { | 66 | if (get(result, 'data.detailList', []).length) { |
66 | this.page++; | 67 | this.page++; |
68 | + this.fetchArticleProductFavs({ | ||
69 | + articles: result.data.detailList | ||
70 | + }); | ||
67 | return new Promise(resolve => { | 71 | return new Promise(resolve => { |
68 | if (this.page === 2) { | 72 | if (this.page === 2) { |
69 | setTimeout(() => { | 73 | setTimeout(() => { |
@@ -91,6 +95,12 @@ export default { | @@ -91,6 +95,12 @@ export default { | ||
91 | }, | 95 | }, |
92 | onScrollChange({articleId}) { | 96 | onScrollChange({articleId}) { |
93 | this.CHANGE_ARTICLE_TOPIC_SCROLL({articleId}); | 97 | this.CHANGE_ARTICLE_TOPIC_SCROLL({articleId}); |
98 | + }, | ||
99 | + async onComment({articleId}) { | ||
100 | + await this.fetchArticleTopicUpdate({ | ||
101 | + articleId, | ||
102 | + }); | ||
103 | + this.$refs.article.resize(); | ||
94 | } | 104 | } |
95 | }, | 105 | }, |
96 | components: { | 106 | components: { |
@@ -36,6 +36,34 @@ export default { | @@ -36,6 +36,34 @@ export default { | ||
36 | } | 36 | } |
37 | return result; | 37 | return result; |
38 | }, | 38 | }, |
39 | + async fetchArticleListUpdate({commit}, {articleId}) { | ||
40 | + const result = await this.$api.get('/api/grass/columnArticleDetail', { | ||
41 | + articleId, | ||
42 | + limit: 1, | ||
43 | + page: 1, | ||
44 | + columnType: 1001 | ||
45 | + }); | ||
46 | + | ||
47 | + const articleData = get(result, 'data.detailList[0]'); | ||
48 | + | ||
49 | + if (articleData) { | ||
50 | + commit(Types.FETCH_ARTICLE_LIST_UPDATE, {data: articleData}); | ||
51 | + } | ||
52 | + }, | ||
53 | + async fetchArticleTopicUpdate({commit}, {articleId}) { | ||
54 | + const result = await this.$api.get('/api/grass/columnArticleDetail', { | ||
55 | + articleId, | ||
56 | + limit: 1, | ||
57 | + page: 1, | ||
58 | + columnType: 1001 | ||
59 | + }); | ||
60 | + | ||
61 | + const articleData = get(result, 'data.detailList[0]'); | ||
62 | + | ||
63 | + if (articleData) { | ||
64 | + commit(Types.FETCH_ARTICLE_TOPIC_UPDATE, {data: articleData}); | ||
65 | + } | ||
66 | + }, | ||
39 | async fetchArticleProductFavs({commit}, {articles}) { | 67 | async fetchArticleProductFavs({commit}, {articles}) { |
40 | const products = [], ufoProducts = []; | 68 | const products = [], ufoProducts = []; |
41 | 69 |
@@ -94,6 +94,17 @@ export default { | @@ -94,6 +94,17 @@ export default { | ||
94 | } | 94 | } |
95 | }); | 95 | }); |
96 | }, | 96 | }, |
97 | + [Types.FETCH_ARTICLE_LIST_UPDATE](state, {data}) { | ||
98 | + const find = state.articleList.find(article => article.articleId === data.articleId); | ||
99 | + | ||
100 | + if (find) { | ||
101 | + find.commentCount = data.commentCount; | ||
102 | + find.comments = data.comments; | ||
103 | + } | ||
104 | + }, | ||
105 | + [Types.FETCH_ARTICLE_TOPIC_UPDATE](state, {data}) { | ||
106 | + | ||
107 | + }, | ||
97 | [Types.CHANGE_ARTICLE_TOPIC_SCROLL](state, {articleId}) { | 108 | [Types.CHANGE_ARTICLE_TOPIC_SCROLL](state, {articleId}) { |
98 | let inx; | 109 | let inx; |
99 | 110 |
@@ -20,4 +20,7 @@ export const CHANGE_ARTICLE_TOPIC_SCROLL = 'CHANGE_ARTICLE_TOPIC_SCROLL'; | @@ -20,4 +20,7 @@ export const CHANGE_ARTICLE_TOPIC_SCROLL = 'CHANGE_ARTICLE_TOPIC_SCROLL'; | ||
20 | 20 | ||
21 | export const FETCH_ARTICLE_TOPIC_REQUEST = 'FETCH_ARTICLE_TOPIC_REQUEST'; | 21 | export const FETCH_ARTICLE_TOPIC_REQUEST = 'FETCH_ARTICLE_TOPIC_REQUEST'; |
22 | export const FETCH_ARTICLE_TOPIC_FAILD = 'FETCH_ARTICLE_TOPIC_FAILD'; | 22 | export const FETCH_ARTICLE_TOPIC_FAILD = 'FETCH_ARTICLE_TOPIC_FAILD'; |
23 | -export const FETCH_ARTICLE_TOPIC_SUCCESS = 'FETCH_ARTICLE_TOPIC_SUCCESS'; | ||
23 | +export const FETCH_ARTICLE_TOPIC_SUCCESS = 'FETCH_ARTICLE_TOPIC_SUCCESS'; | ||
24 | + | ||
25 | +export const FETCH_ARTICLE_LIST_UPDATE = 'FETCH_ARTICLE_LIST_UPDATE'; | ||
26 | +export const FETCH_ARTICLE_TOPIC_UPDATE = 'FETCH_ARTICLE_TOPIC_UPDATE'; |
-
Please register or login to post a comment