Authored by biao

update for set cookie

1 const model = require('../models'); 1 const model = require('../models');
  2 +const Cookies = require( "cookies" );
2 3
3 exports.index = (req, res) => { 4 exports.index = (req, res) => {
4 const channelType = req.path.substring(1) || 'men'; 5 const channelType = req.path.substring(1) || 'men';
5 6
6 model.getContent(channelType).then(result => { 7 model.getContent(channelType).then(result => {
  8 + const cookies = new Cookies(req, res);
  9 +
  10 + cookies.set('_Channel', channelType);
  11 +
7 res.display('index', Object.assign({ 12 res.display('index', Object.assign({
8 module: 'channel', 13 module: 'channel',
9 page: 'home', 14 page: 'home',
@@ -37,6 +37,7 @@ @@ -37,6 +37,7 @@
37 "connect-memcached": "^0.2.0", 37 "connect-memcached": "^0.2.0",
38 "connect-multiparty": "^2.0.0", 38 "connect-multiparty": "^2.0.0",
39 "cookie-parser": "^1.4.3", 39 "cookie-parser": "^1.4.3",
  40 + "cookies": "^0.6.1",
40 "express": "^4.13.1", 41 "express": "^4.13.1",
41 "express-handlebars": "^3.0.0", 42 "express-handlebars": "^3.0.0",
42 "express-session": "^1.13.0", 43 "express-session": "^1.13.0",
@@ -6,8 +6,6 @@ @@ -6,8 +6,6 @@
6 6
7 var lazyLoad = require('yoho-jquery-lazyload'); 7 var lazyLoad = require('yoho-jquery-lazyload');
8 8
9 -var homePage = $('.home-page').data('page');  
10 -  
11 require('../common/header'); 9 require('../common/header');
12 require('../common/return-top'); 10 require('../common/return-top');
13 require('../plugins/slider'); 11 require('../plugins/slider');
@@ -27,11 +25,3 @@ $('.card').mouseenter(function() { @@ -27,11 +25,3 @@ $('.card').mouseenter(function() {
27 $this.addClass('active'); 25 $this.addClass('active');
28 }); 26 });
29 27
30 -  
31 -if ($.inArray(homePage, ['men', 'women', 'lifestyle']) > -1) {  
32 - window.setCookie('_Channel', homePage, {  
33 - domain: '.yohoblk.com',  
34 - path: '/',  
35 - expires: 365  
36 - });  
37 -}