Authored by 陈峰

列表排序

@@ -51,21 +51,13 @@ @@ -51,21 +51,13 @@
51 {{/ brandHome}} 51 {{/ brandHome}}
52 <!-- /品牌页面 --> 52 <!-- /品牌页面 -->
53 <ul id="list-nav" class="list-nav clearfix"> 53 <ul id="list-nav" class="list-nav clearfix">
54 - {{#if isSearch}}  
55 - <li class="new active buriedpoint" data-bp-id=""> 54 + <li class="default active buriedpoint first-li-more" data-bp-id="shop_listnav_default_1">
56 <a href="javascript:void(0);"> 55 <a href="javascript:void(0);">
57 <span class="nav-txt">默认</span> 56 <span class="nav-txt">默认</span>
58 - <span class="iconfont cur">&#xe616;</span> 57 + <span class="iconfont up cur hide">&#xe615;</span>
  58 + <span class="iconfont down cur">&#xe616;</span>
59 </a> 59 </a>
60 </li> 60 </li>
61 - {{else}}  
62 - <li class="new active buriedpoint" data-bp-id="shop_listnav_new_1">  
63 - <a href="javascript:void(0);">  
64 - <span class="nav-txt">最新</span>  
65 - <span class="iconfont cur">&#xe616;</span>  
66 - </a>  
67 - </li>  
68 - {{/if}}  
69 <li class="price buriedpoint" data-bp-id="shop_listnav_price_1"> 61 <li class="price buriedpoint" data-bp-id="shop_listnav_price_1">
70 <a href="javascript:void(0);"> 62 <a href="javascript:void(0);">
71 <span class="nav-txt">价格</span> 63 <span class="nav-txt">价格</span>
@@ -91,12 +83,18 @@ @@ -91,12 +83,18 @@
91 </a> 83 </a>
92 </li> 84 </li>
93 </ul> 85 </ul>
  86 + <div class='new-list hide'>
  87 + <ul>
  88 + <li class='active default' data-bp-id='shop_listnav_default_1'>默认</li>
  89 + <li class='new' data-bp-id='shop_listnav_new_1'>最新</li>
  90 + </ul>
  91 + </div>
94 <div id="goods-container" class="goods-container"> 92 <div id="goods-container" class="goods-container">
95 - <div class="new-goods container clearfix"> 93 + <div class="default-goods container clearfix">
96 {{#newGoods}} 94 {{#newGoods}}
97 {{> common/goods}} 95 {{> common/goods}}
98 - {{/newGoods}}  
99 - </div> 96 + {{/newGoods}}</div>
  97 + <div class="new-goods container clearfix hide"></div>
100 <div class="price-goods container clearfix hide"></div> 98 <div class="price-goods container clearfix hide"></div>
101 <div class="discount-goods container clearfix hide"></div> 99 <div class="discount-goods container clearfix hide"></div>
102 100
@@ -29,21 +29,13 @@ @@ -29,21 +29,13 @@
29 {{/ baseShopHome}} 29 {{/ baseShopHome}}
30 <!-- /基础店铺页面 --> 30 <!-- /基础店铺页面 -->
31 <ul id="list-nav" class="list-nav clearfix"> 31 <ul id="list-nav" class="list-nav clearfix">
32 - {{#if isSearch}}  
33 - <li class="new active buriedpoint" data-bp-id=""> 32 + <li class="default active buriedpoint first-li-more" data-bp-id="shop_listnav_default_1">
34 <a href="javascript:void(0);"> 33 <a href="javascript:void(0);">
35 <span class="nav-txt">默认</span> 34 <span class="nav-txt">默认</span>
36 - <span class="iconfont cur">&#xe616;</span> 35 + <span class="iconfont up cur hide">&#xe615;</span>
  36 + <span class="iconfont down cur">&#xe616;</span>
37 </a> 37 </a>
38 </li> 38 </li>
39 - {{else}}  
40 - <li class="new active buriedpoint" data-bp-id="shop_listnav_new_1">  
41 - <a href="javascript:void(0);">  
42 - <span class="nav-txt">最新</span>  
43 - <span class="iconfont cur">&#xe616;</span>  
44 - </a>  
45 - </li>  
46 - {{/if}}  
47 <li class="price buriedpoint" data-bp-id="shop_listnav_price_1"> 39 <li class="price buriedpoint" data-bp-id="shop_listnav_price_1">
48 <a href="javascript:void(0);"> 40 <a href="javascript:void(0);">
49 <span class="nav-txt">价格</span> 41 <span class="nav-txt">价格</span>
@@ -69,12 +61,18 @@ @@ -69,12 +61,18 @@
69 </a> 61 </a>
70 </li> 62 </li>
71 </ul> 63 </ul>
  64 + <div class='new-list hide'>
  65 + <ul>
  66 + <li class='active default' data-bp-id='shop_listnav_default_1'>默认</li>
  67 + <li class='new' data-bp-id='shop_listnav_new_1'>最新</li>
  68 + </ul>
  69 + </div>
72 <div id="goods-container" class="goods-container"> 70 <div id="goods-container" class="goods-container">
73 - <div class="new-goods container clearfix"> 71 + <div class="default-goods container clearfix">
74 {{#newGoods}} 72 {{#newGoods}}
75 {{> common/goods}} 73 {{> common/goods}}
76 - {{/newGoods}}  
77 - </div> 74 + {{/newGoods}}</div>
  75 + <div class="new-goods container clearfix hide"></div>
78 <div class="price-goods container clearfix hide"></div> 76 <div class="price-goods container clearfix hide"></div>
79 <div class="discount-goods container clearfix hide"></div> 77 <div class="discount-goods container clearfix hide"></div>
80 78
@@ -43,11 +43,11 @@ @@ -43,11 +43,11 @@
43 </div> 43 </div>
44 44
45 <ul id="nav" class="nav"> 45 <ul id="nav" class="nav">
46 - <li class="active color buriedpoint" tab="home-page" data-bp-id="shop_nav_index_1">首页</li>  
47 - <li tab="new-arrival" data-bp-id="shop_nav_new_1" class="buriedpoint">上新</li>  
48 - <li tab="popularity" data-bp-id="shop_nav_populary_1" class="buriedpoint">人气</li> 46 + <li class="active color buriedpoint" tab="home-page" data-bp-id="shop_nav_index_1"><div class="text">首页</div></li>
  47 + <li tab="new-arrival" data-bp-id="shop_nav_new_1" class="buriedpoint"><div class="text">上新</div></li>
  48 + <li tab="popularity" data-bp-id="shop_nav_populary_1" class="buriedpoint"><div class="text">人气</div></li>
49 <li data-bp-id="shop_nav_all_1" class="all-goods buriedpoint"> 49 <li data-bp-id="shop_nav_all_1" class="all-goods buriedpoint">
50 - <a href="{{allGoods}}" target="_blank">全部商品</a> 50 + <div class="text"><a href="{{allGoods}}" target="_blank">全部商品</a></div>
51 </li> 51 </li>
52 </ul> 52 </ul>
53 53
@@ -175,11 +175,11 @@ @@ -175,11 +175,11 @@
175 {{> shop/shop-footer}} 175 {{> shop/shop-footer}}
176 {{/unless}} 176 {{/unless}}
177 <ul id="pos-nav" class="nav hide"> 177 <ul id="pos-nav" class="nav hide">
178 - <li class="active color buriedpoint" tab="home-page" data-bp-id="shop_posnav_index_1">首页</li>  
179 - <li tab="new-arrival" class="buriedpoint" data-bp-id="shop_posnav_new_1">上新</li>  
180 - <li tab="popularity" class="buriedpoint" data-bp-id="shop_posnav_populary_1">人气</li> 178 + <li class="active color buriedpoint" tab="home-page" data-bp-id="shop_posnav_index_1"><div class="text">首页</div></li>
  179 + <li tab="new-arrival" class="buriedpoint" data-bp-id="shop_posnav_new_1"><div class="text">上新</div></li>
  180 + <li tab="popularity" class="buriedpoint" data-bp-id="shop_posnav_populary_1"><div class="text">人气</div></li>
181 <li class="all-goods buriedpoint" data-bp-id="shop_posnav_all_1"> 181 <li class="all-goods buriedpoint" data-bp-id="shop_posnav_all_1">
182 - <a href="{{allGoods}}" target="_blank">全部商品</a> 182 + <div class="text"><a href="{{allGoods}}" target="_blank">全部商品</a></div>
183 </li> 183 </li>
184 </ul> 184 </ul>
185 185
1 'use strict'; 1 'use strict';
2 2
3 const fs = require('fs'); 3 const fs = require('fs');
4 -let devHost = '127.0.0.1'; 4 +let devHost = '172.16.9.195';
5 5
6 fs.readFile('.devhost', (err, buf)=> { 6 fs.readFile('.devhost', (err, buf)=> {
7 if (!err) { 7 if (!err) {
1 /** 1 /**
2 * 品牌店铺首页 2 * 品牌店铺首页
3 */ 3 */
4 - 4 +require('./shop/coupon');
5 var $ = require('yoho-jquery'), 5 var $ = require('yoho-jquery'),
6 IScroll = require('yoho-iscroll/build/iscroll-probe'), 6 IScroll = require('yoho-iscroll/build/iscroll-probe'),
7 lazyLoad = require('yoho-jquery-lazyload'), 7 lazyLoad = require('yoho-jquery-lazyload'),
@@ -358,6 +358,7 @@ function tabChange(dom, index) { @@ -358,6 +358,7 @@ function tabChange(dom, index) {
358 } else if (activeTab === 'home-page') { 358 } else if (activeTab === 'home-page') {
359 $nav1.removeClass('fixed-top absolute'); 359 $nav1.removeClass('fixed-top absolute');
360 $nav2.removeClass('fixed-top absolute'); 360 $nav2.removeClass('fixed-top absolute');
  361 + viewType = 1;
361 scrollToNav1(); 362 scrollToNav1();
362 } 363 }
363 scH = $('#scroller').outerHeight(); 364 scH = $('#scroller').outerHeight();
@@ -370,13 +371,13 @@ function tabChange(dom, index) { @@ -370,13 +371,13 @@ function tabChange(dom, index) {
370 function scrollHandler() { 371 function scrollHandler() {
371 var scrollCall, 372 var scrollCall,
372 sTop = $(document).scrollTop(), 373 sTop = $(document).scrollTop(),
  374 + scH = $('#scroller').outerHeight(),
373 nav1OffsetTop = $('#nav').length ? $('#nav').offset().top : 0, 375 nav1OffsetTop = $('#nav').length ? $('#nav').offset().top : 0,
374 nav2OffsetTop = $('#list-nav').length ? $('#list-nav').offset().top : 0; 376 nav2OffsetTop = $('#list-nav').length ? $('#list-nav').offset().top : 0;
375 377
376 var tra; 378 var tra;
377 -  
378 //分页加载店铺商品列表 379 //分页加载店铺商品列表
379 - if (sTop + winH > scH - 0.25 * $goodsContainer.height() - 50) { 380 + if (sTop > scH - winH * 2 && viewType === 1) {
380 if ($pre !== undefined) { 381 if ($pre !== undefined) {
381 search({ 382 search({
382 type: 'shop_id', 383 type: 'shop_id',
@@ -867,3 +868,4 @@ $collect.on('touchstart', function() { @@ -867,3 +868,4 @@ $collect.on('touchstart', function() {
867 } 868 }
868 }); 869 });
869 }); 870 });
  871 +
@@ -23,9 +23,11 @@ var tip = require('../../plugin/tip'); @@ -23,9 +23,11 @@ var tip = require('../../plugin/tip');
23 var loading = require('../../plugin/loading'); 23 var loading = require('../../plugin/loading');
24 24
25 var $goodsContainer = $('#goods-container'), 25 var $goodsContainer = $('#goods-container'),
  26 + $defaultgc = $goodsContainer.children('.default-goods'),
26 $ngc = $goodsContainer.children('.new-goods'), 27 $ngc = $goodsContainer.children('.new-goods'),
27 $pgc = $goodsContainer.children('.price-goods'), 28 $pgc = $goodsContainer.children('.price-goods'),
28 - $dgc = $goodsContainer.children('.discount-goods'); 29 + $dgc = $goodsContainer.children('.discount-goods'),
  30 + $newList = $('.new-list');
29 31
30 var winH = $(window).height(); 32 var winH = $(window).height();
31 33
@@ -46,7 +48,13 @@ var $listNav = $('#list-nav'), @@ -46,7 +48,13 @@ var $listNav = $('#list-nav'),
46 newest: { 48 newest: {
47 order: 1, 49 order: 1,
48 reload: true, 50 reload: true,
49 - page: 0, 51 + page: 1,
  52 + end: false
  53 + },
  54 + default: {
  55 + order: 0,
  56 + reload: true,
  57 + page: 1,
50 end: false 58 end: false
51 }, 59 },
52 price: { 60 price: {
@@ -298,8 +306,9 @@ function search(opt) { @@ -298,8 +306,9 @@ function search(opt) {
298 navType = 'price'; 306 navType = 'price';
299 } else if ($pre.hasClass('discount')) { 307 } else if ($pre.hasClass('discount')) {
300 navType = 'discount'; 308 navType = 'discount';
  309 + } else if ($pre.hasClass('default')) {
  310 + navType = 'default';
301 } 311 }
302 -  
303 nav = navInfo[navType]; 312 nav = navInfo[navType];
304 313
305 page = nav.page + 1; 314 page = nav.page + 1;
@@ -383,6 +392,9 @@ function search(opt) { @@ -383,6 +392,9 @@ function search(opt) {
383 case 'discount': 392 case 'discount':
384 $container = $dgc; 393 $container = $dgc;
385 break; 394 break;
  395 + case 'default':
  396 + $container = $defaultgc;
  397 + break;
386 default: 398 default:
387 break; 399 break;
388 } 400 }
@@ -405,8 +417,10 @@ function search(opt) { @@ -405,8 +417,10 @@ function search(opt) {
405 first_load = false; 417 first_load = false;
406 //移除头四个 418 //移除头四个
407 goodList.splice(0, 4); 419 goodList.splice(0, 4);
  420 + $container.append(goodList);
  421 + } else {
  422 + $container.html(goodList);
408 } 423 }
409 - $container.append(goodList);  
410 lazyLoad($container.find('.lazy')); 424 lazyLoad($container.find('.lazy'));
411 } else { 425 } else {
412 num = $container.find('.good-info').length; 426 num = $container.find('.good-info').length;
@@ -417,7 +431,6 @@ function search(opt) { @@ -417,7 +431,6 @@ function search(opt) {
417 } 431 }
418 432
419 } 433 }
420 -  
421 nav.reload = false; 434 nav.reload = false;
422 nav.page = page; 435 nav.page = page;
423 436
@@ -448,6 +461,10 @@ function search(opt) { @@ -448,6 +461,10 @@ function search(opt) {
448 window._yas(1 * new Date(), '1.0.16', 'yohobuy_m', window._ozuid, 461 window._yas(1 * new Date(), '1.0.16', 'yohobuy_m', window._ozuid,
449 '', $('.discount-goods .good-info .good-detail-img .good-thumb')); 462 '', $('.discount-goods .good-info .good-detail-img .good-thumb'));
450 break; 463 break;
  464 + case 'default':
  465 + window._yas(1 * new Date(), '1.0.16', 'yohobuy_m', window._ozuid,
  466 + '', $('.default-goods .good-info .good-detail-img .good-thumb'));
  467 + break;
451 default: 468 default:
452 break; 469 break;
453 } 470 }
@@ -498,7 +515,84 @@ writeSearch.bindWirteLocal($('#search-form')); @@ -498,7 +515,84 @@ writeSearch.bindWirteLocal($('#search-form'));
498 $listNav.bind('contextmenu', function() { 515 $listNav.bind('contextmenu', function() {
499 return false; 516 return false;
500 }); 517 });
  518 +function newListHide() {
  519 + var $firstLi = $listNav.find('li.first-li-more');
  520 +
  521 + if ($newList.hasClass('hide')) {
  522 + $firstLi.find('span.up').addClass('hide');
  523 + $firstLi.find('span.down').removeClass('hide');
  524 + } else {
  525 + $firstLi.find('span.down').addClass('hide');
  526 + $firstLi.find('span.up').removeClass('hide');
  527 + }
  528 +}
  529 +
  530 +$newList.on('touchstart', 'li', function(e) {
  531 + var navType, bpIdData = $(this).attr('data-bp-id') || '',
  532 + $firstLiDom = $listNav.find('li.first-li-more'),
  533 + cls = '';
  534 +
  535 + e.preventDefault();
  536 + if ($(this).hasClass('new')) {
  537 + navType = 'newest';
  538 + cls = 'new';
  539 + } else if ($(this).hasClass('default')) {
  540 + navType = 'default';
  541 + cls = 'default';
  542 + } else if ($(this).hasClass('sale')) {
  543 + navType = 'sale';
  544 + cls = 'sale';
  545 + }
  546 +
  547 + $newList.addClass('hide');
  548 + $firstLiDom.find('.nav-txt').text($(this).text());
  549 + $firstLiDom.attr('data-bp-id', bpIdData).addClass('active').siblings().removeClass('active');
  550 + $listNav.find('.first-li-more').removeClass('new default sale').addClass(cls);
  551 +
  552 + $(document).trigger('shouldSendBpData', [bpIdData]);
  553 + newListHide();
  554 +
  555 + // 切换container显示
  556 + $goodsContainer.children('.container:not(.hide)').addClass('hide');
  557 +
  558 + switch (navType) {
  559 + case 'newest':
  560 + $ngc.removeClass('hide');
  561 + break;
  562 +
  563 + case 'price':
  564 + $pgc.removeClass('hide');
  565 + break;
  566 +
  567 + case 'discount':
  568 + $dgc.removeClass('hide');
  569 + break;
  570 +
  571 + case 'default':
  572 + $defaultgc.removeClass('hide');
  573 + break;
  574 +
  575 + case 'sale':
  576 + $sgc.removeClass('hide');
  577 + break;
  578 + default:
  579 + break;
  580 + }
  581 + $pre = $('.first-li-more');
  582 + var nav = navInfo[navType];
  583 + if (nav.reload) {
  584 + search();
  585 + }
  586 +
  587 +});
501 588
  589 +$(document).on('touchstart', function(e) {
  590 + if (!$newList.hasClass('hide') &&
  591 + $(e.target).closest('.new-list, li.first-li-more').length <= 0) {
  592 + $newList.addClass('hide');
  593 + newListHide();
  594 + }
  595 +});
502 $listNav.on('touchend touchcancel', function(e) { 596 $listNav.on('touchend touchcancel', function(e) {
503 var $this = $(e.target).closest('li'), 597 var $this = $(e.target).closest('li'),
504 nav, 598 nav,
@@ -506,6 +600,22 @@ $listNav.on('touchend touchcancel', function(e) { @@ -506,6 +600,22 @@ $listNav.on('touchend touchcancel', function(e) {
506 $active; 600 $active;
507 var bpIdData = $(this).find('.buriedpoint').attr('data-bp-id') || ''; 601 var bpIdData = $(this).find('.buriedpoint').attr('data-bp-id') || '';
508 602
  603 + if ($this.hasClass('first-li-more')) {
  604 + filter.hideFilter();
  605 + $newList.toggleClass('hide');
  606 + if ($this.hasClass('default')) {
  607 + $newList.find('li.default').addClass('active').siblings().removeClass('active');
  608 + } else if ($this.hasClass('new')) {
  609 + $newList.find('li.new').addClass('active').siblings().removeClass('active');
  610 + } else if ($this.hasClass('sale')) {
  611 + $newList.find('li.sale').addClass('active').siblings().removeClass('active');
  612 + }
  613 + newListHide();
  614 + return true;
  615 + }
  616 + // 最新li 列表
  617 + $newList.addClass('hide');
  618 +
509 if ($this.hasClass('filter')) { 619 if ($this.hasClass('filter')) {
510 620
511 // 筛选面板切换状态 621 // 筛选面板切换状态
@@ -531,7 +641,9 @@ $listNav.on('touchend touchcancel', function(e) { @@ -531,7 +641,9 @@ $listNav.on('touchend touchcancel', function(e) {
531 navType = 'price'; 641 navType = 'price';
532 } else if ($this.hasClass('discount')) { 642 } else if ($this.hasClass('discount')) {
533 navType = 'discount'; 643 navType = 'discount';
534 - } 644 + } else if ($pre.hasClass('default')) {
  645 + navType = 'default';
  646 + }
535 647
536 nav = navInfo[navType]; 648 nav = navInfo[navType];
537 649
@@ -576,6 +688,10 @@ $listNav.on('touchend touchcancel', function(e) { @@ -576,6 +688,10 @@ $listNav.on('touchend touchcancel', function(e) {
576 case 'discount': 688 case 'discount':
577 $dgc.removeClass('hide'); 689 $dgc.removeClass('hide');
578 break; 690 break;
  691 +
  692 + case 'default':
  693 + $defaultgc.removeClass('hide');
  694 + break;
579 default: 695 default:
580 break; 696 break;
581 } 697 }
@@ -689,3 +805,4 @@ $listNav.on('touchstart', 'li', function() { @@ -689,3 +805,4 @@ $listNav.on('touchstart', 'li', function() {
689 }); 805 });
690 806
691 require('../../common/footer'); 807 require('../../common/footer');
  808 +require('./coupon');
@@ -90,16 +90,20 @@ @@ -90,16 +90,20 @@
90 90
91 li{ 91 li{
92 display: block; 92 display: block;
93 - height: 28px; 93 + height: 100%;
  94 + line-height: 100%;
94 float: left; 95 float: left;
95 - line-height: 28px;  
96 width: 24.7%; 96 width: 24.7%;
97 text-align: center; 97 text-align: center;
98 - border-left: 1px solid #e0e0e0;  
99 - margin-top: 30px;  
100 border-sizing: border-box; 98 border-sizing: border-box;
101 color: #b0b0b0; 99 color: #b0b0b0;
102 - 100 + .text {
  101 + display: block;
  102 + width: 100%;
  103 + border-left: 1px solid #e0e0e0;
  104 + margin-top: 30px;
  105 + height: 28px;
  106 + }
103 &:first-child { 107 &:first-child {
104 border-left: none; 108 border-left: none;
105 } 109 }