prefer.js 989 Bytes
/**
 * 为你优选
 * @author: shijian
 * @date: 2016/12/6
 */
'use strict';
const preferModel = require('../models/prefer');

const _channel = (channel) => {
    let yhChannel = 1;

    switch (channel) {
        case 'men':
            yhChannel = 1;
            break;
        case 'women':
            yhChannel = 2;
            break;
        case 'lifestyle':
            yhChannel = 4;
            break;
        default:
            break;
    }

    return yhChannel;
};

/**
 * 个人中心主页
 */
const component = {
    index: (req, res) => {
        res.render('prefer', {
            module: 'me',
            page: 'prefer'
        });
    },
    list(req, res, next) {
        let params = {
            yh_channel: _channel(req.query.channel || req.cookies._Channel || 'men'),
            udid: req.sessionID
        };

        preferModel.getlist(params).then((result) => {
            res.json(result);
        }).catch(next);
    }
};

module.exports = component;