search-process.js
1.84 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
/**
* 搜索相关数据处理
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/7/29
*/
/**
* 根据频道判断出性别
*/
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';
}
};
module.exports = {
getGenderByChannel,
getChannelType,
getTypeCont
};