Authored by ccbikai(👎🏻🍜)

Merge branch 'feature/seckillgoods' of git.yoho.cn:fe/yohobuywap-node into feature/seckillgoods

<div class="seckill-list yoho-page">
<div id="seckill-list-loading" style="height: 100vh"></div>
</div>
<div class="floor-header-more">
<h2>限时热促</h2>
</div>
<div id="goodsContainer" class="goods-container hide" style="background-color: #fff">
<div id="container" class="default-goods container clearfix"></div>
</div>
\ No newline at end of file
... ...
{
"name": "m-yohobuy-node",
"version": "5.6.1",
"version": "5.6.2",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -18,7 +18,4 @@
<li>活动最终解释权归YOHO!BUY有货所有</li>
</ol>
</section>
<div id="goodsContainer" class="goods-container">
<div class="default-goods container clearfix"></div>
</div>
</div>
... ...
... ... @@ -2,11 +2,92 @@
* @Author: Targaryen
* @Date: 2017-04-21 13:36:34
* @Last Modified by: Targaryen
* @Last Modified time: 2017-04-21 13:38:09
* @Last Modified time: 2017-04-21 14:17:40
*/
const $ = require('yoho-jquery');
const lazyLoad = require('yoho-jquery-lazyload');
const yoho = require('yoho-app');
const qs = require('yoho-qs');
const cookie = require('yoho-cookie');
/**
* 获取 APP 传过来的参数
*/
const getChannel = {
1: 'boys',
2: 'girls',
3: 'kids',
4: 'lifestyle',
'1,2,3,4': 'all'
};
let $goodsContainer = $('#goodsContainer');
let $container = $('#container');
let channel = getChannel[qs.yh_channel] || cookie.get('_Channel');
let page = 1;
let beforeScroll = document.body.scrollTop; // 滚动前位置记录
let onSearching = false; // 是否正在搜索
const loadGoodsList = () => {
if (onSearching) {
return false;
}
onSearching = true;
$.ajax({
method: 'get',
url: location.protocol + '//m.yohobuy.com/product/sale/search?type=discount&order=1',
data: {
yh_channel: channel,
page: page++,
isApp: yoho.isApp
},
complete: function() {
onSearching = false;
},
success: function(result) {
let $result = $(result);
let noResult = !result || result.length < 1 || (result.list && result.list.length < 1);
if (noResult) {
return false;
}
$container.append($result);
$goodsContainer.removeClass('hide');
lazyLoad($result.find('img'));
}
});
};
/**
* 当scroll到1/2$goodsContainer高度后继续请求下一页数据
*/
const scrollHandler = function() {
if ($(window).scrollTop() > $goodsContainer.height() * 0.6) {
loadGoodsList();
}
};
/**
* 滚动加载
*/
$(window).scroll(function() {
setTimeout(function() {
let afterScroll = document.body.scrollTop;
if (afterScroll - beforeScroll > 0) {
window.requestAnimationFrame(scrollHandler);
beforeScroll = afterScroll;
} else {
return false;
}
}, 5);
});
console.log($goodsContainer);
$(function() {
loadGoodsList();
});
... ...
... ... @@ -4,8 +4,9 @@
.tips {
font-size: 24px;
line-height: 1.4;
color: #b0b0b0;
padding: 30px 30px 185px;
color: #666;
padding: 30px;
background-color: #fff;
h5 {
font-size: 25px;
... ...