Authored by 梁志锋

update

framework @ 119c247f
1 -Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2 1 +Subproject commit 119c247f5cf929aa1e059e40609bb16dd6b58f05
@@ -22,6 +22,37 @@ function cookie(name) { @@ -22,6 +22,37 @@ function cookie(name) {
22 return cookieVal; 22 return cookieVal;
23 } 23 }
24 24
  25 +function setCookie(name, value, options) {
  26 + var expires = '',
  27 + path,
  28 + domain,
  29 + secure,
  30 + date;
  31 +
  32 + if (typeof value !== 'undefined') {
  33 + options = options || {};
  34 + if (value === null) {
  35 + value = '';
  36 + options.expires = -1;
  37 + }
  38 +
  39 + if (options.expires &&
  40 + (typeof options.expires === 'number' || options.expires.toUTCString)) {
  41 + if (typeof options.expires === 'number') {
  42 + date = new Date();
  43 + date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
  44 + } else {
  45 + date = options.expires;
  46 + }
  47 + expires = '; expires=' + date.toUTCString();
  48 + }
  49 + path = options.path ? '; path=' + options.path : '';
  50 + domain = options.domain ? '; domain=' + options.domain : '';
  51 + secure = options.secure ? '; secure' : '';
  52 + document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
  53 + }
  54 +}
  55 +
25 function getUser() { 56 function getUser() {
26 var c = cookie('_UID'), 57 var c = cookie('_UID'),
27 user; 58 user;
@@ -60,7 +91,7 @@ function getShoppingKey() { @@ -60,7 +91,7 @@ function getShoppingKey() {
60 } 91 }
61 92
62 //页面通用底部位置及status设置 93 //页面通用底部位置及status设置
63 -(function() { 94 +(function () {
64 var $footer = $('#yoho-footer'), 95 var $footer = $('#yoho-footer'),
65 $op = $footer.children('.op-row'); 96 $op = $footer.children('.op-row');
66 97
@@ -94,8 +125,10 @@ function getShoppingKey() { @@ -94,8 +125,10 @@ function getShoppingKey() {
94 //暴露公共接口 125 //暴露公共接口
95 window.cookie = cookie; 126 window.cookie = cookie;
96 127
  128 +window.setCookie = setCookie;
  129 +
97 window.getUser = getUser; 130 window.getUser = getUser;
98 131
99 window.getUid = getUid; 132 window.getUid = getUid;
100 133
101 -window.getShoppingKey = getShoppingKey;  
  134 +window.getShoppingKey = getShoppingKey;
@@ -28,7 +28,7 @@ lazyLoad($('img.lazy')); @@ -28,7 +28,7 @@ lazyLoad($('img.lazy'));
28 //$('img:in-viewport').trigger('appear'); 28 //$('img:in-viewport').trigger('appear');
29 29
30 //点击首页汉堡menu图标,滑出侧栏导航 30 //点击首页汉堡menu图标,滑出侧栏导航
31 -$('.nav-btn').on('click', function (event) { 31 +$('.nav-btn').on('tap', function (event) {
32 if (!$(this).hasClass('menu-open')) { 32 if (!$(this).hasClass('menu-open')) {
33 $('.mobile-wrap').addClass('menu-open'); 33 $('.mobile-wrap').addClass('menu-open');
34 $('.overlay').addClass('show'); 34 $('.overlay').addClass('show');
@@ -45,7 +45,7 @@ $('.nav-btn').on('click', function (event) { @@ -45,7 +45,7 @@ $('.nav-btn').on('click', function (event) {
45 }); 45 });
46 46
47 //点击页面主体,收起侧栏导航及二级导航 47 //点击页面主体,收起侧栏导航及二级导航
48 -$('.mobile-wrap').on('click', function () { 48 +$('.mobile-wrap').on('tap', function () {
49 if ($(this).hasClass('menu-open')) { 49 if ($(this).hasClass('menu-open')) {
50 $('.mobile-wrap').removeClass('menu-open'); 50 $('.mobile-wrap').removeClass('menu-open');
51 $('.overlay').removeClass('show'); 51 $('.overlay').removeClass('show');
@@ -59,7 +59,7 @@ $('.mobile-wrap').on('click', function () { @@ -59,7 +59,7 @@ $('.mobile-wrap').on('click', function () {
59 }); 59 });
60 60
61 //点击一级导航,弹出二级导航 61 //点击一级导航,弹出二级导航
62 -$('.side-nav').on('click', 'li', function () { 62 +$('.side-nav').on('tap', 'li', function () {
63 if ($(this).find('.sub-nav').size() > 0) { 63 if ($(this).find('.sub-nav').size() > 0) {
64 $('.sub-nav').removeClass('show'); 64 $('.sub-nav').removeClass('show');
65 $(this).find('.sub-nav').addClass('show'); 65 $(this).find('.sub-nav').addClass('show');
@@ -68,7 +68,7 @@ $('.side-nav').on('click', 'li', function () { @@ -68,7 +68,7 @@ $('.side-nav').on('click', 'li', function () {
68 68
69 //返回一级导航,收起二级导航 69 //返回一级导航,收起二级导航
70 $('.sub-nav').each(function () { 70 $('.sub-nav').each(function () {
71 - $(this).find('li').eq(0).on('click', function (e) { 71 + $(this).find('li').eq(0).on('tap', function (e) {
72 $('.sub-nav').removeClass('show'); 72 $('.sub-nav').removeClass('show');
73 e.stopPropagation(); 73 e.stopPropagation();
74 }); 74 });
@@ -84,6 +84,7 @@ $('.sub-nav').on('mouseenter', 'li', function () { @@ -84,6 +84,7 @@ $('.sub-nav').on('mouseenter', 'li', function () {
84 //头部banner轮播 84 //头部banner轮播
85 if ($('.banner-swiper').find('li').size() > 1) { 85 if ($('.banner-swiper').find('li').size() > 1) {
86 bannerSwiper = new Swiper('.banner-swiper', { 86 bannerSwiper = new Swiper('.banner-swiper', {
  87 + lazyLoading: true,
87 loop: true, 88 loop: true,
88 autoplay: 3000, 89 autoplay: 3000,
89 autoplayDisableOnInteraction: false, 90 autoplayDisableOnInteraction: false,
@@ -137,15 +138,8 @@ $('.category-swiper').each(function (i, index) { @@ -137,15 +138,8 @@ $('.category-swiper').each(function (i, index) {
137 } 138 }
138 }); 139 });
139 140
140 -  
141 -//回到顶部  
142 -// $('.back-to-top').bind('touchstart', function (e) {  
143 -// e.preventDefault();  
144 -// $(window).scrollTop(0);  
145 -// });  
146 -  
147 //关闭头部下载浮层 141 //关闭头部下载浮层
148 -$('.header-download').on('click', '.close-btn', function () { 142 +$('.header-download').on('tap', '.close-btn', function () {
149 $(this).parent().remove(); 143 $(this).parent().remove();
150 }); 144 });
151 145
@@ -34,7 +34,7 @@ if (kidsType) { @@ -34,7 +34,7 @@ if (kidsType) {
34 34
35 $curNav = $navList.children('.focus'); 35 $curNav = $navList.children('.focus');
36 36
37 -$('#maybe-like-nav').delegate('li', 'touchstart', function() { 37 +$('#maybe-like-nav').delegate('li', 'tap', function() {
38 var $this = $(this), 38 var $this = $(this),
39 $goods = $('.goods-list'), 39 $goods = $('.goods-list'),
40 $content; 40 $content;
  1 +/**
  2 + * 底部JS
  3 + * @author: liangzhifeng<zhifeng.liang@yoho.cn>
  4 + * @date: 2015/10/26
  5 + */
  6 +
  7 +var $ = require('yoho.zepto');
  8 +
  9 +function downLoadApp() {
  10 + var appUrl = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445';
  11 + var clickedAt = new Date();
  12 +
  13 + setTimeout(function () {
  14 + if ((new Date()) - clickedAt < 2000) {
  15 + window.location = appUrl;
  16 + }
  17 + }, 500);
  18 +}
  19 +
  20 +$('#float-layer-close').bind('tap', function () {
  21 + $('#float-layer-app').hide();
  22 + window.setCookie('_float-layer-app', 'id490655927',
  23 + {
  24 + domain: '.yohobuy.com'
  25 + });
  26 + window.setCookie('_float-layer-app-close', 1,
  27 + {
  28 + domain: '.yohobuy.com',
  29 + expires: 1
  30 + });
  31 +});
  32 +
  33 +$('#float-layer-btn').tap(function () {
  34 + downLoadApp('bottom');
  35 +});
  36 +
  37 +if (!window.cookie('_float-layer-app')) {
  38 + $('#float-layer-app').show();
  39 +} else {
  40 + $('#float-layer-app').hide();
  41 +}
  42 +
@@ -5,4 +5,5 @@ @@ -5,4 +5,5 @@
5 */ 5 */
6 6
7 require('./search'); 7 require('./search');
8 -require('./channel');  
  8 +require('./channel');
  9 +require('./footer');
@@ -26,7 +26,7 @@ $pwd.bind('input', function() { @@ -26,7 +26,7 @@ $pwd.bind('input', function() {
26 } 26 }
27 }); 27 });
28 28
29 -$btnOk.on('touchstart', function() { 29 +$btnOk.on('tap', function() {
30 var pwd = trim($pwd.val()), 30 var pwd = trim($pwd.val()),
31 mobileBack = true, 31 mobileBack = true,
32 setting, 32 setting,
@@ -59,6 +59,10 @@ var $listNav = $('#list-nav'), @@ -59,6 +59,10 @@ var $listNav = $('#list-nav'),
59 if ($('.swiper-container .swiper-slide').length > 1) { 59 if ($('.swiper-container .swiper-slide').length > 1) {
60 swiper = new Swiper('.swiper-container', { 60 swiper = new Swiper('.swiper-container', {
61 lazyLoading: true, 61 lazyLoading: true,
  62 + loop: true,
  63 + autoplay: 3000,
  64 + autoplayDisableOnInteraction: false,
  65 + paginationClickable: true,
62 pagination: '.swiper-pagination' 66 pagination: '.swiper-pagination'
63 }); 67 });
64 } 68 }
@@ -216,7 +220,7 @@ filter.registerCbFn(search); @@ -216,7 +220,7 @@ filter.registerCbFn(search);
216 //3.筛选无active时点击展开筛选面板 220 //3.筛选无active时点击展开筛选面板
217 //4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态 221 //4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态
218 //5.当前active为筛选并且点击其他项时,隐藏筛选面板 222 //5.当前active为筛选并且点击其他项时,隐藏筛选面板
219 -$listNav.delegate('li', 'touchstart', function() { 223 +$listNav.delegate('li', 'tap', function() {
220 var $this = $(this), 224 var $this = $(this),
221 nav, 225 nav,
222 navType, 226 navType,
@@ -33,6 +33,10 @@ var defaultOpt = { @@ -33,6 +33,10 @@ var defaultOpt = {
33 p_d: $('#p_d').val() 33 p_d: $('#p_d').val()
34 }; 34 };
35 35
  36 +var now = new Date(),
  37 + month = now.getMonth() + 1,
  38 + date = now.getDate();
  39 +
36 var $listNav = $('#list-nav'), 40 var $listNav = $('#list-nav'),
37 41
38 //导航数据信息 42 //导航数据信息
@@ -59,9 +63,15 @@ var $listNav = $('#list-nav'), @@ -59,9 +63,15 @@ var $listNav = $('#list-nav'),
59 $pgc.addClass('hide'); 63 $pgc.addClass('hide');
60 $dgc.addClass('hide'); 64 $dgc.addClass('hide');
61 65
  66 +$('#today a').text(month + '月' + date + '号');
  67 +
62 if ($('.swiper-container .swiper-slide').length > 1) { 68 if ($('.swiper-container .swiper-slide').length > 1) {
63 swiper = new Swiper('.swiper-container', { 69 swiper = new Swiper('.swiper-container', {
64 lazyLoading: true, 70 lazyLoading: true,
  71 + loop: true,
  72 + autoplay: 3000,
  73 + autoplayDisableOnInteraction: false,
  74 + paginationClickable: true,
65 pagination: '.swiper-pagination' 75 pagination: '.swiper-pagination'
66 }); 76 });
67 } 77 }
@@ -237,7 +247,7 @@ filter.registerCbFn(search); @@ -237,7 +247,7 @@ filter.registerCbFn(search);
237 //3.筛选无active时点击展开筛选面板 247 //3.筛选无active时点击展开筛选面板
238 //4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态 248 //4.筛选有active时点击隐藏筛选面板并恢复点击筛选前active项的active状态
239 //5.当前active为筛选并且点击其他项时,隐藏筛选面板 249 //5.当前active为筛选并且点击其他项时,隐藏筛选面板
240 -$listNav.delegate('li', 'touchstart', function() { 250 +$listNav.delegate('li', 'tap', function() {
241 var $this = $(this), 251 var $this = $(this),
242 nav, 252 nav,
243 navType, 253 navType,
@@ -273,7 +283,7 @@ $listNav.delegate('li', 'touchstart', function() { @@ -273,7 +283,7 @@ $listNav.delegate('li', 'touchstart', function() {
273 nav = navInfo[navType]; 283 nav = navInfo[navType];
274 284
275 if (!($this.hasClass('active'))) { 285 if (!($this.hasClass('active'))) {
276 - 286 +
277 $active = $this.siblings('.active'); 287 $active = $this.siblings('.active');
278 288
279 $pre = $this; //$pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项 289 $pre = $this; //$pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项
  1 +.float-layer {
  2 + height: 44px;
  3 + background: rgba(68, 68, 68, 0.95);
  4 + position: fixed;
  5 + width: 100%;
  6 + bottom: 0;
  7 + left: 0;
  8 + z-index: 9999;
  9 + padding: 10px 0;
  10 +
  11 + .float-layer-left {
  12 + padding-left: 22px;
  13 + overflow: hidden;
  14 + float: left;
  15 +
  16 + img {
  17 + height: 44px;
  18 + float: left;
  19 + margin-right: 10px;
  20 + }
  21 +
  22 + p {
  23 + float: left;
  24 + font-size: 16px;
  25 + height: 44px;
  26 + line-height: 44px;
  27 + color: white;
  28 + }
  29 + }
  30 +
  31 +}
  32 +
  33 +#float-layer-close {
  34 + position: absolute;
  35 + left: 0;
  36 + top: 0;
  37 + width: 50px;
  38 + height: 50px;
  39 +}
  40 +
  41 +#float-layer-btn {
  42 + position: absolute;
  43 + top: 50%;
  44 + right: 15px;
  45 + font-size: 16px;
  46 + padding: 0 10px;
  47 + height: 27px;
  48 + line-height: 27px;
  49 + background: white;
  50 + border-radius: 5px;
  51 + margin-top: -13px;
  52 + -webkit-tap-highlight-color: rgba(0, 0, 0, 0.5);
  53 +}
@@ -39,5 +39,5 @@ @@ -39,5 +39,5 @@
39 39
40 } 40 }
41 41
42 -@import "search"; 42 +@import "search","footer";
43 43
@@ -38,4 +38,5 @@ @@ -38,4 +38,5 @@
38 width: 100%; 38 width: 100%;
39 bottom: 0; 39 bottom: 0;
40 } 40 }
  41 +
41 } 42 }
1 {{> layout/header}} 1 {{> layout/header}}
2 <div class="mobile-wrap boys-wrap yoho-page"> 2 <div class="mobile-wrap boys-wrap yoho-page">
3 -  
4 - {{# headerDownload}}  
5 - {{> home/header_download}}  
6 - {{/ headerDownload}}  
7 -  
8 {{! 首页header}} 3 {{! 首页header}}
9 {{# homeHeader}} 4 {{# homeHeader}}
10 {{> home/home_header}} 5 {{> home/home_header}}
@@ -20,4 +15,5 @@ @@ -20,4 +15,5 @@
20 <div class="overlay"></div> 15 <div class="overlay"></div>
21 </div> 16 </div>
22 {{> home/side_nav}} 17 {{> home/side_nav}}
23 -{{> layout/footer}}  
  18 +{{> layout/footer}}
  19 +{{> layout/download_app}}
1 {{> layout/header}} 1 {{> layout/header}}
2 <div class="mobile-wrap girls-wrap yoho-page"> 2 <div class="mobile-wrap girls-wrap yoho-page">
3 -  
4 - {{# headerDownload}}  
5 - {{> home/header_download}}  
6 - {{/ headerDownload}}  
7 -  
8 - {{! 首页header}} 3 + {{! 首页header}}
9 {{# homeHeader}} 4 {{# homeHeader}}
10 {{> home/home_header}} 5 {{> home/home_header}}
11 {{/ homeHeader}} 6 {{/ homeHeader}}
@@ -14,5 +9,6 @@ @@ -14,5 +9,6 @@
14 9
15 <div class="overlay"></div> 10 <div class="overlay"></div>
16 </div> 11 </div>
17 - {{> home/side_nav}}  
18 -{{> layout/footer}}  
  12 + {{> home/side_nav}}
  13 +{{> layout/footer}}
  14 +{{> layout/download_app}}
@@ -16,4 +16,5 @@ @@ -16,4 +16,5 @@
16 </div> 16 </div>
17 </div> 17 </div>
18 18
19 -{{>layout/footer}}  
  19 +{{>layout/footer}}
  20 +{{> layout/download_app}}
1 {{> layout/header}} 1 {{> layout/header}}
2 2
3 <div class="mobile-wrap kids-wrap yoho-page"> 3 <div class="mobile-wrap kids-wrap yoho-page">
4 - {{! app下载}}  
5 - {{# headerDownload}}  
6 - {{> home/header_download}}  
7 - {{/ headerDownload}}  
8 -  
9 {{! 首页header}} 4 {{! 首页header}}
10 {{# homeHeader}} 5 {{# homeHeader}}
11 {{> home/home_header}} 6 {{> home/home_header}}
@@ -26,4 +21,5 @@ @@ -26,4 +21,5 @@
26 <div class="overlay"></div> 21 <div class="overlay"></div>
27 </div> 22 </div>
28 {{> home/side_nav}} 23 {{> home/side_nav}}
29 -{{> layout/footer}}  
  24 +{{> layout/footer}}
  25 +{{> layout/download_app}}
1 {{> layout/header}} 1 {{> layout/header}}
2 <div class="mobile-wrap lifestyle-wrap yoho-page"> 2 <div class="mobile-wrap lifestyle-wrap yoho-page">
3 - {{! app下载}}  
4 - {{# headerDownload}}  
5 - {{> home/header_download}}  
6 - {{/ headerDownload}}  
7 -  
8 {{! 首页header}} 3 {{! 首页header}}
9 {{# homeHeader}} 4 {{# homeHeader}}
10 {{> home/home_header}} 5 {{> home/home_header}}
@@ -24,4 +19,5 @@ @@ -24,4 +19,5 @@
24 <div class="overlay"></div> 19 <div class="overlay"></div>
25 </div> 20 </div>
26 {{> home/side_nav}} 21 {{> home/side_nav}}
27 -{{> layout/footer}}  
  22 +{{> layout/footer}}
  23 +{{> layout/download_app}}
@@ -5,9 +5,8 @@ @@ -5,9 +5,8 @@
5 {{/ headerBanner}} 5 {{/ headerBanner}}
6 6
7 <ul id="list-nav" class="list-nav clearfix"> 7 <ul id="list-nav" class="list-nav clearfix">
8 - <li class="today active">  
9 - <a href="javascript:void(0);">  
10 - 1026 8 + <li id="today" class="today active">
  9 + <a href="javascript:void(0);">
11 </a> 10 </a>
12 </li> 11 </li>
13 <li class="week"> 12 <li class="week">
  1 +{{#showDownloadApp}}
  2 +<div class="float-layer hide" id="float-layer-app">
  3 + <div class="float-layer-left">
  4 + <img src="http://static.yohobuy.com/m/v1/img/yohobuy_new.png" alt="">
  5 + <p>新用户首单减10元</p>
  6 + </div>
  7 + <a href="javascript:void(0);" id="float-layer-close" >
  8 + <img src="http://static.yohobuy.com/m/v1/img/close_new.png" width="22">
  9 + </a>
  10 + <a href="http://m.yohobuy.com/download/hyapp" id="float-layer-btn">
  11 + 立即下载
  12 + </a>
  13 +</div>
  14 +{{/showDownloadApp}}
  15 +
  16 +
  17 +
@@ -10,4 +10,6 @@ @@ -10,4 +10,6 @@
10 CopyRight©2007-2016 南京新与力文化传播有限公司 10 CopyRight©2007-2016 南京新与力文化传播有限公司
11 </address> 11 </address>
12 </footer> 12 </footer>
13 -{{/pageFooter}}  
  13 +{{/pageFooter}}
  14 +
  15 +
@@ -85,25 +85,36 @@ @@ -85,25 +85,36 @@
85 </script> 85 </script>
86 {{/if}} 86 {{/if}}
87 87
  88 +{{!-- 频道选择页 --}}
  89 +{{#if channelPage}}
  90 +<script>
  91 + seajs.use('js/index/footer');
  92 +</script>
  93 +{{/if}}
  94 +
88 {{!-- 首页 --}} 95 {{!-- 首页 --}}
89 {{#if grilsHomePage}} 96 {{#if grilsHomePage}}
90 <script> 97 <script>
91 seajs.use('js/home/home'); 98 seajs.use('js/home/home');
  99 + seajs.use('js/index/footer');
92 </script> 100 </script>
93 {{/if}} 101 {{/if}}
94 {{#if boysHomePage}} 102 {{#if boysHomePage}}
95 <script> 103 <script>
96 seajs.use('js/home/home'); 104 seajs.use('js/home/home');
  105 + seajs.use('js/index/footer');
97 </script> 106 </script>
98 {{/if}} 107 {{/if}}
99 {{#if kidsHomePage}} 108 {{#if kidsHomePage}}
100 <script> 109 <script>
101 seajs.use('js/home/home'); 110 seajs.use('js/home/home');
  111 + seajs.use('js/index/footer');
102 </script> 112 </script>
103 {{/if}} 113 {{/if}}
104 {{#if lifestyleHomePage}} 114 {{#if lifestyleHomePage}}
105 <script> 115 <script>
106 seajs.use('js/home/home'); 116 seajs.use('js/home/home');
  117 + seajs.use('js/index/footer');
107 </script> 118 </script>
108 {{/if}} 119 {{/if}}
109 120