detail-helper.js 793 Bytes
/**
 * Created by TaoHuang on 2016/6/13.
 */

'use strict';

/* COOKIE标识访问的是男生频道 */
const COOKIE_NAME_BOYS = 'boys';
module.exports.COOKIE_DOMAIN = '.yohobuy.com';

module.exports.setSwitchToCookie = (res) => {
    res.cookie('_Channel', COOKIE_NAME_BOYS, {
        domain: COOKIE_DOMAIN,
        maxAge: moment.duration(300, 'days').seconds()
    });
};

module.exports.getGenderByCookie = (req) => {
    let gender = null;

    let channel = req.cookies._Channel || 'boys';

    switch (channel) {
        case 'boys':
        {
            gender = '1,3';
            break;
        }
        case 'girls':
        {
            gender = '2,3';
            break;
        }
        default:
        {
            gender = '1,2,3';
        }
    }

    return gender;
};