recom.js
2.62 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
103
104
105
106
'use strict';
const api = global.yoho.API;
const logger = global.yoho.logger;
const utils = '../../../utils';
const productProcess = require(`${utils}/product-process`);
const mayLike = (uid, page, limit, gender, udid, recPos, channel) => {
return api.get('', {
method: 'app.search.newLast7day',
uid: uid,
page: page,
limit: limit,
udid: udid,
rec_pos: recPos,
yh_channel: channel,
gender: gender
}).then((result) => {
if (result && result.code === 200) {
if (result.data.page_total && page <= result.data.page_total) {
if (result.data.product_list) {
return productProcess.processProductList(result.data.product_list);
} else {
return false;
}
}
} else {
logger.error('mayLike code no 200');
}
});
};
const mayLikeKids = (page, limit, channel) => {
return api.get('', {
method: 'app.search.kids',
page: page,
limit: limit,
yh_channel: channel
}).then((result) => {
if (result && result.code === 200) {
if (page > result.data.page_total) {
return;
}
if (result.data.product_list) {
return productProcess.processProductList(result.data.product_list);
}
} else {
logger.error('mayLikeKids code no 200');
}
});
};
const mayLikelife = (page, limit, channel) => {
return api.get('', {
method: 'app.search.lifeStyle',
page: page,
limit: limit,
yh_channel: '4'
}).then((result) => {
if (result && result.code === 200) {
let formData = {
goodsContainer: []
};
if (result.data.product_list.top) {
let build = {};
build.show = true;
build.goods = productProcess.processProductList(result.data.product_list.top, {showTags: false});
formData.goodsContainer.push(build);
}
if (result.data.product_list.top) {
let build = {};
build.show = true;
build.goods = productProcess.processProductList(result.data.product_list.new, {showTags: false});
formData.goodsContainer.push(build);
}
// console.log(formData)
return formData;
} else {
logger.error('mayLikelife code no 200');
}
});
};
module.exports = {
mayLike,
mayLikeKids,
mayLikelife
};