...
|
...
|
@@ -2,7 +2,7 @@ |
|
|
* @Author: Targaryen
|
|
|
* @Date: 2016-06-02 15:50:47
|
|
|
* @Last Modified by: Targaryen
|
|
|
* @Last Modified time: 2016-06-03 16:36:28
|
|
|
* @Last Modified time: 2016-06-03 18:25:57
|
|
|
*/
|
|
|
|
|
|
'use strict';
|
...
|
...
|
@@ -161,3 +161,78 @@ exports.handleSalePagerData = (total, params) => { |
|
|
|
|
|
return dest;
|
|
|
};
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 处理 opts 排序数据 待处理 待确认
|
|
|
* @param {[type]} origin [description]
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
exports.handleSaleOptsData = (params, total) => {
|
|
|
var dest = {};
|
|
|
|
|
|
dest.sortType = [];
|
|
|
|
|
|
for (let i = 0; i < 3; i++) {
|
|
|
let opt = {};
|
|
|
|
|
|
switch (i) {
|
|
|
case 0:
|
|
|
opt.href = handleFilterUrl(params, { order: 's_t_desc' });
|
|
|
opt.name = '最新';
|
|
|
break;
|
|
|
case 1:
|
|
|
opt.href = handleFilterUrl(params, { order: 's_p_asc' });
|
|
|
opt.name = '价格';
|
|
|
break;
|
|
|
case 2:
|
|
|
opt.href = handleFilterUrl(params, { order: 'p_d_asc' });
|
|
|
opt.name = '折扣';
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
opt.hasSortOrient = {};
|
|
|
opt.hasSortOrient.active = {};
|
|
|
opt.hasSortOrient.active.desc = {};
|
|
|
|
|
|
dest.sortType.push(opt);
|
|
|
}
|
|
|
|
|
|
// 上下翻页数据处理
|
|
|
dest.pageCounts = [{
|
|
|
href: handleFilterUrl(params, { limit: 100 }),
|
|
|
count: 100
|
|
|
}, {
|
|
|
href: handleFilterUrl(params, { limit: 80 }),
|
|
|
count: 80
|
|
|
}, {
|
|
|
href: handleFilterUrl(params, { limit: 60 }),
|
|
|
count: 60
|
|
|
}];
|
|
|
|
|
|
dest.curPage = _.isEmpty(params.page) ? 1 : params.page; // 当前页码数
|
|
|
|
|
|
// 上一页下一页
|
|
|
let preHref = (!_.isEmpty(params.page) && params.page > 1) ? params.page - 1 : 1;
|
|
|
let nextHref = (!_.isEmpty(params.page)) ? params.page + 1 : 2;
|
|
|
|
|
|
dest.preHref = handleFilterUrl(params, { page: preHref });
|
|
|
dest.nextHref = handleFilterUrl(params, { page: nextHref });
|
|
|
|
|
|
// 每页商品数量
|
|
|
dest.countPerPage = _.isEmpty(params.limit) ? 60 : params.limit;
|
|
|
|
|
|
// 全部页码数量
|
|
|
dest.pageCount = parseInt(total / (_.isEmpty(params.limit) ? 60 : params.limit), 10) + 1;
|
|
|
|
|
|
// 每页多少商品
|
|
|
let paramsLimit = parseInt((_.isEmpty(params.limit) ? 60 : params.limit), 10);
|
|
|
|
|
|
// 商品开始结束数
|
|
|
dest.start = (!_.isEmpty(params.page) ? params.page - 1 : 0) * paramsLimit;
|
|
|
dest.end = parseInt(dest.start, 10) + paramsLimit;
|
|
|
|
|
|
return dest;
|
|
|
}; |
|
|
\ No newline at end of file |
...
|
...
|
|