Authored by 毕凯

Merge branch 'feature/seckillgoods' into 'master'

秒杀添加商品列表



See merge request !519
@@ -278,7 +278,8 @@ const getSearchData = (params, uid) => { @@ -278,7 +278,8 @@ const getSearchData = (params, uid) => {
278 if (result && result.code === 200) { 278 if (result && result.code === 200) {
279 return productProcess.processProductList(result.data.product_list || [], { 279 return productProcess.processProductList(result.data.product_list || [], {
280 yh_channel: params.yh_channel, 280 yh_channel: params.yh_channel,
281 - showSale: false 281 + showSale: false,
  282 + isApp: params.isApp
282 }); 283 });
283 } else { 284 } else {
284 logger.error('api SALE product search code no 200'); 285 logger.error('api SALE product search code no 200');
1 <div class="seckill-list yoho-page"> 1 <div class="seckill-list yoho-page">
2 <div id="seckill-list-loading" style="height: 100vh"></div> 2 <div id="seckill-list-loading" style="height: 100vh"></div>
3 </div> 3 </div>
  4 +<div class="floor-header-more">
  5 + <h2>限时热促</h2>
  6 +</div>
  7 +<div id="goodsContainer" class="goods-container hide" style="background-color: #fff">
  8 + <div id="container" class="default-goods container clearfix"></div>
  9 +</div>
1 { 1 {
2 "name": "m-yohobuy-node", 2 "name": "m-yohobuy-node",
3 - "version": "5.6.1", 3 + "version": "5.6.2",
4 "private": true, 4 "private": true,
5 "description": "A New Yohobuy Project With Express", 5 "description": "A New Yohobuy Project With Express",
6 "repository": { 6 "repository": {
@@ -45,22 +45,26 @@ seckillObj = { @@ -45,22 +45,26 @@ seckillObj = {
45 45
46 self.$productList = $('.product-list'); 46 self.$productList = $('.product-list');
47 47
48 - // 在app webview中click捕获不到translate样式后的新位置  
49 - let $navLis = $el.$navUl.find('>li');  
50 -  
51 - $navLis.on('touchmove', function() {  
52 - self.navMove = true;  
53 - });  
54 - $navLis.on('touchend', function(event) {  
55 - if (self.navMove) {  
56 - self.navMove = false;  
57 - return;  
58 - }  
59 - setTimeout(() => {  
60 - self.selectTime(event.currentTarget);  
61 - }, 200); 48 + $el.$navUl.find('>li').click(function(event) {
  49 + self.selectTime(event.currentTarget);
62 }); 50 });
63 51
  52 + // 在app webview中click捕获不到translate样式后的新位置
  53 + // let $navLis = $el.$navUl.find('>li');
  54 +
  55 + // $navLis.on('touchmove', function() {
  56 + // self.navMove = true;
  57 + // });
  58 + // $navLis.on('touchend', function(event) {
  59 + // if (self.navMove) {
  60 + // self.navMove = false;
  61 + // return;
  62 + // }
  63 + // setTimeout(() => {
  64 + // self.selectTime(event.currentTarget);
  65 + // }, 200);
  66 + // });
  67 +
64 $(window).resize(function() { 68 $(window).resize(function() {
65 self.initNav(); 69 self.initNav();
66 }); 70 });
@@ -115,6 +119,7 @@ seckillObj = { @@ -115,6 +119,7 @@ seckillObj = {
115 tap: true, 119 tap: true,
116 eventPassthrough: true, 120 eventPassthrough: true,
117 preventDefault: true, 121 preventDefault: true,
  122 + HWCompositing: false,
118 bounceTime: 400, 123 bounceTime: 400,
119 bounceEasing: { 124 bounceEasing: {
120 style: 'cubic-bezier(0.333333, 0.666667, 0.666667, 1)' 125 style: 'cubic-bezier(0.333333, 0.666667, 0.666667, 1)'
@@ -466,3 +471,5 @@ window.seckillRefresh = function() { @@ -466,3 +471,5 @@ window.seckillRefresh = function() {
466 $(function() { 471 $(function() {
467 seckillObj.init(); 472 seckillObj.init();
468 }); 473 });
  474 +
  475 +require('./seckill/goods-list');
  1 +/*
  2 + * @Author: Targaryen
  3 + * @Date: 2017-04-21 13:36:34
  4 + * @Last Modified by: Targaryen
  5 + * @Last Modified time: 2017-04-21 14:17:40
  6 + */
  7 +
  8 +const $ = require('yoho-jquery');
  9 +const lazyLoad = require('yoho-jquery-lazyload');
  10 +const yoho = require('yoho-app');
  11 +const qs = require('yoho-qs');
  12 +const cookie = require('yoho-cookie');
  13 +
  14 +/**
  15 + * 获取 APP 传过来的参数
  16 + */
  17 +const getChannel = {
  18 + 1: 'boys',
  19 + 2: 'girls',
  20 + 3: 'kids',
  21 + 4: 'lifestyle',
  22 + '1,2,3,4': 'all'
  23 +};
  24 +
  25 +let $goodsContainer = $('#goodsContainer');
  26 +let $container = $('#container');
  27 +let channel = getChannel[qs.yh_channel] || cookie.get('_Channel');
  28 +let page = 1;
  29 +let beforeScroll = document.body.scrollTop; // 滚动前位置记录
  30 +let onSearching = false; // 是否正在搜索
  31 +
  32 +const loadGoodsList = () => {
  33 +
  34 + if (onSearching) {
  35 + return false;
  36 + }
  37 +
  38 + onSearching = true;
  39 + $.ajax({
  40 + method: 'get',
  41 + url: location.protocol + '//m.yohobuy.com/product/sale/search?type=discount&order=1',
  42 + data: {
  43 + yh_channel: channel,
  44 + page: page++,
  45 + isApp: yoho.isApp
  46 + },
  47 + complete: function() {
  48 + onSearching = false;
  49 + },
  50 + success: function(result) {
  51 + let $result = $(result);
  52 +
  53 + let noResult = !result || result.length < 1 || (result.list && result.list.length < 1);
  54 +
  55 + if (noResult) {
  56 + return false;
  57 + }
  58 +
  59 + $container.append($result);
  60 + $goodsContainer.removeClass('hide');
  61 + lazyLoad($result.find('img'));
  62 + }
  63 + });
  64 +};
  65 +
  66 +/**
  67 + * 当scroll到1/2$goodsContainer高度后继续请求下一页数据
  68 + */
  69 +const scrollHandler = function() {
  70 + if ($(window).scrollTop() > $goodsContainer.height() * 0.6) {
  71 + loadGoodsList();
  72 + }
  73 +};
  74 +
  75 +/**
  76 + * 滚动加载
  77 + */
  78 +$(window).scroll(function() {
  79 + setTimeout(function() {
  80 + let afterScroll = document.body.scrollTop;
  81 +
  82 + if (afterScroll - beforeScroll > 0) {
  83 + window.requestAnimationFrame(scrollHandler);
  84 + beforeScroll = afterScroll;
  85 + } else {
  86 + return false;
  87 + }
  88 + }, 5);
  89 +});
  90 +
  91 +$(function() {
  92 + loadGoodsList();
  93 +});
@@ -4,8 +4,9 @@ @@ -4,8 +4,9 @@
4 .tips { 4 .tips {
5 font-size: 24px; 5 font-size: 24px;
6 line-height: 1.4; 6 line-height: 1.4;
7 - color: #b0b0b0;  
8 - padding: 30px 30px 185px; 7 + color: #666;
  8 + padding: 30px;
  9 + background-color: #fff;
9 10
10 h5 { 11 h5 {
11 font-size: 25px; 12 font-size: 25px;