|
@@ -4,6 +4,32 @@ const api = global.yoho.API; |
|
@@ -4,6 +4,32 @@ const api = global.yoho.API; |
4
|
const prettyFilter = require(`${global.utils}/beautify/filters`);
|
4
|
const prettyFilter = require(`${global.utils}/beautify/filters`);
|
5
|
const processProductList = require(`${global.utils}/beautify/product`);
|
5
|
const processProductList = require(`${global.utils}/beautify/product`);
|
6
|
|
6
|
|
|
|
7
|
+// 排序转换
|
|
|
8
|
+const getTypeCont = (type, order) => {
|
|
|
9
|
+ switch (type) {
|
|
|
10
|
+ case 'price':
|
|
|
11
|
+ return order === '0' ? 's_p_desc' : 's_p_asc';
|
|
|
12
|
+ case 'discount':
|
|
|
13
|
+ return order === '0' ? 'p_d_desc' : 'p_d_asc';
|
|
|
14
|
+ case 'sale':
|
|
|
15
|
+ return order === '0' ? 's_n_desc' : 's_n_asc';
|
|
|
16
|
+ case 'newest':
|
|
|
17
|
+ return order === '0' ? 's_t_desc' : 's_t_asc';
|
|
|
18
|
+ case 'stock':
|
|
|
19
|
+ return order === '0' ? 's_s_desc' : 's_s_asc';
|
|
|
20
|
+ case 'all':
|
|
|
21
|
+ return order === '0' ? 'd_s_desc' : 'd_s_asc';
|
|
|
22
|
+ case 'category':
|
|
|
23
|
+ return order === '0' ? 's_t_desc' : 's_t_asc';
|
|
|
24
|
+ case 'new':
|
|
|
25
|
+ return order === '0' ? 's_t_desc' : 's_t_asc';
|
|
|
26
|
+ case 'hot':
|
|
|
27
|
+ return order === '0' ? 's_n_desc' : 's_n_asc';
|
|
|
28
|
+ default:
|
|
|
29
|
+ return order === '0' ? 's_t_desc' : 's_t_asc';
|
|
|
30
|
+ }
|
|
|
31
|
+};
|
|
|
32
|
+
|
7
|
/* 查询最新产品列表 */
|
33
|
/* 查询最新产品列表 */
|
8
|
exports.getNewData = (params) => {
|
34
|
exports.getNewData = (params) => {
|
9
|
if (params.hasOwnProperty('priceRange')) {
|
35
|
if (params.hasOwnProperty('priceRange')) {
|
|
@@ -11,6 +37,12 @@ exports.getNewData = (params) => { |
|
@@ -11,6 +37,12 @@ exports.getNewData = (params) => { |
11
|
delete params.priceRange;
|
37
|
delete params.priceRange;
|
12
|
}
|
38
|
}
|
13
|
|
39
|
|
|
|
40
|
+ if (params.order) {
|
|
|
41
|
+ params.order = getTypeCont(params.type || '', params.order);
|
|
|
42
|
+ } else {
|
|
|
43
|
+ params.order = 's_t_asc';
|
|
|
44
|
+ }
|
|
|
45
|
+
|
14
|
params = Object.assign({
|
46
|
params = Object.assign({
|
15
|
method: 'app.search.newProduct',
|
47
|
method: 'app.search.newProduct',
|
16
|
}, params);
|
48
|
}, params);
|