Favorite.js 1.26 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 FavoriteModel=require('../models/FavoriteModel');

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,data={};
        data.tabs= FavoriteModel.getFavoriteTabs(type);

        switch(type){
            case 'brand':data.favBrands=yield FavoriteModel.favoriteBrandList(uid,page,limit,type);break;
            case 'article':data.favArticles=yield FavoriteModel.favoriteArticleList(uid,udid,page,limit,type);break;
            default:data.favProducts= yield FavoriteModel.favoriteProductList(uid,page,limit,type,sort,'N',reduction,promotion);break;
        }
        console.log(data);
        res.render("favorite",{
            meFavoritePage:true,
            meFavorite:data
        });
    })();
}

const reductionAction=()=>{

}

module.exports ={
    index
}