recom.js
1.61 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
'use strict';
const mayLikeModel = require('../models/recom');
let yhChannel = {
boys: 1,
girl: 2,
kids: 3
};
/**
* 你可能喜欢的BOYS或GIRLS的商品列表
*/
const mayLike = (req, res, next) => {
let uid = req.user.uid;
let page = req.query.page || 1;
let limit = 50;
let gender = req.query.gender;
let udid = req.cookies.udid || 'yoho';
let recPos = req.query.rec_pos || 100001;
let channel = req.cookies._Channel && yhChannel[req.cookies._Channel] || 1;
let client_id = req.cookies._yasvd || '';
return mayLikeModel.mayLike(uid, page, limit, gender, udid, recPos, channel, client_id).then((result) => {
res.render('recom/maybe-like', Object.assign({
layout: false,
goods: result
}, result));
}).catch(next);
};
/**
* 你可能喜欢的潮童的商品列表
*/
const mayLikeKids = (req, res, next) => {
let page = req.query.page || 1;
let limit = 50;
let channel = req.query.channel || 3;
mayLikeModel.mayLikeKids(page, limit, channel).then((result) => {
res.render('recom/maybe-like', {
layout: false,
goods: result
});
}).catch(next);
};
const mayLikelife = (req, res, next) => {
let page = req.query.page || 1;
let limit = 50;
if (page > 1) {
return;
}
mayLikeModel.mayLikelife(page, limit).then((result) => {
res.render('recom/maybe-like-lifestyle', {
layout: false,
goodsContainer: result.goodsContainer
});
}).catch(next);
};
module.exports = {
mayLike,
mayLikeKids,
mayLikelife
};