coupons.js
1.15 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
// 优惠券 by acgpiano
'use strict';
const headerModel = require('../../../doraemon/models/header'), // 头部model
model = require('../models/coupons');
// status为使用状态
const index = (req, res, next) => {
req.ctx(model).couponData({
method: 'app.coupons.li',
uid: req.user.uid,
status: req.body.status || 0,
page: req.body.page || 1,
limit: 10,
}).then(result => {
let options = {
module: 'home',
page: 'coupons',
pageHeader: headerModel.setNav({
navTitle: '优惠券'
}),
title: '优惠券',
pageFooter: true,
list: result,
localCss: true
};
res.render('coupons', options);
}).catch(next);
};
const couponsAjax = (req, res, next) => {
req.ctx(model).couponData({
method: 'app.coupons.li',
uid: req.user.uid,
status: parseInt(req.body.status || 0, 10),
page: parseInt(req.body.page || 1, 10),
limit: 10,
}).then(result => {
res.json(result);
}).catch(next);
};
module.exports = {
index,
couponsAjax
};