detail-helper.js
1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* Created by TaoHuang on 2016/6/13.
*/
'use strict';
const moment = require('moment');
/* COOKIE标识访问的是男生频道 */
const COOKIE_NAME_BOYS = 'boys';
const COOKIE_DOMAIN = '.yohobuy.com';
// 商品详情页的默认头像
const DEFAULT_AVATAR_ICO = 'http://static.yohobuy.com/images/v3/boy.jpg';
const IMAGE_SERVICE_URL = 'http://head.static.yhbimg.com/yhb-head/';
const setSwitchToCookie = (res) => {
res.cookie('_Channel', COOKIE_NAME_BOYS, {
domain: COOKIE_DOMAIN,
maxAge: moment.duration(300, 'days').seconds()
});
};
const 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;
};
module.exports = {
COOKIE_NAME_BOYS,
COOKIE_DOMAIN,
DEFAULT_AVATAR_ICO,
IMAGE_SERVICE_URL,
setSwitchToCookie,
getGenderByCookie
};