Favorite.js 1.46 KB
/**
 * 我的优惠券 controller
 * @author: weiqingting<qingting.wei@yoho.cn>
 * @date: 2016/05/16
 */
'use strict';
const Promise = require('bluebird');
const co = Promise.coroutine;
const helpers = global.yoho.helpers;

const favoriteService = require('../models/favorite-service');

const index = (req, res, next)=> {
    let uid = '8041246';
    let udid = '8041246';

    co(function*() {
        let page = req.query.page || 1;
        let type = req.query.type || 'article';
        let sort = req.query.sort_id || 0;
        let reduction = req.query.is_reduction || 'N';
        let promotion = req.query.is_promotion || 'N';
        let limit = 10;
        let data = {};

        data.tabs = favoriteService.getFavoriteTabs('product');

        switch (type) {
            case 'brand':
                data.favBrands = yield favoriteService.favoriteBrandList(uid, page, limit, type);

                break;
            case 'article':
                data.favArticles = yield favoriteService.favoriteArticleListAsync(uid, udid, page, limit);

                break;
            default:
                data.favProducts = yield favoriteService.favoriteProductList(uid, page, limit, type, sort, 'N', reduction, promotion);

                break;
        }
        console.log(data);
        res.render('favorite', {
            meFavoritePage: true,
            meFavorite: data
        });
    })().then(next);
};

const reductionAction = ()=> {

};

module.exports = {
    index
};