...
|
...
|
@@ -6,6 +6,7 @@ const co = Promise.coroutine; |
|
|
|
|
|
let CouponsModel = require('../models/CouponsModel');
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const setPager = require(`${global.utils}/pager`).setPager;
|
|
|
|
|
|
|
|
|
const index = (req, res)=>{
|
...
|
...
|
@@ -19,14 +20,6 @@ const index = (req, res)=>{ |
|
|
|
|
|
let data = {};
|
|
|
|
|
|
data.pager = {
|
|
|
hasCheckAll: false,
|
|
|
count: coupons.pager.total || 0,
|
|
|
curPage: coupons.pager.page || 0,
|
|
|
totalPages: coupons.pager.pageTotal || 0
|
|
|
|
|
|
// pagerHtml:
|
|
|
};
|
|
|
if (type === CouponsModel.UNUSED) {
|
|
|
if (!coupons.list.length) {
|
|
|
data.unUseCoupons = {empty: '您没有优惠券'};
|
...
|
...
|
@@ -67,6 +60,23 @@ const index = (req, res)=>{ |
|
|
name: '已失效优惠券'
|
|
|
}
|
|
|
];
|
|
|
|
|
|
if (coupons.list.length !== 0) {
|
|
|
data.pager = {
|
|
|
hasCheckAll: false,
|
|
|
count: coupons.pager.total || 0,
|
|
|
curPage: coupons.pager.page || 0,
|
|
|
totalPages: coupons.pager.pageTotal || 0
|
|
|
};
|
|
|
|
|
|
if (data.pager.totalPages > 1) {
|
|
|
Object.assign(data.pager, setPager(data.pager.totalPages, {
|
|
|
type: type,
|
|
|
page: data.pager.curPage
|
|
|
}));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
res.render('coupons', data);
|
|
|
})();
|
|
|
};
|
...
|
...
|
|