recom.js 1.47 KB
'use strict';

const mRoot = '../models';
const headerModel = require('../../../doraemon/models/header'); // 头部model
const mayLikeModel = require('../models/recom');

/**
* 你可能喜欢的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.sessionID || 'yoho';
    let recPos = 100009;
    let channel = req.query.channel || 1;

    if (channel === 1 || channel === 2) {
        return mayLikeModel.mayLike(uid, page, limit, gender, udid, recPos, channel).then((result) => {

            res.render('recom/maybe-like', Object.assign({
                layout: false,
                goods: result
            }, result));
        }).catch(next);
    }

    recPos = 100001;

    mayLikeModel.mayLike(uid, page, limit, gender, udid, recPos, channel).then((result) => {
        res.render('recom/maybe-like', {
            layout: false,
            goods: result
        });
    }).catch(next);
};

/**
* 你可能喜欢的潮童的商品列表
*/
const mayLikeKids = (req, res, next) => {
    let page = req.body.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);
};

module.exports = {
    mayLike,
    mayLikeKids
};