Authored by 毕凯

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

@@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
5 */ 5 */
6 6
7 var $ = require('jquery'), 7 var $ = require('jquery'),
  8 + ellipsis = require('mlellipsis'),
8 Hammer = require('yoho.hammer'); 9 Hammer = require('yoho.hammer');
9 10
10 var chosePanel = require('./chose-panel'), 11 var chosePanel = require('./chose-panel'),
@@ -15,21 +16,33 @@ var $cartContent = $('.cart-content'), @@ -15,21 +16,33 @@ var $cartContent = $('.cart-content'),
15 cartType = $('#cartType').val(), 16 cartType = $('#cartType').val(),
16 hasShowCartPresellTip = false; 17 hasShowCartPresellTip = false;
17 18
18 -var $cartContentShow = $cartContent.not('.hide');  
19 -  
20 var navHammer, 19 var navHammer,
21 advanceBuyHammer, 20 advanceBuyHammer,
22 freebieHammer, 21 freebieHammer,
23 switchChose = false; 22 switchChose = false;
24 23
25 require('../product/recommend-for-you'); 24 require('../product/recommend-for-you');
  25 +require('./good');
  26 +
  27 +ellipsis.init();
  28 +
  29 +function cartContentShow() {
  30 + return $cartContent.not('.hide');
  31 +}
  32 +
  33 +function mlellipsisHiddenNames() {
  34 + cartContentShow().find('.shopping-cart-good .name').each(function() {
  35 + this.mlellipsis(2);
  36 + });
  37 + switchChose = true;
  38 +}
26 39
27 function hasChecked() { 40 function hasChecked() {
28 - return $cartContentShow.find('.icon-cb-checked').length > 0 ? true : false; 41 + return cartContentShow().find('.cart-goods .icon-cb-checked').length > 0 ? true : false;
29 } 42 }
30 43
31 function shouldSelectGift() { 44 function shouldSelectGift() {
32 - var $freebie = $cartContentShow.find('.freebie'); 45 + var $freebie = cartContentShow().find('.freebie');
33 46
34 if ($freebie.length <= 0) { 47 if ($freebie.length <= 0) {
35 return false; 48 return false;
@@ -70,16 +83,12 @@ function showChooseGifDialog() { @@ -70,16 +83,12 @@ function showChooseGifDialog() {
70 rightBtnText: '去选择' 83 rightBtnText: '去选择'
71 } 84 }
72 }, function() { 85 }, function() {
73 - window.location.href = $cartContentShow.find('.freebie > a').attr('href'); 86 + window.location.href = cartContentShow().find('.freebie > a').attr('href');
74 }, function() { 87 }, function() {
75 window.location.href = '/cart/index/orderEnsure?cartType=' + cartType; 88 window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
76 }); 89 });
77 } 90 }
78 91
79 -require('./good');  
80 -  
81 -//lazyLoad($('img.lazy'));  
82 -  
83 if (typeof window.cookie === 'function' && 'y' === window.cookie('_hasShowCartPresellTip')) { 92 if (typeof window.cookie === 'function' && 'y' === window.cookie('_hasShowCartPresellTip')) {
84 $('#presell-tip').removeClass('show').addClass('hide'); 93 $('#presell-tip').removeClass('show').addClass('hide');
85 hasShowCartPresellTip = true; 94 hasShowCartPresellTip = true;
@@ -91,9 +100,9 @@ if ('advance' === cartType) { @@ -91,9 +100,9 @@ if ('advance' === cartType) {
91 $cartContent.toggleClass('hide'); 100 $cartContent.toggleClass('hide');
92 $('#common-cart-nav').removeClass('active'); 101 $('#common-cart-nav').removeClass('active');
93 $('#presell-cart-nav').addClass('active'); 102 $('#presell-cart-nav').addClass('active');
94 - $('.shopping-cart-good .name').each(function() {  
95 - this.mlellipsis(2);  
96 - }); 103 +
  104 + mlellipsisHiddenNames();
  105 + $(window).trigger('scroll');
97 } 106 }
98 107
99 if ($('.cart-nav').length > 0) { 108 if ($('.cart-nav').length > 0) {
@@ -119,13 +128,8 @@ if ($('.cart-nav').length > 0) { @@ -119,13 +128,8 @@ if ($('.cart-nav').length > 0) {
119 //切换普通商品和预售商品购物车显示 128 //切换普通商品和预售商品购物车显示
120 $cartContent.toggleClass('hide'); 129 $cartContent.toggleClass('hide');
121 130
122 - $cartContentShow = $cartContent.not('.hide');  
123 -  
124 if (switchChose === false) { 131 if (switchChose === false) {
125 - $cartContentShow.find('.shopping-cart-good .name').each(function() {  
126 - this.mlellipsis(2);  
127 - });  
128 - switchChose = true; 132 + mlellipsisHiddenNames();
129 } 133 }
130 134
131 //trigger lazyload 135 //trigger lazyload
@@ -176,16 +180,5 @@ $('.chose').on('touchend', function() { @@ -176,16 +180,5 @@ $('.chose').on('touchend', function() {
176 chosePanel.show(); 180 chosePanel.show();
177 }); 181 });
178 182
179 -function notAllowScroll() {  
180 - var docH = $(document).height(),  
181 - winH = $(window).height();  
182 -  
183 - if (docH - winH <= 10) {  
184 - $('body').css('overflow', 'hidden');  
185 - }  
186 -}  
187 -  
188 -notAllowScroll();  
189 -  
190 //提前触发lazyload 183 //提前触发lazyload
191 $(window).scrollTop(1).scrollTop(0); 184 $(window).scrollTop(1).scrollTop(0);
@@ -162,10 +162,12 @@ @@ -162,10 +162,12 @@
162 } 162 }
163 163
164 .btn-wrap { 164 .btn-wrap {
  165 + position: relative;
165 height: 120rem / $pxConvertRem; 166 height: 120rem / $pxConvertRem;
166 border-top: 1px solid #e6e6e6; 167 border-top: 1px solid #e6e6e6;
167 padding: 20rem / $pxConvertRem; 168 padding: 20rem / $pxConvertRem;
168 text-align: center; 169 text-align: center;
  170 + background: #fff;
169 box-sizing: border-box; 171 box-sizing: border-box;
170 172
171 .btn-sure { 173 .btn-sure {
@@ -15,11 +15,17 @@ @@ -15,11 +15,17 @@
15 15
16 .cart-content > * { 16 .cart-content > * {
17 background: #fff; 17 background: #fff;
  18 +
  19 + &:first-child {
  20 + border-top: none;
  21 + margin-top: 0;
  22 + }
18 } 23 }
19 24
20 .cart-nav { 25 .cart-nav {
21 color: #c6c6c6; 26 color: #c6c6c6;
22 border-bottom: 1px solid #e0e0e0; 27 border-bottom: 1px solid #e0e0e0;
  28 + background: #fff;
23 29
24 li { 30 li {
25 float: left; 31 float: left;
1 -<div class="cart-goods">  
2 - {{# goods}}  
3 - {{> cart/good}}  
4 - {{/ goods}}  
5 -</div> 1 +{{#if goods}}
  2 + <div class="cart-goods">
  3 + {{# goods}}
  4 + {{> cart/good}}
  5 + {{/ goods}}
  6 + </div>
  7 +{{/if}}
6 8
7 {{#if notValidGoods}} 9 {{#if notValidGoods}}
8 <div class="invalid-goods"> 10 <div class="invalid-goods">
@@ -80,19 +80,21 @@ class CartModel @@ -80,19 +80,21 @@ class CartModel
80 80
81 $ordinaryCount = strval($cart['ordinary_cart_data']['shopping_cart_data']['goods_count']); 81 $ordinaryCount = strval($cart['ordinary_cart_data']['shopping_cart_data']['goods_count']);
82 $advanceCount = strval($cart['advance_cart_data']['shopping_cart_data']['goods_count']); 82 $advanceCount = strval($cart['advance_cart_data']['shopping_cart_data']['goods_count']);
  83 + $ordinarySoldOut = empty($cart['ordinary_cart_data']['sold_out_goods_list']);
  84 + $advanceSoldOut = empty($cart['advance_cart_data']['sold_out_goods_list']);
83 // 普通购物车和预售购物车都为空 85 // 普通购物车和预售购物车都为空
84 - if ($ordinaryCount === '0' && $advanceCount === '0') { 86 + if ($ordinaryCount === '0' && $advanceCount === '0' && $ordinarySoldOut && $advanceSoldOut) {
85 $result['isEmptyCart'] = true; 87 $result['isEmptyCart'] = true;
86 break; 88 break;
87 } 89 }
88 90
89 // 普通购物车空,则显示预售购物车 91 // 普通购物车空,则显示预售购物车
90 - if ($ordinaryCount === '0') { 92 + if ($ordinaryCount === '0' && $ordinaryCount) {
91 $result['cartNav'] = false; 93 $result['cartNav'] = false;
92 $result['cartType'] = 'advance'; 94 $result['cartType'] = 'advance';
93 } 95 }
94 // 预售购物车空,则显示普通购物车 96 // 预售购物车空,则显示普通购物车
95 - elseif ($advanceCount === '0') { 97 + elseif ($advanceCount === '0' && $advanceSoldOut) {
96 $result['cartNav'] = false; 98 $result['cartNav'] = false;
97 $result['cartType'] = 'ordinary'; 99 $result['cartType'] = 'ordinary';
98 } 100 }
@@ -734,7 +736,7 @@ class CartModel @@ -734,7 +736,7 @@ class CartModel
734 736
735 do { 737 do {
736 // 数据为空时返回空的标志 738 // 数据为空时返回空的标志
737 - if (empty($data['goods_list'])) { 739 + if (empty($data['goods_list']) && empty($data['sold_out_goods_list'])) {
738 break; 740 break;
739 } 741 }
740 742