recommend-for-you.js 1.51 KB
'use strict';

const mRoot = '../models';
const recommendForYouModel = require(`${mRoot}/recommend-for-you`); // 领取优惠券 model
const _ = require('lodash');

exports.userCenter = (req, res, next) => {
    var udid = req.sessionID,
        uid = _.isEmpty(req.user.uid) ? null : req.user.uid,
        yhChannel = req.query.yh_channel || '1',
        limit = 30;

    recommendForYouModel.getPreference({
        yh_channel: yhChannel,
        udid: udid,
        limit: limit,
        rec_pos: '100004',
        uid: uid
    }).then((preferenceData) => {

        if (preferenceData.code === 200) {
            // 获取信息成功
        }
        res.render('recommend-for-you/index', {
            layout: false,
            result: preferenceData,
            module: 'product',
            page: 'recommend'
        });
    }).catch(next);
};

exports.cart = (req, res, next) => {
    var udid = req.sessionID,
        uid = _.isEmpty(req.user.uid) ? null : req.user.uid,
        yhChannel = req.query.yh_channel || '1',
        limit = 30;

    recommendForYouModel.getPreference({
        yh_channel: yhChannel,
        udid: udid,
        limit: limit,
        rec_pos: '100003',
        uid: uid
    }).then((preferenceData) => {

        if (preferenceData.code === 200) {
            // 获取信息成功
        }
        res.render('recommend-for-you/index', {
            layout: false,
            result: preferenceData,
            module: 'product',
            page: 'recommend'
        });
    }).catch(next);
};