Authored by ccbikai

channel 优化

@@ -34,11 +34,7 @@ let _renderData = { @@ -34,11 +34,7 @@ let _renderData = {
34 * @return {[type]} 34 * @return {[type]}
35 */ 35 */
36 let _channelPage = (req, res, data) => { 36 let _channelPage = (req, res, data) => {
37 - res.cookie('_Channel', data.gender, {  
38 - maxAge: 2592000000,  
39 - domain: 'yohobuy.com'  
40 - });  
41 - return channelModel.getChannelData({ // TODO 内部的Promise方法必须 return 出来 37 + return channelModel.getChannelData({
42 gender: data.gender, 38 gender: data.gender,
43 uid: _.toString(req.user.uid) 39 uid: _.toString(req.user.uid)
44 }).then(result => { 40 }).then(result => {
1 <div class="mobile-container"> 1 <div class="mobile-container">
2 - <div class="mobile-wrap {{#if boysHomePage}}boys-wrap{{/if}} {{#if girlsHomePage}}girls-wrap{{/if}} {{#if kidsHomePage}}kids-wrap{{/if}} {{#if lifestyleHomePage}}lifestyle-wrap{{/if}} yoho-page"> 2 + <div class="mobile-wrap {{#if boysHomePage}}boys-wrap{{/if}} {{#if girlsHomePage}}girls-wrap{{/if}} {{#if kidsHomePage}}kids-wrap{{/if}} {{#if lifestyleHomePage}}lifestyle-wrap{{/if}} yoho-page" data-channel="{{gender}}">
3 {{! 首页header}} 3 {{! 首页header}}
4 {{#homeHeader}} 4 {{#homeHeader}}
5 {{> channel/home-header}} 5 {{> channel/home-header}}
1 -/**  
2 - * 首页  
3 - * @author: liangzhifeng<zhifeng.liang@yoho.cn>  
4 - * @date: 2015/10/12  
5 - */  
6 -var $ = require('yoho-jquery'),  
7 - Swiper = require('yoho-swiper'),  
8 - lazyLoad = require('yoho-jquery-lazyload'),  
9 - fastclick = require('yoho-fastclick'),  
10 - noticeScroll = require('../plugin/notice-scroll');  
11 -  
12 -var $mobileWrap = $('.mobile-wrap'),  
13 - $overlay = $('.overlay'),  
14 - $sideNav = $('.side-nav'),  
15 - $subNav = $('.sub-nav'),  
16 - $logotrans = $('.home-header .logo'),  
17 - start = 0,  
18 - swiperClass,  
19 - isen = true;  
20 -  
21 -require('../common');  
22 -fastclick.attach(document.body);  
23 -  
24 -lazyLoad($('img.lazy'));  
25 -noticeScroll('.notice', $('.notice').data('time') * 1000);  
26 -  
27 -$('.nav-btn').on('touchstart', function() {  
28 - $sideNav.css('pointer-events', 'none');  
29 - $mobileWrap.addClass('menu-open');  
30 - $overlay.show().css('opacity', 0.3);  
31 - $sideNav.addClass('on');  
32 -  
33 - setTimeout(function() {  
34 - $sideNav.css('pointer-events', 'auto');  
35 - }, 400);  
36 -  
37 - return false;  
38 -});  
39 -  
40 -function hideSideBar() {  
41 - if ($mobileWrap.hasClass('menu-open')) {  
42 - $mobileWrap.removeClass('menu-open');  
43 - $overlay.hide();  
44 - $('.sub-nav').removeClass('show');  
45 - $sideNav.removeClass('on');  
46 - }  
47 -}  
48 -  
49 -$overlay.on('touchstart', function() {  
50 - hideSideBar();  
51 - return false;  
52 -});  
53 -  
54 -$sideNav.on('touchmove scroll', function() {  
55 - return false;  
56 -});  
57 -  
58 -// 点击一级导航,弹出二级导航  
59 -$sideNav.on('touchend', 'li', function(e) {  
60 - if ($(this).find('.sub-nav').size() > 0) {  
61 - $('.sub-nav').removeClass('show');  
62 - $(this).find('.sub-nav').addClass('show');  
63 - $(this).find('.highlight').removeClass('highlight');  
64 - }  
65 -  
66 - if (e.target.pathname === location.pathname) {  
67 - hideSideBar();  
68 - return false;  
69 - }  
70 -});  
71 -  
72 -// 返回一级导航,收起二级导航  
73 -$subNav.each(function() {  
74 - $(this).find('li').eq(0).on('click', function() {  
75 - $('.sub-nav').removeClass('show');  
76 - return false;  
77 - });  
78 -}).on('touchstart', function(e) {  
79 - if (e.currentTarget !== e.target) {  
80 - $subNav.find('li').removeClass('current');  
81 - }  
82 -});  
83 -  
84 -// 侧边栏点击背景色变化  
85 -function highlight($elem) {  
86 - $elem.find('li').on('touchstart', function() {  
87 - $elem.find('.highlight').removeClass('highlight');  
88 - $(this).addClass('highlight');  
89 - }).on('touchend touchcancel', function() {  
90 - $(this).removeClass('highlight');  
91 - });  
92 -}  
93 -highlight($sideNav);  
94 -highlight($subNav);  
95 -  
96 -  
97 -// 头部banner轮播  
98 -if ($('.banner-swiper').find('li').size() > 1) {  
99 - new Swiper('.banner-swiper', {  
100 - lazyLoading: true,  
101 - lazyLoadingInPrevNext: true,  
102 - loop: true,  
103 - autoplay: 3000,  
104 - autoplayDisableOnInteraction: false,  
105 - paginationClickable: true,  
106 - slideElement: 'li',  
107 - pagination: '.banner-top .pagination-inner'  
108 - });  
109 -}  
110 -  
111 -// 热门品牌滑动  
112 -new Swiper('.brands-swiper', {  
113 - grabCursor: true,  
114 - slidesPerView: 'auto',  
115 - wrapperClass: 'brands-list',  
116 - slideElement: 'li'  
117 -});  
118 -  
119 -// 推荐搭配滑动  
120 -new Swiper('.recommend-swiper', {  
121 - grabCursor: true,  
122 - slidesPerView: 'auto',  
123 - wrapperClass: 'recommend-list',  
124 - slideElement: 'li'  
125 -});  
126 -  
127 -// 潮品话题轮播  
128 -if ($('.trend-topic-swiper').find('li').size() > 1) {  
129 - new Swiper('.trend-topic-swiper', {  
130 - loop: true,  
131 - autoplay: 3000,  
132 - autoplayDisableOnInteraction: false,  
133 - paginationClickable: true,  
134 - slideElement: 'li',  
135 - pagination: '.trend-topic-content .pagination-inner'  
136 - });  
137 -}  
138 -  
139 -// 新人专享轮播  
140 -if ($('.fresh-list-swiper').find('li').size() > 1) {  
141 - new Swiper('.fresh-list-swiper', {  
142 - lazyLoading: true,  
143 - lazyLoadingInPrevNext: true,  
144 - grabCursor: true,  
145 - slidesPerView: 'auto',  
146 - slideElement: 'li',  
147 - watchSlidesVisibility: true  
148 - });  
149 -}  
150 -  
151 -// 潮流上装/经典裤装等轮播  
152 -$('.category-swiper').each(function(i) {  
153 - swiperClass = 'category-swiper' + i;  
154 - $(this).addClass(swiperClass);  
155 - if ($('.' + swiperClass).find('.swiper-slide').size() > 1) {  
156 - new Swiper('.' + swiperClass, {  
157 - loop: true,  
158 - autoplay: 3000,  
159 - autoplayDisableOnInteraction: false,  
160 - paginationClickable: true,  
161 - slideElement: 'li',  
162 - pagination: '.' + swiperClass + ' .pagination-inner'  
163 - });  
164 - }  
165 -});  
166 -  
167 -// logo动画  
168 -function tsAnimate() {  
169 - start = start + 10;  
170 - $logotrans.css({  
171 - transform: 'rotateX(' + start + 'deg)',  
172 - '-webkit-transform': 'rotateX(' + start + 'deg)',  
173 - '-moz-transform': 'rotateX(' + start + 'deg)'  
174 - });  
175 - if (start / 90 % 2 === 1) {  
176 - if (isen) {  
177 - $logotrans.addClass('animate');  
178 - isen = false;  
179 - } else {  
180 - $logotrans.removeClass('animate');  
181 - isen = true;  
182 - }  
183 - }  
184 - if (start / 90 % 2 === 0 && start % 360 !== 0) {  
185 - window.setTimeout(tsAnimate, 3000);  
186 - } else {  
187 - if (start % 360 === 0) {  
188 - window.setTimeout(tsAnimate, 60 * 1000);  
189 - } else {  
190 - window.requestAnimationFrame(tsAnimate);  
191 - }  
192 - }  
193 -}  
194 -  
195 -setTimeout(tsAnimate, 3000);  
196 -  
197 -$('.home-header .iconfont').on('touchstart', function() {  
198 - $(this).addClass('highlight');  
199 -}).on('touchend touchcancel', function() {  
200 - $(this).removeClass('highlight');  
201 -});  
202 -  
203 -// 底部留出tab 的高度  
204 -window.reMarginFooter('.footer-tab');  
205 -  
206 -require('./maybe-like')();  
1 -require('./home'); 1 +/**
  2 + * 首页
  3 + * @author: liangzhifeng<zhifeng.liang@yoho.cn>
  4 + * @date: 2015/10/12
  5 + */
  6 +var $ = require('yoho-jquery'),
  7 + Swiper = require('yoho-swiper'),
  8 + lazyLoad = require('yoho-jquery-lazyload'),
  9 + fastclick = require('yoho-fastclick'),
  10 + noticeScroll = require('../plugin/notice-scroll');
  11 +
  12 +var $mobileWrap = $('.mobile-wrap'),
  13 + $overlay = $('.overlay'),
  14 + $sideNav = $('.side-nav'),
  15 + $subNav = $('.sub-nav'),
  16 + $logotrans = $('.home-header .logo'),
  17 + start = 0,
  18 + swiperClass,
  19 + isen = true;
  20 +
  21 +require('../common');
  22 +fastclick.attach(document.body);
  23 +
  24 +lazyLoad($('img.lazy'));
  25 +noticeScroll('.notice', $('.notice').data('time') * 1000);
  26 +
  27 +$('.nav-btn').on('touchstart', function() {
  28 + $sideNav.css('pointer-events', 'none');
  29 + $mobileWrap.addClass('menu-open');
  30 + $overlay.show().css('opacity', 0.3);
  31 + $sideNav.addClass('on');
  32 +
  33 + setTimeout(function() {
  34 + $sideNav.css('pointer-events', 'auto');
  35 + }, 400);
  36 +
  37 + return false;
  38 +});
  39 +
  40 +function hideSideBar() {
  41 + if ($mobileWrap.hasClass('menu-open')) {
  42 + $mobileWrap.removeClass('menu-open');
  43 + $overlay.hide();
  44 + $('.sub-nav').removeClass('show');
  45 + $sideNav.removeClass('on');
  46 + }
  47 +}
  48 +
  49 +$overlay.on('touchstart', function() {
  50 + hideSideBar();
  51 + return false;
  52 +});
  53 +
  54 +$sideNav.on('touchmove scroll', function() {
  55 + return false;
  56 +});
  57 +
  58 +// 点击一级导航,弹出二级导航
  59 +$sideNav.on('touchend', 'li', function(e) {
  60 + if ($(this).find('.sub-nav').size() > 0) {
  61 + $('.sub-nav').removeClass('show');
  62 + $(this).find('.sub-nav').addClass('show');
  63 + $(this).find('.highlight').removeClass('highlight');
  64 + }
  65 +
  66 + if (e.target.pathname === location.pathname) {
  67 + hideSideBar();
  68 + return false;
  69 + }
  70 +});
  71 +
  72 +// 返回一级导航,收起二级导航
  73 +$subNav.each(function() {
  74 + $(this).find('li').eq(0).on('click', function() {
  75 + $('.sub-nav').removeClass('show');
  76 + return false;
  77 + });
  78 +}).on('touchstart', function(e) {
  79 + if (e.currentTarget !== e.target) {
  80 + $subNav.find('li').removeClass('current');
  81 + }
  82 +});
  83 +
  84 +// 侧边栏点击背景色变化
  85 +function highlight($elem) {
  86 + $elem.find('li').on('touchstart', function() {
  87 + $elem.find('.highlight').removeClass('highlight');
  88 + $(this).addClass('highlight');
  89 + }).on('touchend touchcancel', function() {
  90 + $(this).removeClass('highlight');
  91 + });
  92 +}
  93 +highlight($sideNav);
  94 +highlight($subNav);
  95 +
  96 +
  97 +// 头部banner轮播
  98 +if ($('.banner-swiper').find('li').size() > 1) {
  99 + new Swiper('.banner-swiper', {
  100 + lazyLoading: true,
  101 + lazyLoadingInPrevNext: true,
  102 + loop: true,
  103 + autoplay: 3000,
  104 + autoplayDisableOnInteraction: false,
  105 + paginationClickable: true,
  106 + slideElement: 'li',
  107 + pagination: '.banner-top .pagination-inner'
  108 + });
  109 +}
  110 +
  111 +// 热门品牌滑动
  112 +new Swiper('.brands-swiper', {
  113 + grabCursor: true,
  114 + slidesPerView: 'auto',
  115 + wrapperClass: 'brands-list',
  116 + slideElement: 'li'
  117 +});
  118 +
  119 +// 推荐搭配滑动
  120 +new Swiper('.recommend-swiper', {
  121 + grabCursor: true,
  122 + slidesPerView: 'auto',
  123 + wrapperClass: 'recommend-list',
  124 + slideElement: 'li'
  125 +});
  126 +
  127 +// 潮品话题轮播
  128 +if ($('.trend-topic-swiper').find('li').size() > 1) {
  129 + new Swiper('.trend-topic-swiper', {
  130 + loop: true,
  131 + autoplay: 3000,
  132 + autoplayDisableOnInteraction: false,
  133 + paginationClickable: true,
  134 + slideElement: 'li',
  135 + pagination: '.trend-topic-content .pagination-inner'
  136 + });
  137 +}
  138 +
  139 +// 新人专享轮播
  140 +if ($('.fresh-list-swiper').find('li').size() > 1) {
  141 + new Swiper('.fresh-list-swiper', {
  142 + lazyLoading: true,
  143 + lazyLoadingInPrevNext: true,
  144 + grabCursor: true,
  145 + slidesPerView: 'auto',
  146 + slideElement: 'li',
  147 + watchSlidesVisibility: true
  148 + });
  149 +}
  150 +
  151 +// 潮流上装/经典裤装等轮播
  152 +$('.category-swiper').each(function(i) {
  153 + swiperClass = 'category-swiper' + i;
  154 + $(this).addClass(swiperClass);
  155 + if ($('.' + swiperClass).find('.swiper-slide').size() > 1) {
  156 + new Swiper('.' + swiperClass, {
  157 + loop: true,
  158 + autoplay: 3000,
  159 + autoplayDisableOnInteraction: false,
  160 + paginationClickable: true,
  161 + slideElement: 'li',
  162 + pagination: '.' + swiperClass + ' .pagination-inner'
  163 + });
  164 + }
  165 +});
  166 +
  167 +// logo动画
  168 +function tsAnimate() {
  169 + start = start + 10;
  170 + $logotrans.css({
  171 + transform: 'rotateX(' + start + 'deg)',
  172 + '-webkit-transform': 'rotateX(' + start + 'deg)',
  173 + '-moz-transform': 'rotateX(' + start + 'deg)'
  174 + });
  175 + if (start / 90 % 2 === 1) {
  176 + if (isen) {
  177 + $logotrans.addClass('animate');
  178 + isen = false;
  179 + } else {
  180 + $logotrans.removeClass('animate');
  181 + isen = true;
  182 + }
  183 + }
  184 + if (start / 90 % 2 === 0 && start % 360 !== 0) {
  185 + window.setTimeout(tsAnimate, 3000);
  186 + } else {
  187 + if (start % 360 === 0) {
  188 + window.setTimeout(tsAnimate, 60 * 1000);
  189 + } else {
  190 + window.requestAnimationFrame(tsAnimate);
  191 + }
  192 + }
  193 +}
  194 +
  195 +setTimeout(tsAnimate, 3000);
  196 +
  197 +$('.home-header .iconfont').on('touchstart', function() {
  198 + $(this).addClass('highlight');
  199 +}).on('touchend touchcancel', function() {
  200 + $(this).removeClass('highlight');
  201 +});
  202 +
  203 +// 底部留出tab 的高度
  204 +window.reMarginFooter('.footer-tab');
  205 +
  206 +window.setCookie('_Channel', $mobileWrap.data('channel'), {
  207 + expires: 30,
  208 + domain: '.yohobuy.com'
  209 +});
  210 +
  211 +require('./maybe-like')();