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

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

exports.userCenter = (req, res, next) => {
    var udid = req.cookies.udid,
        uid = req.user.uid || 0,
        yhChannel = req.query.yh_channel || '1',
        limit = 30,
        client_id = req.cookies._yasvd || '';

    req.ctx(recommendForYouModel).getPreference({
        yh_channel: yhChannel,
        udid: udid,
        limit: limit,
        rec_pos: '100004',
        uid: uid,
        client_id: client_id,
    }).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) => {
    let udid = req.cookies.udid,
        uid = req.user.uid || 0,
        yhChannel = req.query.yh_channel || '1',
        limit = 30,
        client_id = req.cookies._yasvd || '';

    if (_.get(req, 'app.locals.wap.cart.removePrefer', false)) {
        return res.send('');
    }
    req.ctx(recommendForYouModel).getPreference({
        yh_channel: yhChannel,
        udid: udid,
        limit: limit,
        rec_pos: '100003',
        uid: uid,
        client_id: client_id
    }).then((preferenceData) => {

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

};