Authored by 郭成尧

首页排序

... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2016-06-02 15:11:15
* @Last Modified by: Targaryen
* @Last Modified time: 2016-06-02 15:22:08
* @Last Modified time: 2016-06-03 18:14:26
*/
'use strict';
... ... @@ -16,7 +16,7 @@ const productProcess = require(`${utils}/product-process`);
const _ = require('lodash');
/**
* 获取 VIP 会员专享和新降价专区数据 Controller 调用
* 获取商品列表商品数据 Controller 调用
* @return {[type]} [description]
*/
exports.getSaleOthersData = (params) => {
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2016-05-30 16:20:03
* @Last Modified by: Targaryen
* @Last Modified time: 2016-06-03 18:04:43
* @Last Modified time: 2016-06-03 18:41:32
*/
'use strict';
... ... @@ -69,7 +69,8 @@ exports.getOutletsIndexData = (params) => {
// 处理底部商品数据
if (result[5].code === 200) {
finalResult.goodsBoard.list = productProcess.processProductList(result[5].data.product_list);
finalResult.goodsBoard.sort = publicHandler.handleSaleOptsData(params, result[5].data.total);
finalResult.goodsBoard.sort.newPage = true;
finalResult.pager = publicHandler.handleSalePagerData(result[5].data.total, params);
}
... ... @@ -152,10 +153,10 @@ exports.getOutletsSpecialData = (params) => {
outletsProcess.handleOutletsSpecilData(result[1].data[0]));
return api.all([
list.getSaleOthersData({
list.getSaleOthersData(Object.assign({
productPool: result[1].data[0].productPoolId,
saleType: 4
})
}, params))
]).then(data => {
specialData.specialHead.count = data[0].totalCount;
Object.assign(specialData, data[0]);
... ...
... ... @@ -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
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2016-05-25 18:16:59
* @Last Modified by: Targaryen
* @Last Modified time: 2016-06-01 18:58:00
* @Last Modified time: 2016-06-03 18:22:50
*/
'use strict';
... ...
... ... @@ -19,32 +19,7 @@
</a>
{{/ sortType}}
{{#if list}}
{{#if oldPage}}
<div class="pager-wrap">
<p class="page-orient">
{{#if preHref}}
<a class="pjax" href="{{preHref}}">
<span class="iconfont">&#xe615;</span>
</a>
{{^}}
<span class="dis-icon iconfont">&#xe615;</span>
{{/if}}
<span>
<i>{{curPage}}</i>/{{pageCount}}
</span>
{{#if nextHref}}
<a class="pjax" href="{{nextHref}}">
<span class="iconfont">&#xe601;</span>
</a>
{{^}}
<span class="dis-icon iconfont">&#xe601;</span>
{{/if}}
</p>
</div>
{{^}}
{{#if newPage}}
<div class="page-nav">
{{#if preHref}}
<a class="pjax" href="{{preHref}}">
... ... @@ -70,7 +45,30 @@
</span>
{{/if}}
</div>
{{^}}
<div class="pager-wrap">
<p class="page-orient">
{{#if preHref}}
<a class="pjax" href="{{preHref}}">
<span class="iconfont">&#xe615;</span>
</a>
{{^}}
<span class="dis-icon iconfont">&#xe615;</span>
{{/if}}
<span>
<i>{{curPage}}</i>/{{pageCount}}
</span>
{{#if nextHref}}
<a class="pjax" href="{{nextHref}}">
<span class="iconfont">&#xe601;</span>
</a>
{{^}}
<span class="dis-icon iconfont">&#xe601;</span>
{{/if}}
</p>
</div>
{{/if}}
</div>
{{/ sort}}
\ No newline at end of file
... ...