Favorite.js
1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* 我的优惠券 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;
}
res.render('favorite', {
meFavoritePage: true,
meFavorite: data
});
})().then(next);
};
const reductionAction = ()=> {
};
module.exports = {
index
};