|
|
'use strict';
|
|
|
|
|
|
const mRoot = '../models';
|
|
|
const headerModel = require('../../../doraemon/models/header'); // 头部model
|
|
|
// const mRoot = '../models';
|
|
|
// const headerModel = require('../../../doraemon/models/header'); // 头部model
|
|
|
const mayLikeModel = require('../models/recom');
|
|
|
|
|
|
let genders = {
|
|
|
boys: '1,3',
|
|
|
girl: '2,3'
|
|
|
};
|
|
|
|
|
|
let channels = {
|
|
|
boys: 1,
|
|
|
girl: 2,
|
|
|
kids: 3,
|
|
|
lifestyle: 4
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 你可能喜欢的BOYS或GIRLS的商品列表
|
|
|
* 你可能喜欢的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 gender = req.query.gender || req.cookies._Channel && genders[req.cookies._Channel] || '1,3';
|
|
|
let udid = req.sessionID || 'yoho';
|
|
|
let recPos = 100009;
|
|
|
let channel = req.query.channel || 1;
|
|
|
let channel = req.query.channel || req.cookies._Channel && channels[req.cookies._Channel] || 1;
|
|
|
|
|
|
if (channel === 1 || channel === 2) {
|
|
|
mayLikeModel.mayLike(uid, page, limit, gender, udid, recPos, channel).then((result) => {
|
|
|
|
|
|
res.render('recom/goods', Object.assign({
|
|
|
layout: false
|
|
|
}, result));
|
|
|
res.render('recom/goods', {
|
|
|
layout: false,
|
|
|
list: result
|
|
|
});
|
|
|
|
|
|
}).catch(next);
|
|
|
} else if (channel === 4) {
|
|
|
|
|
|
recPos = 100001;
|
|
|
gender = '1,3';
|
|
|
|
|
|
mayLikeModel.mayLike(uid, page, limit, gender, udid, recPos, channel).then((result) => {
|
|
|
res.render('recom/goods', Object.assign({
|
|
|
layout: false
|
|
|
}, result));
|
|
|
res.render('recom/goods', {
|
|
|
layout: false,
|
|
|
list: result
|
|
|
});
|
|
|
}).catch(next);
|
|
|
}
|
|
|
};
|
...
|
...
|
@@ -41,13 +58,14 @@ const mayLike = (req, res, next) => { |
|
|
const mayLikeKids = (req, res, next) => {
|
|
|
let page = req.body.page || 1;
|
|
|
let limit = 50;
|
|
|
let channel = req.query.channel || 3;
|
|
|
let channel = req.query.channel || req.cookies._Channel && channels[req.cookies._Channel] || 3;
|
|
|
|
|
|
mayLikeModel.mayLikeKids(page, limit, channel).then((result) => {
|
|
|
|
|
|
res.render('recom/goods', Object.assign({
|
|
|
layout: false
|
|
|
}, result));
|
|
|
res.render('recom/goods', {
|
|
|
layout: false,
|
|
|
list: result
|
|
|
});
|
|
|
}).catch(next);
|
|
|
};
|
|
|
|
...
|
...
|
|