...
|
...
|
@@ -32,6 +32,39 @@ require('./detail/guang-cart'); |
|
|
|
|
|
let CollactionBlock = require('./collocation-block');
|
|
|
|
|
|
const qs = window.queryString;
|
|
|
const article_id = qs.id || $('.detail').data('id');
|
|
|
const $comments = $('#comments');
|
|
|
let onLoading = false; // 是否正在加载
|
|
|
// let beforeScroll = document.body.scrollTop; // 滚动前位置记录
|
|
|
let page = 0;
|
|
|
|
|
|
/**
|
|
|
* 异步加载评论
|
|
|
*/
|
|
|
const getComments = () => {
|
|
|
if (!onLoading) {
|
|
|
onLoading = true;
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'get',
|
|
|
url: '//guang.m.yohobuy.com/guang/info/getComments',
|
|
|
data: {
|
|
|
article_id: article_id,
|
|
|
page: page++
|
|
|
},
|
|
|
success: function(result) {
|
|
|
$comments.append(result);
|
|
|
onLoading = false;
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
getComments();
|
|
|
|
|
|
$('#wrapper').css({
|
|
|
'overflow-y': 'scroll'
|
|
|
});
|
...
|
...
|
@@ -362,3 +395,27 @@ $('.wei-share').on('touchend', function(e) { |
|
|
initIscroll();
|
|
|
}());
|
|
|
|
|
|
/**
|
|
|
* 当scroll到1/2$goodsContainer高度后继续请求下一页数据
|
|
|
*/
|
|
|
// const scrollHandler = function() {
|
|
|
// if ($(window).scrollTop() > $comments.height() * 0.6) {
|
|
|
// getComments();
|
|
|
// }
|
|
|
// };
|
|
|
|
|
|
// /**
|
|
|
// * 滚动加载
|
|
|
// */
|
|
|
// $(window).scroll(function() {
|
|
|
// setTimeout(function() {
|
|
|
// let afterScroll = document.body.scrollTop;
|
|
|
|
|
|
// if (afterScroll - beforeScroll > 0) {
|
|
|
// window.requestAnimationFrame(scrollHandler);
|
|
|
// beforeScroll = afterScroll;
|
|
|
// } else {
|
|
|
// return false;
|
|
|
// }
|
|
|
// }, 5);
|
|
|
// }); |
...
|
...
|
|