search-process.js
2.94 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/**
* 搜索相关数据处理
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/7/29
*/
const _getGender = {
'1,3': '男生',
'2,3': '女生',
'1,2,3': '',
};
/**
* 根据频道判断出性别
*/
const getGenderByChannel = (channel) => {
channel = channel ? channel : 'boys';
switch (channel) {
case 'boys': // 男
return '1,3';
case 'girls': // 女
return '2,3';
default: // 其它
return '1,2,3';
}
};
// 频道转换
const getChannelType = (channel) => {
channel = channel ? channel : 'boys';
switch (channel) {
case 'boys': // 男
return '1';
case 'girls': // 女
return '2';
case 'kids': // 童装
return '3';
case 'lifestyle': // 创意生活
return '4';
default: // all
return '1,2,3,4';
}
};
// 排序转换
const getTypeCont = (type, order) => {
switch (type) {
case 'price':
return order === '0' ? 's_p_desc' : 's_p_asc';
case 'discount':
return order === '0' ? 'p_d_desc' : 'p_d_asc';
case 'sale':
return order === '0' ? 's_n_desc' : 's_n_asc';
case 'newest':
return order === '0' ? 's_t_desc' : 's_t_asc';
case 'stock':
return order === '0' ? 's_s_desc' : 's_s_asc';
case 'all':
return order === '0' ? 'd_s_desc' : 'd_s_asc';
case 'category':
return order === '0' ? 's_t_desc' : 's_t_asc';
case 'new':
return order === '0' ? 's_t_desc' : 's_t_asc';
case 'hot':
return order === '0' ? 's_n_desc' : 's_n_asc';
case 'popularity':
return order === '0' ? 'h_v_desc' : 'h_v_asc';
default:
return order === '0' ? 's_t_desc' : 's_t_asc';
}
};
/**
* 品类列表页 SEO 数据
* @param {*} gender
* @param {*} sort_name
*/
const getListSeoData = (gender, sort_name) => {
let seoData = {
title: '潮流服装配饰,创意生活用品_男生|女生|潮童服装,鞋履,配饰品牌正品-YOHO!BUY有货',
keywords: '潮流服装配饰,创意生活用品,男生服装配饰,女生服装配饰,潮童服装配饰',
description: '潮流服装配饰及创意生活正品网购!YOHO!BUY有货提供男生、女生、潮童服装配饰。100%品牌正品保证,支持货到付款。'
};
if (gender && sort_name) {
seoData = {
title: `${sort_name}|新款${sort_name}${_getGender[gender]}|品牌正品|YOHO!BUY有货`,
keywords: `新款${sort_name},${_getGender[gender]}${sort_name},品牌正品`,
description: `正品网购!YOHO!BUY有货提供新款${sort_name}${_getGender[gender]}${sort_name}100%品牌正品保证,支持货到付款。`
};
}
return seoData;
};
module.exports = {
getGenderByChannel,
getChannelType,
getTypeCont,
getListSeoData
};