Authored by 梁志锋

update

framework @ 119c247f
1 -Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2 1 +Subproject commit 119c247f5cf929aa1e059e40609bb16dd6b58f05
@@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
5 */ 5 */
6 6
7 var $ = require('jquery'), 7 var $ = require('jquery'),
  8 + Hammer = require('hammer');
8 Swiper = require('yoho.iswiper'), 9 Swiper = require('yoho.iswiper'),
9 lazyLoad = require('yoho.lazyload'); 10 lazyLoad = require('yoho.lazyload');
10 11
@@ -15,6 +16,8 @@ var searchH = $('.newbrand-search').height(), @@ -15,6 +16,8 @@ var searchH = $('.newbrand-search').height(),
15 headerH = $('.yoho-header').height(), 16 headerH = $('.yoho-header').height(),
16 brandSwipe = parseInt(searchH) + parseInt(headerH); 17 brandSwipe = parseInt(searchH) + parseInt(headerH);
17 18
  19 +var myHammer;
  20 +
18 swiper = new Swiper('.swiper-container', { 21 swiper = new Swiper('.swiper-container', {
19 lazyLoading: true, 22 lazyLoading: true,
20 loop: true, 23 loop: true,
@@ -49,11 +52,19 @@ if ($brandList.length > 0) { @@ -49,11 +52,19 @@ if ($brandList.length > 0) {
49 }); 52 });
50 } 53 }
51 54
52 -$('#right-bar .con').find('b').unbind().on('tap', function() { 55 +// $('#right-bar .con').find('b').unbind().on('tap', function() {
  56 +// var index = $(this).index();
  57 +
  58 +// if ($('.bar-' + index).size() > 0) {
  59 +// document.body.scrollTop = parseInt($('.bar-' + index)[0].offsetTop) - parseInt(brandSwipe - 1);
  60 +// }
  61 +// });
  62 +
  63 +myHammer = new Hammer($('#right-bar .con').find('b').unbind()[0]);
  64 +myHammer.on('tap', function(e) {
53 var index = $(this).index(); 65 var index = $(this).index();
54 66
55 if ($('.bar-' + index).size() > 0) { 67 if ($('.bar-' + index).size() > 0) {
56 document.body.scrollTop = parseInt($('.bar-' + index)[0].offsetTop) - parseInt(brandSwipe - 1); 68 document.body.scrollTop = parseInt($('.bar-' + index)[0].offsetTop) - parseInt(brandSwipe - 1);
57 } 69 }
58 }); 70 });
59 -  
@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 * @date: 2015/10/12 4 * @date: 2015/10/12
5 */ 5 */
6 var $ = require('jquery'), 6 var $ = require('jquery'),
  7 + Hammer = require('hammer'),
7 Swiper = require('yoho.iswiper'), 8 Swiper = require('yoho.iswiper'),
8 lazyLoad = require('yoho.lazyload'), 9 lazyLoad = require('yoho.lazyload'),
9 bannerSwiper, 10 bannerSwiper,
@@ -21,6 +22,8 @@ var requestFrame, @@ -21,6 +22,8 @@ var requestFrame,
21 $logotrans = $('.home-header .logo'), 22 $logotrans = $('.home-header .logo'),
22 isen = true; 23 isen = true;
23 24
  25 +var navHammer, mobileWrapHammer, sideNavHammer;
  26 +
24 require('./maybe-like'); 27 require('./maybe-like');
25 28
26 lazyLoad($('img.lazy')); 29 lazyLoad($('img.lazy'));
@@ -28,7 +31,24 @@ lazyLoad($('img.lazy')); @@ -28,7 +31,24 @@ lazyLoad($('img.lazy'));
28 //$('img:in-viewport').trigger('appear'); 31 //$('img:in-viewport').trigger('appear');
29 32
30 //点击首页汉堡menu图标,滑出侧栏导航 33 //点击首页汉堡menu图标,滑出侧栏导航
31 -$('.nav-btn').on('tap', function (event) { 34 +// $('.nav-btn').on('tap', function (event) {
  35 +// if (!$(this).hasClass('menu-open')) {
  36 +// $('.mobile-wrap').addClass('menu-open');
  37 +// $('.overlay').show().css('opacity', 0.3);
  38 +// $('.side-nav').addClass('on');
  39 +
  40 +// //设置boy高宽,页面不能上下滑动
  41 +// $('body').css({
  42 +// height: $(window).height(),
  43 +// width: '100%',
  44 +// overflow: 'hidden'
  45 +// });
  46 +// }
  47 +// event.stopPropagation();
  48 +// });
  49 +
  50 +navHammer = new Hammer($('.nav-btn')[0]);
  51 +navHammer.on('tap', function(event) {
32 if (!$(this).hasClass('menu-open')) { 52 if (!$(this).hasClass('menu-open')) {
33 $('.mobile-wrap').addClass('menu-open'); 53 $('.mobile-wrap').addClass('menu-open');
34 $('.overlay').show().css('opacity', 0.3); 54 $('.overlay').show().css('opacity', 0.3);
@@ -45,7 +65,24 @@ $('.nav-btn').on('tap', function (event) { @@ -45,7 +65,24 @@ $('.nav-btn').on('tap', function (event) {
45 }); 65 });
46 66
47 //点击页面主体,收起侧栏导航及二级导航 67 //点击页面主体,收起侧栏导航及二级导航
48 -$('.mobile-wrap').on('tap', function () { 68 +// $('.mobile-wrap').on('tap', function () {
  69 +// if ($(this).hasClass('menu-open')) {
  70 +// $('.mobile-wrap').removeClass('menu-open');
  71 +// $('.overlay').css('opacity', 0);
  72 +// $('.sub-nav').removeClass('show');
  73 +// $('.side-nav').removeClass('on');
  74 +// $('body').css({
  75 +// height: 'auto',
  76 +// overflow: 'auto'
  77 +// });
  78 +// setTimeout(function() {
  79 +// $('.overlay').hide();
  80 +// }, 300);
  81 +// }
  82 +// });
  83 +
  84 +mobileWrapHammer = new Hammer($('.mobile-wrap')[0]);
  85 +mobileWrapHammer.on('tap', function(event) {
49 if ($(this).hasClass('menu-open')) { 86 if ($(this).hasClass('menu-open')) {
50 $('.mobile-wrap').removeClass('menu-open'); 87 $('.mobile-wrap').removeClass('menu-open');
51 $('.overlay').css('opacity', 0); 88 $('.overlay').css('opacity', 0);
@@ -62,7 +99,7 @@ $('.mobile-wrap').on('tap', function () { @@ -62,7 +99,7 @@ $('.mobile-wrap').on('tap', function () {
62 }); 99 });
63 100
64 //点击一级导航,弹出二级导航 101 //点击一级导航,弹出二级导航
65 -$('.side-nav').on('tap', 'li', function () { 102 +$('.side-nav').on('touchstart', 'li', function () {
66 if ($(this).find('.sub-nav').size() > 0) { 103 if ($(this).find('.sub-nav').size() > 0) {
67 $('.sub-nav').removeClass('show'); 104 $('.sub-nav').removeClass('show');
68 $(this).find('.sub-nav').addClass('show'); 105 $(this).find('.sub-nav').addClass('show');
@@ -71,7 +108,7 @@ $('.side-nav').on('tap', 'li', function () { @@ -71,7 +108,7 @@ $('.side-nav').on('tap', 'li', function () {
71 108
72 //返回一级导航,收起二级导航 109 //返回一级导航,收起二级导航
73 $('.sub-nav').each(function () { 110 $('.sub-nav').each(function () {
74 - $(this).find('li').eq(0).on('tap', function (e) { 111 + $(this).find('li').eq(0).on('touchstart', function (e) {
75 $('.sub-nav').removeClass('show'); 112 $('.sub-nav').removeClass('show');
76 e.stopPropagation(); 113 e.stopPropagation();
77 }); 114 });
@@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
5 */ 5 */
6 6
7 var $ = require('jquery'), 7 var $ = require('jquery'),
  8 + Hammer = require('hammer'),
8 tip = require('../plugin/tip'), 9 tip = require('../plugin/tip'),
9 lazyLoad = require('yoho.lazyload'); 10 lazyLoad = require('yoho.lazyload');
10 11
@@ -86,9 +87,11 @@ $(window).scroll(function () { @@ -86,9 +87,11 @@ $(window).scroll(function () {
86 type: 'GET', 87 type: 'GET',
87 url: url, 88 url: url,
88 success: function(data) { 89 success: function(data) {
89 - $('#load-more-img').show();  
90 - $('#load-more-img a').attr('url', data[0].banner[0].url);  
91 - $('#load-more-img a > img').attr('src', data[0].banner[0].img); 90 + if (data && data[0] && data[0].banner[0]) {
  91 + $('#load-more-img').show();
  92 + $('#load-more-img a').attr('url', data[0].banner[0].url);
  93 + $('#load-more-img a > img').attr('src', data[0].banner[0].img);
  94 + }
92 }, 95 },
93 error: function() { 96 error: function() {
94 } 97 }
@@ -4,12 +4,15 @@ @@ -4,12 +4,15 @@
4 * @date: 2015/10/26 4 * @date: 2015/10/26
5 */ 5 */
6 6
7 -var $ = require('jquery'); 7 +var $ = require('jquery'),
  8 + Hammer = require('hammer');
8 9
9 var $searchBox = $('.search-box'), 10 var $searchBox = $('.search-box'),
10 $indexSearch = $('.index-search'), 11 $indexSearch = $('.index-search'),
11 $indexLogo = $('.index-logo'); 12 $indexLogo = $('.index-logo');
12 13
  14 +var floatLayerCloseHammer, floatLayerBtnHammer, clearTextHammer, searchIconHammer;
  15 +
13 function downLoadApp() { 16 function downLoadApp() {
14 var appUrl = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445'; 17 var appUrl = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445';
15 var clickedAt = new Date(); 18 var clickedAt = new Date();
@@ -21,7 +24,21 @@ function downLoadApp() { @@ -21,7 +24,21 @@ function downLoadApp() {
21 }, 500); 24 }, 500);
22 } 25 }
23 26
24 -$('#float-layer-close').bind('tap', function () { 27 +// $('#float-layer-close').bind('tap', function () {
  28 +// $('#float-layer-app').hide();
  29 +// window.setCookie('_float-layer-app', 'id490655927',
  30 +// {
  31 +// domain: '.yohobuy.com'
  32 +// });
  33 +// window.setCookie('_float-layer-app-close', 1,
  34 +// {
  35 +// domain: '.yohobuy.com',
  36 +// expires: 1
  37 +// });
  38 +// });
  39 +
  40 +floatLayerCloseHammer = new Hammer($('#float-layer-close')[0]);
  41 +floatLayerCloseHammer.on('tap', function(e) {
25 $('#float-layer-app').hide(); 42 $('#float-layer-app').hide();
26 window.setCookie('_float-layer-app', 'id490655927', 43 window.setCookie('_float-layer-app', 'id490655927',
27 { 44 {
@@ -34,7 +51,12 @@ $('#float-layer-close').bind('tap', function () { @@ -34,7 +51,12 @@ $('#float-layer-close').bind('tap', function () {
34 }); 51 });
35 }); 52 });
36 53
37 -$('#float-layer-btn').tap(function () { 54 +// $('#float-layer-btn').tap(function () {
  55 +// downLoadApp('bottom');
  56 +// });
  57 +
  58 +floatLayerBtnHammer = new Hammer($('#float-layer-btn')[0]);
  59 +floatLayerBtnHammer.on('tap', function(e) {
38 downLoadApp('bottom'); 60 downLoadApp('bottom');
39 }); 61 });
40 62
@@ -76,10 +98,20 @@ $searchBox.find('input').on('focus', function () { @@ -76,10 +98,20 @@ $searchBox.find('input').on('focus', function () {
76 $('.clear-text, .no-search').hide(); 98 $('.clear-text, .no-search').hide();
77 }); 99 });
78 100
79 -$searchBox.find('.clear-text').tap(function () { 101 +$searchBox.find('.clear-text').click(function () {
80 $searchBox.find('input').val('').trigger('focus'); 102 $searchBox.find('input').val('').trigger('focus');
81 }); 103 });
82 104
83 -$searchBox.find('.search-icon').tap(function () { 105 +// clearTextHammer = new Hammer($searchBox.find('.clear-text')[0]);
  106 +// clearTextHammer.on('tap', function(e) {
  107 +// $searchBox.find('input').val('').trigger('focus');
  108 +// });
  109 +
  110 +$searchBox.find('.search-icon').click(function () {
84 $indexSearch.submit(); 111 $indexSearch.submit();
85 -});  
  112 +});
  113 +
  114 +// searchIconHammer = new Hammer($searchBox.find('.search-icon')[0]);
  115 +// searchIconHammer.on('tap', function(e) {
  116 +// $indexSearch.submit();
  117 +// });
@@ -225,7 +225,7 @@ filter.registerCbFn(search); @@ -225,7 +225,7 @@ filter.registerCbFn(search);
225 //3.筛选无active时点击展开筛选面板 225 //3.筛选无active时点击展开筛选面板
226 //4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态 226 //4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态
227 //5.当前active为筛选并且点击其他项时,隐藏筛选面板 227 //5.当前active为筛选并且点击其他项时,隐藏筛选面板
228 -$listNav.delegate('li', 'tap', function() { 228 +$listNav.delegate('li', 'touchstart', function() {
229 var $this = $(this), 229 var $this = $(this),
230 nav, 230 nav,
231 navType, 231 navType,
@@ -252,7 +252,7 @@ filter.registerCbFn(search); @@ -252,7 +252,7 @@ filter.registerCbFn(search);
252 //4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态 252 //4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态
253 //5.当前active为筛选并且点击其他项时,隐藏筛选面板 253 //5.当前active为筛选并且点击其他项时,隐藏筛选面板
254 254
255 -$listNav.delegate('li', 'tap', function() { 255 +$listNav.delegate('li', 'touchstart', function() {
256 var $this = $(this), 256 var $this = $(this),
257 nav, 257 nav,
258 navType, 258 navType,
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 8
9 </div> 9 </div>
10 <div class="load-more-img hide" id="load-more-img"> 10 <div class="load-more-img hide" id="load-more-img">
11 - <a href="">  
12 - <img src="">  
13 - </a> 11 + <a href="">
  12 + <img src="">
  13 + </a>
14 </div> 14 </div>