Authored by 周少峰

Merge branch 'hotfix/guangComment'

... ... @@ -12,6 +12,7 @@ const guangModel = require('../models/index');
const headerModel = require('../../../doraemon/models/header');
const ghelper = require('../models/guang-helper');
const querystring = require('querystring');
const helpers = global.yoho.helpers;
/**
* 首页文章列表 类型列表
... ... @@ -205,6 +206,7 @@ exports.detail = (req, res, next) => {
if (pjax) {
guangModel.getArticleComments(id, page, pageSize).then(ret => {
res.set('Cache-Control', 'no-cache');
res.render('guang/detail-comment', {
layout: false,
comment: ret
... ... @@ -288,7 +290,11 @@ exports.detail = (req, res, next) => {
shareImg: info.shareImg,
sharedTitle: info.title,
shareDesc: info.desc,
weixinUrl: info.weixinUrl
weixinUrl: info.weixinUrl,
commentFirstPageUrl: helpers.urlFormat('/info/index', {
id: id,
pageSize: 10
}, 'guang')
}
}, {
title: `${info.title} | YOHO!BUY有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证`,
... ...
... ... @@ -142,6 +142,7 @@
<div id="pjax-container" class="comments-wrap">
{{> comment}}
</div>
<a href="{{commentFirstPageUrl}}" data-role="comment-first-url" class="hide"></a>
</div>
{{/unless}}
</div>
... ...
... ... @@ -17,7 +17,8 @@ const cachePage = {
// 逛
'/guang/': 1 * MINUTE,
'/guang/info/index': 10 * MINUTE,
// '/guang/info/index': 10 * MINUTE,
'/guang/detail/:id': 10 * MINUTE,
'/guang/Index/editor': 1 * MINUTE,
'/guang/tags/index': 1 * MINUTE,
... ...
... ... @@ -15,7 +15,8 @@ var $commentList = $commentArea.find('.comments-wrap'),
locating = false, // 评论页面正在跳转
$commentBtn = $('#comment-btn'),
MAX_COMMENTS_WORDS = 100,
$wordCountTip = $('#word-count-tip');
$wordCountTip = $('#word-count-tip'),
commentLoaded = false;
require('../common');
require('./right-side');
... ... @@ -213,10 +214,21 @@ $commentBtn.click(function(e) {
// comment pager pjax
$(document).pjax('.comment-pager a', '#pjax-container', {
$(document).pjax('.comment-pager a, [data-role="comment-first-url"]', '#pjax-container', {
timeout: 5000
});
if ($('#comment-area').length) {
$(document).on('scroll', function() {
if (!commentLoaded && ($(document).scrollTop() + $(window).height()) > $('#comment-area').offset().top) {
commentLoaded = true;
$('[data-role="comment-first-url"]').click();
}
});
}
// 分页后移动到评论框的位置
$(document).on('pjax:end', function() {
showComment();
... ...