Showing
7 changed files
with
93 additions
and
2 deletions
@@ -248,6 +248,7 @@ const index = (req, res, next) => { | @@ -248,6 +248,7 @@ const index = (req, res, next) => { | ||
248 | let resu = yield aboutModel.about(req.yoho.isApp); | 248 | let resu = yield aboutModel.about(req.yoho.isApp); |
249 | 249 | ||
250 | data.guang.wxFooter = resu; | 250 | data.guang.wxFooter = resu; |
251 | + console.log(data); | ||
251 | res.render('info/index', Object.assign({ | 252 | res.render('info/index', Object.assign({ |
252 | page: 'info-index', | 253 | page: 'info-index', |
253 | title: '逛', | 254 | title: '逛', |
@@ -424,9 +425,26 @@ const foryoho = (req, res, next) => { | @@ -424,9 +425,26 @@ const foryoho = (req, res, next) => { | ||
424 | })().catch(next); | 425 | })().catch(next); |
425 | }; | 426 | }; |
426 | 427 | ||
428 | +/** | ||
429 | + * 异步获取逛文章评论 | ||
430 | + * @param {*} req | ||
431 | + * @param {*} res | ||
432 | + * @param {*} next | ||
433 | + */ | ||
434 | +const getComments = (req, res, next) => { | ||
435 | + | ||
436 | + req.ctx(DetailModel).comments({ | ||
437 | + article_id: req.query.article_id, | ||
438 | + page: req.query.page | ||
439 | + }).then(result => { | ||
440 | + return res.render('info/comments', result); | ||
441 | + }).catch(next); | ||
442 | +}; | ||
443 | + | ||
427 | module.exports = { | 444 | module.exports = { |
428 | index, | 445 | index, |
429 | mini, | 446 | mini, |
430 | foryoho, | 447 | foryoho, |
431 | - indexRedirect | 448 | + indexRedirect, |
449 | + getComments | ||
432 | }; | 450 | }; |
@@ -11,6 +11,7 @@ const helpers = global.yoho.helpers; | @@ -11,6 +11,7 @@ const helpers = global.yoho.helpers; | ||
11 | 11 | ||
12 | const URI_PACKAGE_ARTICLE = 'guang/service/v2/article/'; | 12 | const URI_PACKAGE_ARTICLE = 'guang/service/v2/article/'; |
13 | const URI_PACKAGE_AUTHOR = 'guang/service/v1/author/'; | 13 | const URI_PACKAGE_AUTHOR = 'guang/service/v1/author/'; |
14 | +const URI_PACKAGE_COMMENTS = 'guang/service/v1/comments/'; | ||
14 | 15 | ||
15 | 16 | ||
16 | class DetailModel extends global.yoho.BaseModel { | 17 | class DetailModel extends global.yoho.BaseModel { |
@@ -348,6 +349,17 @@ class DetailModel extends global.yoho.BaseModel { | @@ -348,6 +349,17 @@ class DetailModel extends global.yoho.BaseModel { | ||
348 | return _.get(result, 'data.product_list', []); | 349 | return _.get(result, 'data.product_list', []); |
349 | }); | 350 | }); |
350 | } | 351 | } |
352 | + | ||
353 | + /** | ||
354 | + * 获取文章评论列表 | ||
355 | + */ | ||
356 | + comments(params) { | ||
357 | + return serviceAPI.get(`${URI_PACKAGE_COMMENTS}getList`, { | ||
358 | + article_id: params.article_id, | ||
359 | + page: params.page, | ||
360 | + limit: params.limit || 10 | ||
361 | + }); | ||
362 | + } | ||
351 | } | 363 | } |
352 | 364 | ||
353 | module.exports = DetailModel; | 365 | module.exports = DetailModel; |
@@ -58,6 +58,8 @@ router.get('/:id.html', detail.index); // 逛详情页(兼容 PC 跳转过来的 | @@ -58,6 +58,8 @@ router.get('/:id.html', detail.index); // 逛详情页(兼容 PC 跳转过来的 | ||
58 | router.get('/info/mini', detail.mini); // 逛mini内容页 | 58 | router.get('/info/mini', detail.mini); // 逛mini内容页 |
59 | router.get('/info/foryoho', detail.foryoho); // 逛foryoho内容页 | 59 | router.get('/info/foryoho', detail.foryoho); // 逛foryoho内容页 |
60 | 60 | ||
61 | +router.get('/info/getComments', detail.getComments); // 异步获取逛文章评论 | ||
62 | + | ||
61 | router.get('/plustar', plustar.getListData); // 国际优选列表页 | 63 | router.get('/plustar', plustar.getListData); // 国际优选列表页 |
62 | router.get('/plustar/brandinfo', plustar.getDetailData); // 国际优选详情页 | 64 | router.get('/plustar/brandinfo', plustar.getDetailData); // 国际优选详情页 |
63 | router.post('/plustar/brandinfoAsync', plustar.getDetailDataAsync); // 国际优选详情页异步数据 | 65 | router.post('/plustar/brandinfoAsync', plustar.getDetailDataAsync); // 国际优选详情页异步数据 |
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | * @Author: Targaryen | 2 | * @Author: Targaryen |
3 | * @Date: 2017-05-25 14:36:33 | 3 | * @Date: 2017-05-25 14:36:33 |
4 | * @Last Modified by: Targaryen | 4 | * @Last Modified by: Targaryen |
5 | - * @Last Modified time: 2017-05-25 15:28:52 | 5 | + * @Last Modified time: 2017-05-25 17:09:44 |
6 | */ | 6 | */ |
7 | const $ = require('yoho-jquery'); | 7 | const $ = require('yoho-jquery'); |
8 | const qs = window.queryString; | 8 | const qs = window.queryString; |
@@ -32,6 +32,39 @@ require('./detail/guang-cart'); | @@ -32,6 +32,39 @@ require('./detail/guang-cart'); | ||
32 | 32 | ||
33 | let CollactionBlock = require('./collocation-block'); | 33 | let CollactionBlock = require('./collocation-block'); |
34 | 34 | ||
35 | +const qs = window.queryString; | ||
36 | +const article_id = qs.id || $('.detail').data('id'); | ||
37 | +const $comments = $('#comments'); | ||
38 | +let onLoading = false; // 是否正在加载 | ||
39 | +// let beforeScroll = document.body.scrollTop; // 滚动前位置记录 | ||
40 | +let page = 0; | ||
41 | + | ||
42 | +/** | ||
43 | + * 异步加载评论 | ||
44 | + */ | ||
45 | +const getComments = () => { | ||
46 | + if (!onLoading) { | ||
47 | + onLoading = true; | ||
48 | + } else { | ||
49 | + return false; | ||
50 | + } | ||
51 | + | ||
52 | + $.ajax({ | ||
53 | + type: 'get', | ||
54 | + url: '//guang.m.yohobuy.com/guang/info/getComments', | ||
55 | + data: { | ||
56 | + article_id: article_id, | ||
57 | + page: page++ | ||
58 | + }, | ||
59 | + success: function(result) { | ||
60 | + $comments.append(result); | ||
61 | + onLoading = false; | ||
62 | + } | ||
63 | + }); | ||
64 | +}; | ||
65 | + | ||
66 | +getComments(); | ||
67 | + | ||
35 | $('#wrapper').css({ | 68 | $('#wrapper').css({ |
36 | 'overflow-y': 'scroll' | 69 | 'overflow-y': 'scroll' |
37 | }); | 70 | }); |
@@ -362,3 +395,27 @@ $('.wei-share').on('touchend', function(e) { | @@ -362,3 +395,27 @@ $('.wei-share').on('touchend', function(e) { | ||
362 | initIscroll(); | 395 | initIscroll(); |
363 | }()); | 396 | }()); |
364 | 397 | ||
398 | +/** | ||
399 | + * 当scroll到1/2$goodsContainer高度后继续请求下一页数据 | ||
400 | + */ | ||
401 | +// const scrollHandler = function() { | ||
402 | +// if ($(window).scrollTop() > $comments.height() * 0.6) { | ||
403 | +// getComments(); | ||
404 | +// } | ||
405 | +// }; | ||
406 | + | ||
407 | +// /** | ||
408 | +// * 滚动加载 | ||
409 | +// */ | ||
410 | +// $(window).scroll(function() { | ||
411 | +// setTimeout(function() { | ||
412 | +// let afterScroll = document.body.scrollTop; | ||
413 | + | ||
414 | +// if (afterScroll - beforeScroll > 0) { | ||
415 | +// window.requestAnimationFrame(scrollHandler); | ||
416 | +// beforeScroll = afterScroll; | ||
417 | +// } else { | ||
418 | +// return false; | ||
419 | +// } | ||
420 | +// }, 5); | ||
421 | +// }); |
-
Please register or login to post a comment