Authored by 郭成尧

首页排序

@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2016-06-02 15:11:15 3 * @Date: 2016-06-02 15:11:15
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2016-06-02 15:22:08 5 + * @Last Modified time: 2016-06-03 18:14:26
6 */ 6 */
7 7
8 'use strict'; 8 'use strict';
@@ -16,7 +16,7 @@ const productProcess = require(`${utils}/product-process`); @@ -16,7 +16,7 @@ const productProcess = require(`${utils}/product-process`);
16 const _ = require('lodash'); 16 const _ = require('lodash');
17 17
18 /** 18 /**
19 - * 获取 VIP 会员专享和新降价专区数据 Controller 调用 19 + * 获取商品列表商品数据 Controller 调用
20 * @return {[type]} [description] 20 * @return {[type]} [description]
21 */ 21 */
22 exports.getSaleOthersData = (params) => { 22 exports.getSaleOthersData = (params) => {
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2016-05-30 16:20:03 3 * @Date: 2016-05-30 16:20:03
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2016-06-03 18:04:43 5 + * @Last Modified time: 2016-06-03 18:41:32
6 */ 6 */
7 7
8 'use strict'; 8 'use strict';
@@ -69,7 +69,8 @@ exports.getOutletsIndexData = (params) => { @@ -69,7 +69,8 @@ exports.getOutletsIndexData = (params) => {
69 // 处理底部商品数据 69 // 处理底部商品数据
70 if (result[5].code === 200) { 70 if (result[5].code === 200) {
71 finalResult.goodsBoard.list = productProcess.processProductList(result[5].data.product_list); 71 finalResult.goodsBoard.list = productProcess.processProductList(result[5].data.product_list);
72 - 72 + finalResult.goodsBoard.sort = publicHandler.handleSaleOptsData(params, result[5].data.total);
  73 + finalResult.goodsBoard.sort.newPage = true;
73 finalResult.pager = publicHandler.handleSalePagerData(result[5].data.total, params); 74 finalResult.pager = publicHandler.handleSalePagerData(result[5].data.total, params);
74 } 75 }
75 76
@@ -152,10 +153,10 @@ exports.getOutletsSpecialData = (params) => { @@ -152,10 +153,10 @@ exports.getOutletsSpecialData = (params) => {
152 outletsProcess.handleOutletsSpecilData(result[1].data[0])); 153 outletsProcess.handleOutletsSpecilData(result[1].data[0]));
153 154
154 return api.all([ 155 return api.all([
155 - list.getSaleOthersData({ 156 + list.getSaleOthersData(Object.assign({
156 productPool: result[1].data[0].productPoolId, 157 productPool: result[1].data[0].productPoolId,
157 saleType: 4 158 saleType: 4
158 - }) 159 + }, params))
159 ]).then(data => { 160 ]).then(data => {
160 specialData.specialHead.count = data[0].totalCount; 161 specialData.specialHead.count = data[0].totalCount;
161 Object.assign(specialData, data[0]); 162 Object.assign(specialData, data[0]);
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2016-06-02 15:50:47 3 * @Date: 2016-06-02 15:50:47
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 -* @Last Modified time: 2016-06-03 16:36:28 5 +* @Last Modified time: 2016-06-03 18:25:57
6 */ 6 */
7 7
8 'use strict'; 8 'use strict';
@@ -161,3 +161,78 @@ exports.handleSalePagerData = (total, params) => { @@ -161,3 +161,78 @@ exports.handleSalePagerData = (total, params) => {
161 161
162 return dest; 162 return dest;
163 }; 163 };
  164 +
  165 +
  166 +/**
  167 + * 处理 opts 排序数据 待处理 待确认
  168 + * @param {[type]} origin [description]
  169 + * @return {[type]} [description]
  170 + */
  171 +exports.handleSaleOptsData = (params, total) => {
  172 + var dest = {};
  173 +
  174 + dest.sortType = [];
  175 +
  176 + for (let i = 0; i < 3; i++) {
  177 + let opt = {};
  178 +
  179 + switch (i) {
  180 + case 0:
  181 + opt.href = handleFilterUrl(params, { order: 's_t_desc' });
  182 + opt.name = '最新';
  183 + break;
  184 + case 1:
  185 + opt.href = handleFilterUrl(params, { order: 's_p_asc' });
  186 + opt.name = '价格';
  187 + break;
  188 + case 2:
  189 + opt.href = handleFilterUrl(params, { order: 'p_d_asc' });
  190 + opt.name = '折扣';
  191 + break;
  192 + default:
  193 + break;
  194 + }
  195 +
  196 + opt.hasSortOrient = {};
  197 + opt.hasSortOrient.active = {};
  198 + opt.hasSortOrient.active.desc = {};
  199 +
  200 + dest.sortType.push(opt);
  201 + }
  202 +
  203 + // 上下翻页数据处理
  204 + dest.pageCounts = [{
  205 + href: handleFilterUrl(params, { limit: 100 }),
  206 + count: 100
  207 + }, {
  208 + href: handleFilterUrl(params, { limit: 80 }),
  209 + count: 80
  210 + }, {
  211 + href: handleFilterUrl(params, { limit: 60 }),
  212 + count: 60
  213 + }];
  214 +
  215 + dest.curPage = _.isEmpty(params.page) ? 1 : params.page; // 当前页码数
  216 +
  217 + // 上一页下一页
  218 + let preHref = (!_.isEmpty(params.page) && params.page > 1) ? params.page - 1 : 1;
  219 + let nextHref = (!_.isEmpty(params.page)) ? params.page + 1 : 2;
  220 +
  221 + dest.preHref = handleFilterUrl(params, { page: preHref });
  222 + dest.nextHref = handleFilterUrl(params, { page: nextHref });
  223 +
  224 + // 每页商品数量
  225 + dest.countPerPage = _.isEmpty(params.limit) ? 60 : params.limit;
  226 +
  227 + // 全部页码数量
  228 + dest.pageCount = parseInt(total / (_.isEmpty(params.limit) ? 60 : params.limit), 10) + 1;
  229 +
  230 + // 每页多少商品
  231 + let paramsLimit = parseInt((_.isEmpty(params.limit) ? 60 : params.limit), 10);
  232 +
  233 + // 商品开始结束数
  234 + dest.start = (!_.isEmpty(params.page) ? params.page - 1 : 0) * paramsLimit;
  235 + dest.end = parseInt(dest.start, 10) + paramsLimit;
  236 +
  237 + return dest;
  238 +};
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2016-05-25 18:16:59 3 * @Date: 2016-05-25 18:16:59
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2016-06-01 18:58:00 5 + * @Last Modified time: 2016-06-03 18:22:50
6 */ 6 */
7 7
8 'use strict'; 8 'use strict';
@@ -19,58 +19,56 @@ @@ -19,58 +19,56 @@
19 </a> 19 </a>
20 {{/ sortType}} 20 {{/ sortType}}
21 21
22 - {{#if list}}  
23 - {{#if oldPage}}  
24 - <div class="pager-wrap">  
25 - <p class="page-orient">  
26 - {{#if preHref}}  
27 - <a class="pjax" href="{{preHref}}">  
28 - <span class="iconfont">&#xe615;</span>  
29 - </a>  
30 - {{^}}  
31 - <span class="dis-icon iconfont">&#xe615;</span>  
32 - {{/if}} 22 + {{#if newPage}}
  23 + <div class="page-nav">
  24 + {{#if preHref}}
  25 + <a class="pjax" href="{{preHref}}">
  26 + <span class="page-prev"><i class="arrow-left"></i></span>
  27 + </a>
  28 + {{^}}
  29 + <span class="page-prev"><i class="arrow-left"></i></span>
  30 + {{/if}}
33 31
34 - <span>  
35 - <i>{{curPage}}</i>/{{pageCount}} 32 + {{#if nextHref}}
  33 + <a class="pjax" href="{{nextHref}}">
  34 + <span class="page-next">
  35 + 下一页
  36 + <i class="arrow-right"></i>
  37 + <i class="pages">{{curPage}}</i>/{{pageCount}}
36 </span> 38 </span>
37 -  
38 - {{#if nextHref}}  
39 - <a class="pjax" href="{{nextHref}}">  
40 - <span class="iconfont">&#xe601;</span>  
41 - </a>  
42 - {{^}}  
43 - <span class="dis-icon iconfont">&#xe601;</span>  
44 - {{/if}}  
45 - </p>  
46 - </div>  
47 - {{^}}  
48 - <div class="page-nav"> 39 + </a>
  40 + {{^}}
  41 + <span class="page-next">
  42 + 下一页
  43 + <i class="arrow-right"></i>
  44 + <i class="pages">{{curPage}}</i>/{{pageCount}}
  45 + </span>
  46 + {{/if}}
  47 + </div>
  48 + {{^}}
  49 + <div class="pager-wrap">
  50 + <p class="page-orient">
49 {{#if preHref}} 51 {{#if preHref}}
50 <a class="pjax" href="{{preHref}}"> 52 <a class="pjax" href="{{preHref}}">
51 - <span class="page-prev"><i class="arrow-left"></i></span> 53 + <span class="iconfont">&#xe615;</span>
52 </a> 54 </a>
53 {{^}} 55 {{^}}
54 - <span class="page-prev"><i class="arrow-left"></i></span> 56 + <span class="dis-icon iconfont">&#xe615;</span>
55 {{/if}} 57 {{/if}}
56 58
  59 + <span>
  60 + <i>{{curPage}}</i>/{{pageCount}}
  61 + </span>
  62 +
57 {{#if nextHref}} 63 {{#if nextHref}}
58 <a class="pjax" href="{{nextHref}}"> 64 <a class="pjax" href="{{nextHref}}">
59 - <span class="page-next">  
60 - 下一页  
61 - <i class="arrow-right"></i>  
62 - <i class="pages">{{curPage}}</i>/{{pageCount}}  
63 - </span> 65 + <span class="iconfont">&#xe601;</span>
64 </a> 66 </a>
65 {{^}} 67 {{^}}
66 - <span class="page-next">  
67 - 下一页  
68 - <i class="arrow-right"></i>  
69 - <i class="pages">{{curPage}}</i>/{{pageCount}}  
70 - </span> 68 + <span class="dis-icon iconfont">&#xe601;</span>
71 {{/if}} 69 {{/if}}
72 - </div>  
73 - {{/if}} 70 + </p>
  71 + </div>
74 {{/if}} 72 {{/if}}
75 </div> 73 </div>
76 {{/ sort}} 74 {{/ sort}}