Authored by hongweigao

yoho币优惠券分页,修改优惠券参数错误bug

... ... @@ -30,7 +30,6 @@ const index = (req, res, next)=>{
co(function*() {
let data = yield CurrencyModel.currencyData($uid, $condition);
console.info(data.pager);
res.render('currency', {
content: data
});
... ...
... ... @@ -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);
})();
};
... ...
... ... @@ -18,8 +18,8 @@ const getCouponsList = (uid, type, page, limit)=>{
let result = [];
if (!couponsInfo.data.couponList) {
return result;
if (couponsInfo.code !== 200) {
return {list: result};
}
let coupons = couponsInfo.data.couponList;
... ...
... ... @@ -11,11 +11,7 @@ const helpers = global.yoho.helpers;
const _ = require('lodash');
const CurrencyData = require('./CurrencyData');
const SearchData = require('./SearchData');
// 使用 product中的分页逻辑
// const pagerPath = path.join(global.appRoot, '/apps/product/models/public-handler.js');
// const pager = require(pagerPath).handlePagerData;
const setPager = require(`${global.utils}/pager`).setPager;
const moment = require('moment');
... ... @@ -70,8 +66,12 @@ const currencyList = (uid, condition)=>{
result.pager.count = data.data.total;
result.pager.curPage = data.data.page;
result.pager.totalPages = Math.ceil(data.data.total / condition.limit);
// result.pager.pagerHtml = HelperSearch::pager(data.data.total, condition.limit);
if (result.pager.totalPages > 1) {
Object.assign(result.pager, setPager(result.pager.totalPages, {
type: condition.queryType,
page: result.pager.curPage
}));
}
}
return result;
... ...