Merge branch 'feature/guang' of http://git.yoho.cn/fe/yohobuy-node into feature/guang
Showing
14 changed files
with
248 additions
and
100 deletions
@@ -99,6 +99,7 @@ exports.tags = (req, res, next) => { | @@ -99,6 +99,7 @@ exports.tags = (req, res, next) => { | ||
99 | 99 | ||
100 | tag: query, | 100 | tag: query, |
101 | guangIndexPage: true, | 101 | guangIndexPage: true, |
102 | + baseUrl: `?${querystring.stringify(req.query)}`, | ||
102 | pageSize: pageSize, | 103 | pageSize: pageSize, |
103 | type: type, | 104 | type: type, |
104 | pathNav: pathNav, | 105 | pathNav: pathNav, |
@@ -140,18 +141,14 @@ exports.editor = (req, res, next) => { | @@ -140,18 +141,14 @@ exports.editor = (req, res, next) => { | ||
140 | res.render('editor', { | 141 | res.render('editor', { |
141 | title: ret[0].name + (res.locals.title || ''), | 142 | title: ret[0].name + (res.locals.title || ''), |
142 | guang: { | 143 | guang: { |
143 | - editor: { | ||
144 | - avatar: ret[0] && ret[0].avatar, | ||
145 | - name: ret[0] && ret[0].name, | ||
146 | - intro: ret[0] && ret[0].author_desc, | ||
147 | - info: '设计理念:时尚,线条流畅' | ||
148 | - }, | 144 | + editor: ret[0], |
149 | msgs: ret[1] && ret[1].msgs, | 145 | msgs: ret[1] && ret[1].msgs, |
150 | hotTags: ret[2], | 146 | hotTags: ret[2], |
151 | ads: ret[3], | 147 | ads: ret[3], |
152 | exRecos: ret[4], | 148 | exRecos: ret[4], |
153 | 149 | ||
154 | gender: gender, | 150 | gender: gender, |
151 | + baseUrl: `?${querystring.stringify(req.query)}`, | ||
155 | pageSize: pageSize, | 152 | pageSize: pageSize, |
156 | pathNav: pathNav, | 153 | pathNav: pathNav, |
157 | page: page, | 154 | page: page, |
@@ -171,7 +168,7 @@ exports.detail = (req, res, next) => { | @@ -171,7 +168,7 @@ exports.detail = (req, res, next) => { | ||
171 | 168 | ||
172 | let id = req.params.id || req.query.id; | 169 | let id = req.params.id || req.query.id; |
173 | let page = req.query.page || 1; | 170 | let page = req.query.page || 1; |
174 | - let pageSize = req.query.pageSize || 20; | 171 | + let pageSize = req.query.pageSize || 10; |
175 | let col = req.query.col || 0; | 172 | let col = req.query.col || 0; |
176 | let pjax = req.query._pjax; | 173 | let pjax = req.query._pjax; |
177 | let uid = req.user.uid; | 174 | let uid = req.user.uid; |
@@ -184,9 +181,20 @@ exports.detail = (req, res, next) => { | @@ -184,9 +181,20 @@ exports.detail = (req, res, next) => { | ||
184 | } | 181 | } |
185 | 182 | ||
186 | if (pjax) { | 183 | if (pjax) { |
187 | - return guangModel.getArticleComments(id, page, pageSize).then(ret => { | ||
188 | - return res.render('comment', ret); | 184 | + guangModel.getArticleComments(id, page, pageSize).then(ret => { |
185 | + | ||
186 | + res.render('detail-comment', { | ||
187 | + layout: false, | ||
188 | + comment: ret | ||
189 | + }, function(err, html) { | ||
190 | + if (err) { | ||
191 | + return res.send(''); | ||
192 | + } | ||
193 | + return res.status(200).send(html); | ||
194 | + }); | ||
189 | }); | 195 | }); |
196 | + | ||
197 | + return; | ||
190 | } | 198 | } |
191 | 199 | ||
192 | // 登陆后自动收藏 | 200 | // 登陆后自动收藏 |
@@ -276,8 +284,26 @@ exports.detail = (req, res, next) => { | @@ -276,8 +284,26 @@ exports.detail = (req, res, next) => { | ||
276 | exports.listDynamicData = (req, res) => { | 284 | exports.listDynamicData = (req, res) => { |
277 | let ids = req.query.ids; | 285 | let ids = req.query.ids; |
278 | 286 | ||
279 | - guangModel.getDynamicDataByIds(ids).then(ret => { | ||
280 | - res.status(200).send(ret); | 287 | + let udid = ghelper.getUdid(req, res); |
288 | + | ||
289 | + let other = {}; | ||
290 | + let query = req.query.query, | ||
291 | + type = req.query.type; | ||
292 | + | ||
293 | + if (req.user.uid) { | ||
294 | + other.uid = req.user.uid; | ||
295 | + } | ||
296 | + | ||
297 | + if (query) { | ||
298 | + other.query = query; | ||
299 | + } | ||
300 | + | ||
301 | + if (type) { | ||
302 | + other.type = type; | ||
303 | + } | ||
304 | + | ||
305 | + guangModel.getDynamicDataByIds(ids, udid, other).then(ret => { | ||
306 | + res.send(ret); | ||
281 | }); | 307 | }); |
282 | }; | 308 | }; |
283 | 309 | ||
@@ -287,23 +313,17 @@ exports.listDynamicData = (req, res) => { | @@ -287,23 +313,17 @@ exports.listDynamicData = (req, res) => { | ||
287 | * @param res | 313 | * @param res |
288 | */ | 314 | */ |
289 | exports.detailDynamicData = (req, res) => { | 315 | exports.detailDynamicData = (req, res) => { |
290 | - let id = req.query.id; | 316 | + let id = req.query.id, |
317 | + uid = req.user.uid, | ||
318 | + udid = ghelper.getUdid(req, res); | ||
291 | 319 | ||
292 | - guangModel.getDynamicDataByIds(id).then(ret => { | 320 | + guangModel.getDynamicDataById(id, uid, udid).then((ret) => { |
293 | res.status(200).send(ret); | 321 | res.status(200).send(ret); |
322 | + }).catch(() => { | ||
323 | + res.status(400); | ||
294 | }); | 324 | }); |
295 | }; | 325 | }; |
296 | 326 | ||
297 | -exports.detailCommentData = (req, res) => { | ||
298 | - | ||
299 | - let param = { | ||
300 | - id: req.query.id, | ||
301 | - page: req.query.page | ||
302 | - }; | ||
303 | - | ||
304 | - res.render('', param); | ||
305 | -}; | ||
306 | - | ||
307 | /** | 327 | /** |
308 | * 添加评论 | 328 | * 添加评论 |
309 | */ | 329 | */ |
@@ -9,7 +9,6 @@ const _ = require('lodash'); | @@ -9,7 +9,6 @@ const _ = require('lodash'); | ||
9 | const moment = require('moment'); | 9 | const moment = require('moment'); |
10 | const ghelper = require('./guang-helper'); | 10 | const ghelper = require('./guang-helper'); |
11 | 11 | ||
12 | - | ||
13 | const helpers = global.yoho.helpers; | 12 | const helpers = global.yoho.helpers; |
14 | const serviceApi = global.yoho.ServiceAPI; | 13 | const serviceApi = global.yoho.ServiceAPI; |
15 | const yohoApi = global.yoho.API; | 14 | const yohoApi = global.yoho.API; |
@@ -364,7 +363,7 @@ const getCategory = currentSortId => { | @@ -364,7 +363,7 @@ const getCategory = currentSortId => { | ||
364 | list.push({ | 363 | list.push({ |
365 | typeId: cat.id, | 364 | typeId: cat.id, |
366 | type: cat.name, | 365 | type: cat.name, |
367 | - isActive: cat.id === currentSortId, | 366 | + isActive: ('' + cat.id) === ('' + currentSortId), |
368 | navUrl: helpers.urlFormat('/index/index', {type: cat.id}, 'guang') | 367 | navUrl: helpers.urlFormat('/index/index', {type: cat.id}, 'guang') |
369 | }); | 368 | }); |
370 | } | 369 | } |
@@ -734,7 +733,7 @@ const getArticleComments = (aid, page, pageSize) => { | @@ -734,7 +733,7 @@ const getArticleComments = (aid, page, pageSize) => { | ||
734 | return serviceApi.get('guang/api/v1/comments/getList', { | 733 | return serviceApi.get('guang/api/v1/comments/getList', { |
735 | article_id: aid, | 734 | article_id: aid, |
736 | page: page, | 735 | page: page, |
737 | - pageSize: pageSize | 736 | + limit: pageSize |
738 | }).then(res => { | 737 | }).then(res => { |
739 | 738 | ||
740 | let num = (res.data && res.data.total) || 0; | 739 | let num = (res.data && res.data.total) || 0; |
@@ -757,7 +756,13 @@ const getArticleComments = (aid, page, pageSize) => { | @@ -757,7 +756,13 @@ const getArticleComments = (aid, page, pageSize) => { | ||
757 | 756 | ||
758 | return { | 757 | return { |
759 | commentNum: num, | 758 | commentNum: num, |
760 | - list: list | 759 | + pageSize: pageSize, |
760 | + page: page, | ||
761 | + list: list, | ||
762 | + baseUrl: helpers.urlFormat('/info/index', { | ||
763 | + id: aid, | ||
764 | + pageSize: pageSize | ||
765 | + }, 'guang') | ||
761 | }; | 766 | }; |
762 | }); | 767 | }); |
763 | }; | 768 | }; |
@@ -829,35 +834,46 @@ const cancelCollect = (aid, uid) => serviceApi.get('guang/api/v1/favorite/cancel | @@ -829,35 +834,46 @@ const cancelCollect = (aid, uid) => serviceApi.get('guang/api/v1/favorite/cancel | ||
829 | * @param ids | 834 | * @param ids |
830 | * @returns {Promise.<T>|*} | 835 | * @returns {Promise.<T>|*} |
831 | */ | 836 | */ |
832 | -const getDynamicDataById = id => { | ||
833 | - return serviceApi.get('', { | ||
834 | - id: id | ||
835 | - }).then(res => { | ||
836 | - | ||
837 | - if (res && res.code === 200 && res.data) { | ||
838 | - return res.data; | ||
839 | - } | ||
840 | - | ||
841 | - return Promise.reject('获取失败'); | 837 | +const getDynamicDataById = (id, uid, udid) => { |
838 | + return serviceApi.get('/gateway/guang/api/*/article/getArticlePraiseAndFavor', { | ||
839 | + id: id, | ||
840 | + uid: uid, | ||
841 | + udid: udid | ||
842 | }); | 842 | }); |
843 | }; | 843 | }; |
844 | 844 | ||
845 | /** | 845 | /** |
846 | * 获取制指定文章的动态信息 | 846 | * 获取制指定文章的动态信息 |
847 | * @param ids | 847 | * @param ids |
848 | + * @param udid | ||
849 | + * @param other [Obejct] 包含uid,query,type等非必传参数 | ||
848 | * @returns {Promise.<T>|*} | 850 | * @returns {Promise.<T>|*} |
849 | */ | 851 | */ |
850 | -const getDynamicDataByIds = ids => { | ||
851 | - return serviceApi.get('', { | ||
852 | - ids: ids | ||
853 | - }).then(res => { | 852 | +const getDynamicDataByIds = (ids, udid, other) => { |
853 | + let params = { | ||
854 | + articleIds: ids, | ||
855 | + udid: udid | ||
856 | + }; | ||
854 | 857 | ||
855 | - if (res && res.code === 200 && res.data) { | ||
856 | - return res.data; | ||
857 | - } | 858 | + if (other.uid) { |
859 | + _.assign(params, { | ||
860 | + uid: other.uid | ||
861 | + }); | ||
862 | + } | ||
858 | 863 | ||
859 | - return Promise.reject('获取失败'); | ||
860 | - }); | 864 | + if (other.query) { |
865 | + _.assign(params, { | ||
866 | + query: other.query | ||
867 | + }); | ||
868 | + } | ||
869 | + | ||
870 | + if (other.type) { | ||
871 | + _.assign(params, { | ||
872 | + type: other.type | ||
873 | + }); | ||
874 | + } | ||
875 | + | ||
876 | + return serviceApi.get('guang/api/*/article/getSimpleArticleList', params, {cache: true}); | ||
861 | }; | 877 | }; |
862 | 878 | ||
863 | module.exports = { | 879 | module.exports = { |
@@ -23,5 +23,9 @@ router.get('/info/cancelPraise', guangController.cancelPraise); | @@ -23,5 +23,9 @@ router.get('/info/cancelPraise', guangController.cancelPraise); | ||
23 | router.get('/info/collect', guangController.collect); | 23 | router.get('/info/collect', guangController.collect); |
24 | router.get('/info/cancelCollect', guangController.cancelCollect); | 24 | router.get('/info/cancelCollect', guangController.cancelCollect); |
25 | 25 | ||
26 | +router.get('/info/listData', guangController.listDynamicData); | ||
27 | +router.get('/info/detailData', guangController.detailDynamicData); | ||
28 | + | ||
29 | +// router.get('/info/commentData', guangController.detailCommentData); | ||
26 | 30 | ||
27 | module.exports = router; | 31 | module.exports = router; |
@@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
17 | </div> | 17 | </div> |
18 | <div class="article-status clearfix"> | 18 | <div class="article-status clearfix"> |
19 | <span class="article-time">{{time}}</span> | 19 | <span class="article-time">{{time}}</span> |
20 | - <span class="article-click">点击:{{click}}</span> | 20 | + <span class="article-click">点击:<em>{{click}}</em></span> |
21 | <a href="#comment-info" id="article-comment" class="article-comment"><em class="comment-num">{{commentNum}}</em>条评论</a> | 21 | <a href="#comment-info" id="article-comment" class="article-comment"><em class="comment-num">{{commentNum}}</em>条评论</a> |
22 | </div> | 22 | </div> |
23 | </div> | 23 | </div> |
@@ -147,4 +147,4 @@ | @@ -147,4 +147,4 @@ | ||
147 | {{> right-side}} | 147 | {{> right-side}} |
148 | </div> | 148 | </div> |
149 | {{/ guang}} | 149 | {{/ guang}} |
150 | -</div> | ||
150 | +</div> |
@@ -20,11 +20,11 @@ | @@ -20,11 +20,11 @@ | ||
20 | {{/ msgs}} | 20 | {{/ msgs}} |
21 | </div> | 21 | </div> |
22 | <div class="msg-pager pager"> | 22 | <div class="msg-pager pager"> |
23 | - {{{msgPager}}} | 23 | + {{pager baseUrl totalRecords=total page=page type="ellipsis" theme="msg-pager"}} |
24 | </div> | 24 | </div> |
25 | </div> | 25 | </div> |
26 | <div class="right-side"> | 26 | <div class="right-side"> |
27 | {{> right-side}} | 27 | {{> right-side}} |
28 | </div> | 28 | </div> |
29 | {{/ guang}} | 29 | {{/ guang}} |
30 | -</div> | ||
30 | +</div> |
@@ -12,10 +12,10 @@ | @@ -12,10 +12,10 @@ | ||
12 | {{/ msgs}} | 12 | {{/ msgs}} |
13 | </div> | 13 | </div> |
14 | 14 | ||
15 | - {{pager totalRecords=total page=page type="ellipsis" theme="msg-pager"}} | 15 | + {{pager baseUrl totalRecords=total page=page type="ellipsis" theme="msg-pager"}} |
16 | </div> | 16 | </div> |
17 | <div class="right-side"> | 17 | <div class="right-side"> |
18 | {{> right-side}} | 18 | {{> right-side}} |
19 | </div> | 19 | </div> |
20 | {{/ guang}} | 20 | {{/ guang}} |
21 | -</div> | ||
21 | +</div> |
@@ -18,6 +18,6 @@ | @@ -18,6 +18,6 @@ | ||
18 | </li> | 18 | </li> |
19 | {{/ list}} | 19 | {{/ list}} |
20 | </ul> | 20 | </ul> |
21 | - <div class="comment-pager pager">{{pager totalRecords=commentNum page=page type="ellipsis" theme="msg-pager"}}</div> | 21 | + <div class="comment-pager pager">{{pager baseUrl totalRecords=commentNum page=page pageSize=pageSize type="ellipsis" theme="msg-pager"}}</div> |
22 | </div> | 22 | </div> |
23 | {{/ comment}} | 23 | {{/ comment}} |
@@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
22 | </span> | 22 | </span> |
23 | <span class="page-view"> | 23 | <span class="page-view"> |
24 | <i class="iconfont"></i> | 24 | <i class="iconfont"></i> |
25 | - {{pView}} | 25 | + <em>{{pView}}</em> |
26 | </span> | 26 | </span> |
27 | </p> | 27 | </p> |
28 | <p class="content">{{content}}</p> | 28 | <p class="content">{{content}}</p> |
@@ -40,7 +40,7 @@ | @@ -40,7 +40,7 @@ | ||
40 | <span class="comment"> | 40 | <span class="comment"> |
41 | <i class="iconfont"></i> | 41 | <i class="iconfont"></i> |
42 | {{# comment}} | 42 | {{# comment}} |
43 | - ({{.}}) | 43 | + (<em>{{.}}</em>) |
44 | {{/ comment}} | 44 | {{/ comment}} |
45 | </span> | 45 | </span> |
46 | </div> | 46 | </div> |
public/js/guang/detail-dynamic.js
0 → 100644
1 | +/** | ||
2 | + * 动态获取页面数据 | ||
3 | + * @author liuchuanyang | ||
4 | + * @date 2016/10/09 | ||
5 | + */ | ||
6 | +var $ = require('yoho-jquery'); | ||
7 | + | ||
8 | +function getDynamicById(id) { | ||
9 | + 'use strict'; | ||
10 | + | ||
11 | + var param = { | ||
12 | + id: id | ||
13 | + }; | ||
14 | + | ||
15 | +// //guang.yohobuy.com/guang/info/detailData | ||
16 | + return $.getJSON('/guang/info/detailData', param); | ||
17 | +} | ||
18 | + | ||
19 | +function renderData(data) { | ||
20 | + 'use strict'; | ||
21 | + | ||
22 | + var $favor = $('#collect-btn'), | ||
23 | + $praise = $('#prise-btn'); | ||
24 | + | ||
25 | + if (data && data.code === 200 && data.data) { | ||
26 | + | ||
27 | + if (data.data.isFavor === 'Y') { | ||
28 | + $favor.addClass('collected'); | ||
29 | + } else { | ||
30 | + $favor.removeClass('collected'); | ||
31 | + } | ||
32 | + | ||
33 | + if (data.data.isPraise === 'Y') { | ||
34 | + $praise.addClass('liked'); | ||
35 | + } else { | ||
36 | + $praise.removeClass('liked'); | ||
37 | + } | ||
38 | + | ||
39 | + $praise.find('.like-num').text(data.data.praiseNum || 0); | ||
40 | + $('.detail-body .article-click em').text(data.data.browseNum || 0); | ||
41 | + } | ||
42 | +} | ||
43 | + | ||
44 | +function refreshData() { | ||
45 | + 'use strict'; | ||
46 | + | ||
47 | + var id = $('.detail-body').attr('data-id'); | ||
48 | + | ||
49 | + getDynamicById(id).done(renderData); | ||
50 | +} | ||
51 | + | ||
52 | +refreshData(); |
@@ -21,6 +21,7 @@ require('./right-side'); | @@ -21,6 +21,7 @@ require('./right-side'); | ||
21 | require('./img-blink'); | 21 | require('./img-blink'); |
22 | 22 | ||
23 | require('../common/share'); | 23 | require('../common/share'); |
24 | +require('./detail-dynamic'); | ||
24 | 25 | ||
25 | // Pjax | 26 | // Pjax |
26 | require('yoho-jquery-pjax'); | 27 | require('yoho-jquery-pjax'); |
@@ -214,6 +215,9 @@ $(document).pjax('.comment-pager a', '#pjax-container', { | @@ -214,6 +215,9 @@ $(document).pjax('.comment-pager a', '#pjax-container', { | ||
214 | $(document).on('pjax:end', function() { | 215 | $(document).on('pjax:end', function() { |
215 | showComment(); | 216 | showComment(); |
216 | $('html,body').scrollTop($('#comment-info').offset().top); | 217 | $('html,body').scrollTop($('#comment-info').offset().top); |
218 | + | ||
219 | + // 设置头部评论数 | ||
220 | + $('#article-comment .comment-num').text($('#comment-area .comment-num').text()); | ||
217 | }); | 221 | }); |
218 | 222 | ||
219 | $('#comment-info').keyup(function() { | 223 | $('#comment-info').keyup(function() { |
public/js/guang/dynamic-data.js
deleted
100644 → 0
1 | -/** | ||
2 | - * 动态获取页面数据 | ||
3 | - * @author liuchuanyang | ||
4 | - * @date 2016/10/09 | ||
5 | - */ | ||
6 | -var $ = require('yoho-jquery'); | ||
7 | - | ||
8 | -function getDynamicById(id) { | ||
9 | - 'use strict'; | ||
10 | - | ||
11 | - var param = { | ||
12 | - return_type: 'jsonp', | ||
13 | - id: id | ||
14 | - }; | ||
15 | - | ||
16 | - return $.getJSON('//guang.yohobuy.com/guang/suggest?callback=?', param); | ||
17 | -} | ||
18 | - | ||
19 | -function getDynamicByIds(ids) { | ||
20 | - 'use strict'; | ||
21 | - | ||
22 | - var param = { | ||
23 | - return_type: 'jsonp', | ||
24 | - ids: ids | ||
25 | - }; | ||
26 | - | ||
27 | - return $.getJSON('//guang.yohobuy.com/guang/suggest?callback=?', param); | ||
28 | -} | ||
29 | - | ||
30 | -function getDynamicCommentList(id, page) { | ||
31 | - 'use strict'; | ||
32 | - | ||
33 | - var param = { | ||
34 | - id: id, | ||
35 | - page: page | ||
36 | - }; | ||
37 | - | ||
38 | - return $.getJSON('//guang.yohobuy.com/guang/suggest?callback=?', param); | ||
39 | -} | ||
40 | - | ||
41 | -module.exports = { | ||
42 | - getDynamicById, | ||
43 | - getDynamicByIds, | ||
44 | - getDynamicCommentList | ||
45 | -}; |
@@ -15,6 +15,9 @@ require('./img-blink'); | @@ -15,6 +15,9 @@ require('./img-blink'); | ||
15 | 15 | ||
16 | require('./right-side'); | 16 | require('./right-side'); |
17 | 17 | ||
18 | +// page cache下更新点赞状态、点赞数、评论数、阅读数 | ||
19 | +require('./list-dynamic'); | ||
20 | + | ||
18 | $('#slider').slider(); // 初始化slider | 21 | $('#slider').slider(); // 初始化slider |
19 | 22 | ||
20 | $(document).pjax('.pjax-link, .msg-pager a', '#pjax-container', { | 23 | $(document).pjax('.pjax-link, .msg-pager a', '#pjax-container', { |
public/js/guang/list-dynamic.js
0 → 100644
1 | +/** | ||
2 | + * 动态获取页面数据 | ||
3 | + * @author liuchuanyang | ||
4 | + * @date 2016/10/09 | ||
5 | + */ | ||
6 | +var $ = require('yoho-jquery'); | ||
7 | + | ||
8 | +var $msgs = $('#msg-list'); | ||
9 | + | ||
10 | +require('../common'); | ||
11 | + | ||
12 | +function getDynamicByIds(ids) { | ||
13 | + 'use strict'; | ||
14 | + var data = { | ||
15 | + ids: ids | ||
16 | + }; | ||
17 | + | ||
18 | + var qs = window.queryString(); | ||
19 | + | ||
20 | + if (qs.query) { | ||
21 | + | ||
22 | + // 标签列表 | ||
23 | + data.query = qs.query; | ||
24 | + } else if (qs.type) { | ||
25 | + | ||
26 | + // 逛首页type | ||
27 | + data.type = qs.type; | ||
28 | + } else if (!qs.author_id) { | ||
29 | + | ||
30 | + // 非编辑页的情况下,为逛首页默认type=0 | ||
31 | + data.type = '0'; | ||
32 | + } | ||
33 | + | ||
34 | + return $.ajax({ | ||
35 | + type: 'GET', | ||
36 | + url: '/guang/info/listData', | ||
37 | + data: data | ||
38 | + }); | ||
39 | +} | ||
40 | + | ||
41 | +function renderData(data) { | ||
42 | + 'use strict'; | ||
43 | + | ||
44 | + var i, | ||
45 | + it, | ||
46 | + $it; | ||
47 | + | ||
48 | + var list; | ||
49 | + | ||
50 | + if (data && data.code === 200 && (list = data.data.artList)) { | ||
51 | + for (i = 0; i < list.length; i++) { | ||
52 | + it = list[i]; | ||
53 | + | ||
54 | + if (it && it.articleId) { | ||
55 | + $it = $('.msg-content[data-id=' + it.articleId + ']', $msgs); | ||
56 | + | ||
57 | + // 浏览数目 | ||
58 | + $it.find('.page-view em').text(it.views_num); | ||
59 | + | ||
60 | + // 点赞状态 | ||
61 | + if (it.isPraise === 'Y') { | ||
62 | + $it.find('.like-icon').addClass('liked'); | ||
63 | + } else { | ||
64 | + $it.find('.like-icon').removeClass('liked'); | ||
65 | + } | ||
66 | + | ||
67 | + // 点赞数目 | ||
68 | + $it.find('.like .num').text(it.praise_num); | ||
69 | + | ||
70 | + // 评论数目 | ||
71 | + $it.find('.comment em').text(it.comment_num); | ||
72 | + } | ||
73 | + } | ||
74 | + } | ||
75 | +} | ||
76 | + | ||
77 | +(function() { | ||
78 | + 'use strict'; | ||
79 | + | ||
80 | + var idArr = []; | ||
81 | + | ||
82 | + $msgs.children('.msg-content').each(function() { | ||
83 | + var id = $(this).data('id'); | ||
84 | + | ||
85 | + if (id) { | ||
86 | + idArr.push(id); | ||
87 | + } | ||
88 | + }); | ||
89 | + | ||
90 | + getDynamicByIds(idArr.join(',')).then(renderData); | ||
91 | +}()); |
-
Please register or login to post a comment