favorite.js
1.26 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
/**
* 收藏商品、品牌
* @type {Object}
*/
'use strict';
const favModel = require('../models/favorite');
const fav = {
favorite: (req, res) => {
if (req.query.tab === 'brand') {
res.render('favorite-brand', {
module: 'me',
page: 'favorite-brand'
});
} else {
res.render('favorite', {
module: 'me',
page: 'favorite'
});
}
},
favpaging: (req, res, next) => {
const uid = req.user.uid;
const tab = req.query.tab;
const page = req.query.page;
if (tab === 'brand') {
const gender = '1,2,3';
favModel.getFavBrandData(uid, gender, page, 10).then(data => {
return res.json(data);
});
} else {
favModel.getFavProductData(uid, page, 10).then(data => {
return res.json(data);
}).catch(next);
}
},
deletefav: (req, res, next) => {
const uid = req.user.uid;
const favId = req.body.favId;
const type = req.body.type;
favModel.favoriteDelete(uid, favId, type).then(data => {
return res.json(data);
}).catch(next);
}
};
module.exports = fav;