Authored by 王水玲

sale

@@ -35,7 +35,8 @@ const typeCont = { @@ -35,7 +35,8 @@ const typeCont = {
35 price: ['s_p_desc', 's_p_asc'], 35 price: ['s_p_desc', 's_p_asc'],
36 discount: ['p_d_desc', 'p_d_asc'], 36 discount: ['p_d_desc', 'p_d_asc'],
37 sales: ['s_n_desc', 's_n_asc'], 37 sales: ['s_n_desc', 's_n_asc'],
38 - newest: ['s_t_desc', 's_t_asc'] 38 + newest: ['s_t_desc', 's_t_asc'],
  39 + stock: ['s_s_desc', 's_s_asc']
39 }; 40 };
40 41
41 /** 42 /**
@@ -248,9 +249,57 @@ const processProductList = (list, options) => { @@ -248,9 +249,57 @@ const processProductList = (list, options) => {
248 */ 249 */
249 const processFilter = (list, options) => { 250 const processFilter = (list, options) => {
250 const filters = { 251 const filters = {
251 - classify: {} 252 + classify: []
252 }; 253 };
253 254
  255 + const filtersType = {
  256 + brand: {
  257 + name: '所有品牌',
  258 + title: '品牌',
  259 + dataId: 'id',
  260 + subsName: 'brandName'
  261 + },
  262 + color: {
  263 + name: '所有颜色',
  264 + title: '颜色',
  265 + dataId: 'colorId',
  266 + subsName: 'colorName'
  267 + },
  268 + discount: {
  269 + name: '所有商品',
  270 + title: '折扣',
  271 + dataId: 'key',
  272 + subsName: 'name'
  273 + },
  274 + gender: {
  275 + name: '所有性别',
  276 + title: '性别',
  277 + dataId: 'key',
  278 + subsName: 'flag'
  279 + },
  280 + groupSort: {
  281 + name: '所有品类',
  282 + title: '品类',
  283 + dataId: 'relationParameter',
  284 + subsName: 'categoryName'
  285 + },
  286 + priceRange: {
  287 + name: '所有价格',
  288 + title: '价格',
  289 + dataId: 'key',
  290 + subsName: 'flag'
  291 + },
  292 + size: {
  293 + name: '所有尺码',
  294 + title: '尺码',
  295 + dataId: 'sizeId',
  296 + subsName: 'sizeName'
  297 + }
  298 + };
  299 +
  300 + let subs = {};
  301 + let classify = {};
  302 +
254 options = Object.assign({ 303 options = Object.assign({
255 gender: '1,2,3', // 默认选择的性别,默认1,2,3表示所有 304 gender: '1,2,3', // 默认选择的性别,默认1,2,3表示所有
256 exclude: null // 需要排除的字段 305 exclude: null // 需要排除的字段
@@ -258,8 +307,33 @@ const processFilter = (list, options) => { @@ -258,8 +307,33 @@ const processFilter = (list, options) => {
258 list = camelCase(list); 307 list = camelCase(list);
259 308
260 _.forEach(list, (item, key) => { 309 _.forEach(list, (item, key) => {
261 - console.log(key); 310 + if (key === 'group_sort') {
  311 + return;
  312 + }
  313 + classify.dataType = key;
  314 + classify.name = filtersType[key].name;
  315 + classify.title = filtersType[key].typeCont;
  316 +
  317 + _.forEach(item, (sub, index) => {
  318 + if (filtersType[key].dataId === 'key') {
  319 + subs.dataId = index;
  320 + } else if (filtersType[key].dataId === 'relationParameter') {
  321 + subs.dataId = item.relationParameter.sort;
  322 + } else {
  323 + subs.dataId = item[filtersType[key].dataId];
  324 + }
  325 +
  326 + if (filtersType[key].subsName === 'flag') {
  327 + subs.name = index;
  328 + } else {
  329 + subs.name = sub[filtersType[key].subsName];
  330 + }
  331 + classify.subs.push(subs)
  332 + });
  333 +
  334 + filters.classify.push(classify);
262 }); 335 });
  336 +
263 return filters; 337 return filters;
264 }; 338 };
265 339
@@ -31,28 +31,24 @@ var $listNav = $('#list-nav'), @@ -31,28 +31,24 @@ var $listNav = $('#list-nav'),
31 // 导航数据信息 31 // 导航数据信息
32 navInfo = { 32 navInfo = {
33 coat: { 33 coat: {
34 - order: 1,  
35 reload: true, 34 reload: true,
36 page: 0, 35 page: 0,
37 end: false, 36 end: false,
38 saleType: 1 37 saleType: 1
39 }, 38 },
40 trouser: { 39 trouser: {
41 - order: 1,  
42 reload: true, 40 reload: true,
43 page: 0, 41 page: 0,
44 end: false, 42 end: false,
45 saleType: 1 43 saleType: 1
46 }, 44 },
47 shoes: { 45 shoes: {
48 - order: 1,  
49 reload: true, 46 reload: true,
50 page: 0, 47 page: 0,
51 end: false, 48 end: false,
52 saleType: 1 49 saleType: 1
53 }, 50 },
54 other: { 51 other: {
55 - order: 1,  
56 reload: true, 52 reload: true,
57 page: 0, 53 page: 0,
58 end: false, 54 end: false,
@@ -89,12 +85,14 @@ $.each($listNav.find('li'), function(key, item) { @@ -89,12 +85,14 @@ $.each($listNav.find('li'), function(key, item) {
89 */ 85 */
90 function search(opt) { 86 function search(opt) {
91 var setting = {}, 87 var setting = {},
92 - ext = [], 88 + ext = {},
93 att, 89 att,
94 nav, navType, 90 nav, navType,
95 page, 91 page,
96 i; 92 i;
97 93
  94 + delete defaultOpt.size;
  95 +
98 if (searching) { 96 if (searching) {
99 return; 97 return;
100 } 98 }
@@ -150,8 +148,6 @@ function search(opt) { @@ -150,8 +148,6 @@ function search(opt) {
150 } 148 }
151 149
152 $.extend(defaultOpt, ext); // 扩展筛选项 150 $.extend(defaultOpt, ext); // 扩展筛选项
153 -  
154 - console.log(defaultOpt);  
155 } 151 }
156 152
157 153
@@ -177,8 +173,8 @@ function search(opt) { @@ -177,8 +173,8 @@ function search(opt) {
177 } 173 }
178 174
179 $.extend(setting, defaultOpt, { 175 $.extend(setting, defaultOpt, {
180 - type: navType,  
181 - order: nav.order, 176 + type: 'stock',
  177 + order: 0,
182 page: page 178 page: page
183 }); 179 });
184 180
@@ -319,7 +315,6 @@ $listNav.on('touchend touchcancel', function(e) { @@ -319,7 +315,6 @@ $listNav.on('touchend touchcancel', function(e) {
319 nav = navInfo[navType]; 315 nav = navInfo[navType];
320 316
321 if ($this.hasClass('active')) { 317 if ($this.hasClass('active')) {
322 - nav.reload = true;  
323 return; 318 return;
324 } else { 319 } else {
325 $active = $this.siblings('.active'); 320 $active = $this.siblings('.active');
@@ -396,12 +391,11 @@ $swiperSize.on('touchend touchcancel', function(e) { @@ -396,12 +391,11 @@ $swiperSize.on('touchend touchcancel', function(e) {
396 nav = navInfo[navType]; 391 nav = navInfo[navType];
397 392
398 if ($this.hasClass('active')) { 393 if ($this.hasClass('active')) {
399 - nav.reload = true;  
400 return; 394 return;
401 } else { 395 } else {
  396 + nav.reload = true;
402 $active = $this.siblings('.active'); 397 $active = $this.siblings('.active');
403 -  
404 - $pre = $this; // $pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项 398 + $pre = $parentType; // $pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项
405 399
406 $active.removeClass('active'); 400 $active.removeClass('active');
407 $this.addClass('active'); 401 $this.addClass('active');