Authored by 毕凯

Merge branch 'feature/seckillgoods' into 'master'

秒杀添加商品列表



See merge request !519
... ... @@ -278,7 +278,8 @@ const getSearchData = (params, uid) => {
if (result && result.code === 200) {
return productProcess.processProductList(result.data.product_list || [], {
yh_channel: params.yh_channel,
showSale: false
showSale: false,
isApp: params.isApp
});
} else {
logger.error('api SALE product search code no 200');
... ...
<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": {
... ...
... ... @@ -45,22 +45,26 @@ seckillObj = {
self.$productList = $('.product-list');
// 在app webview中click捕获不到translate样式后的新位置
let $navLis = $el.$navUl.find('>li');
$navLis.on('touchmove', function() {
self.navMove = true;
});
$navLis.on('touchend', function(event) {
if (self.navMove) {
self.navMove = false;
return;
}
setTimeout(() => {
self.selectTime(event.currentTarget);
}, 200);
$el.$navUl.find('>li').click(function(event) {
self.selectTime(event.currentTarget);
});
// 在app webview中click捕获不到translate样式后的新位置
// let $navLis = $el.$navUl.find('>li');
// $navLis.on('touchmove', function() {
// self.navMove = true;
// });
// $navLis.on('touchend', function(event) {
// if (self.navMove) {
// self.navMove = false;
// return;
// }
// setTimeout(() => {
// self.selectTime(event.currentTarget);
// }, 200);
// });
$(window).resize(function() {
self.initNav();
});
... ... @@ -115,6 +119,7 @@ seckillObj = {
tap: true,
eventPassthrough: true,
preventDefault: true,
HWCompositing: false,
bounceTime: 400,
bounceEasing: {
style: 'cubic-bezier(0.333333, 0.666667, 0.666667, 1)'
... ... @@ -466,3 +471,5 @@ window.seckillRefresh = function() {
$(function() {
seckillObj.init();
});
require('./seckill/goods-list');
... ...
/*
* @Author: Targaryen
* @Date: 2017-04-21 13:36:34
* @Last Modified by: Targaryen
* @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);
});
$(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;
... ...