Authored by Rock Zhang

Merge branch 'develop' of 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'),
@@ -13,23 +14,36 @@ var chosePanel = require('./chose-panel'), @@ -13,23 +14,36 @@ var chosePanel = require('./chose-panel'),
13 14
14 var $cartContent = $('.cart-content'), 15 var $cartContent = $('.cart-content'),
15 cartType = $('#cartType').val(), 16 cartType = $('#cartType').val(),
  17 + $cartNav = $('.cart-nav'),
16 hasShowCartPresellTip = false; 18 hasShowCartPresellTip = false;
17 19
18 -var $cartContentShow = $cartContent.not('.hide');  
19 -  
20 var navHammer, 20 var navHammer,
21 advanceBuyHammer, 21 advanceBuyHammer,
22 freebieHammer, 22 freebieHammer,
23 switchChose = false; 23 switchChose = false;
24 24
25 require('../product/recommend-for-you'); 25 require('../product/recommend-for-you');
  26 +require('./good');
  27 +
  28 +ellipsis.init();
  29 +
  30 +function cartContentShow() {
  31 + return $cartContent.not('.hide');
  32 +}
  33 +
  34 +function mlellipsisHiddenNames() {
  35 + cartContentShow().find('.shopping-cart-good .name').each(function() {
  36 + this.mlellipsis(2);
  37 + });
  38 + switchChose = true;
  39 +}
26 40
27 function hasChecked() { 41 function hasChecked() {
28 - return $cartContentShow.find('.icon-cb-checked').length > 0 ? true : false; 42 + return cartContentShow().find('.cart-goods .icon-cb-checked').length > 0 ? true : false;
29 } 43 }
30 44
31 function shouldSelectGift() { 45 function shouldSelectGift() {
32 - var $freebie = $cartContentShow.find('.freebie'); 46 + var $freebie = cartContentShow().find('.freebie');
33 47
34 if ($freebie.length <= 0) { 48 if ($freebie.length <= 0) {
35 return false; 49 return false;
@@ -70,16 +84,12 @@ function showChooseGifDialog() { @@ -70,16 +84,12 @@ function showChooseGifDialog() {
70 rightBtnText: '去选择' 84 rightBtnText: '去选择'
71 } 85 }
72 }, function() { 86 }, function() {
73 - window.location.href = $cartContentShow.find('.freebie > a').attr('href'); 87 + window.location.href = cartContentShow().find('.freebie > a').attr('href');
74 }, function() { 88 }, function() {
75 window.location.href = '/cart/index/orderEnsure?cartType=' + cartType; 89 window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
76 }); 90 });
77 } 91 }
78 92
79 -require('./good');  
80 -  
81 -//lazyLoad($('img.lazy'));  
82 -  
83 if (typeof window.cookie === 'function' && 'y' === window.cookie('_hasShowCartPresellTip')) { 93 if (typeof window.cookie === 'function' && 'y' === window.cookie('_hasShowCartPresellTip')) {
84 $('#presell-tip').removeClass('show').addClass('hide'); 94 $('#presell-tip').removeClass('show').addClass('hide');
85 hasShowCartPresellTip = true; 95 hasShowCartPresellTip = true;
@@ -91,12 +101,12 @@ if ('advance' === cartType) { @@ -91,12 +101,12 @@ if ('advance' === cartType) {
91 $cartContent.toggleClass('hide'); 101 $cartContent.toggleClass('hide');
92 $('#common-cart-nav').removeClass('active'); 102 $('#common-cart-nav').removeClass('active');
93 $('#presell-cart-nav').addClass('active'); 103 $('#presell-cart-nav').addClass('active');
94 - $('.shopping-cart-good .name').each(function() {  
95 - this.mlellipsis(2);  
96 - }); 104 +
  105 + mlellipsisHiddenNames();
  106 + $(window).trigger('scroll');
97 } 107 }
98 108
99 -if ($('.cart-nav').length > 0) { 109 +if ($cartNav.length > 0) {
100 navHammer = new Hammer(document.getElementsByClassName('cart-nav')[0]); 110 navHammer = new Hammer(document.getElementsByClassName('cart-nav')[0]);
101 navHammer.on('tap', function(e) { 111 navHammer.on('tap', function(e) {
102 var $this = $(e.target).closest('li'); 112 var $this = $(e.target).closest('li');
@@ -119,13 +129,8 @@ if ($('.cart-nav').length > 0) { @@ -119,13 +129,8 @@ if ($('.cart-nav').length > 0) {
119 //切换普通商品和预售商品购物车显示 129 //切换普通商品和预售商品购物车显示
120 $cartContent.toggleClass('hide'); 130 $cartContent.toggleClass('hide');
121 131
122 - $cartContentShow = $cartContent.not('.hide');  
123 -  
124 if (switchChose === false) { 132 if (switchChose === false) {
125 - $cartContentShow.find('.shopping-cart-good .name').each(function() {  
126 - this.mlellipsis(2);  
127 - });  
128 - switchChose = true; 133 + mlellipsisHiddenNames();
129 } 134 }
130 135
131 //trigger lazyload 136 //trigger lazyload
@@ -176,16 +181,11 @@ $('.chose').on('touchend', function() { @@ -176,16 +181,11 @@ $('.chose').on('touchend', function() {
176 chosePanel.show(); 181 chosePanel.show();
177 }); 182 });
178 183
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(); 184 +$cartNav.on('touchstart', 'li', function(e) {
  185 + $(this).addClass('bytouch');
  186 +}).on('touchend touchcancel', function() {
  187 + $cartNav.find('li').removeClass('bytouch');
  188 +});
189 189
190 //提前触发lazyload 190 //提前触发lazyload
191 $(window).scrollTop(1).scrollTop(0); 191 $(window).scrollTop(1).scrollTop(0);
@@ -31,6 +31,7 @@ @@ -31,6 +31,7 @@
31 } 31 }
32 32
33 .basic-info { 33 .basic-info {
  34 + // height: 100rem / $pxConvertRem;
34 overflow: hidden; 35 overflow: hidden;
35 position: relative; 36 position: relative;
36 margin-bottom: pxToRem(30px); 37 margin-bottom: pxToRem(30px);
@@ -155,10 +156,12 @@ @@ -155,10 +156,12 @@
155 height: 80rem / $pxConvertRem; 156 height: 80rem / $pxConvertRem;
156 line-height: 80rem / $pxConvertRem; 157 line-height: 80rem / $pxConvertRem;
157 padding: 0; 158 padding: 0;
158 - border: none;  
159 - border-top: 1px solid #e6e6e6;  
160 - border-bottom: 1px solid #e6e6e6; 159 + border: 1px solid #e6e6e6;
161 text-align: center; 160 text-align: center;
  161 + margin-left: -1px;
  162 + }
  163 + .btn-plus{
  164 + margin-left: -1px;
162 } 165 }
163 166
164 .btn-wrap { 167 .btn-wrap {
@@ -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;
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 padding: pxToRem(30px) 0 pxToRem(20px); 16 padding: pxToRem(30px) 0 pxToRem(20px);
17 width: 100%; 17 width: 100%;
18 height: pxToRem(252px); 18 height: pxToRem(252px);
19 - overflow: hidden; 19 + // overflow: hidden;
20 20
21 .swiper-slide { 21 .swiper-slide {
22 padding: 0 pxToRem(10px); 22 padding: 0 pxToRem(10px);
1 -<div class="cart-goods"> 1 +{{#if goods}}
  2 + <div class="cart-goods">
2 {{# goods}} 3 {{# goods}}
3 {{> cart/good}} 4 {{> cart/good}}
4 {{/ goods}} 5 {{/ goods}}
5 -</div> 6 + </div>
  7 +{{/if}}
6 8
7 {{#if notValidGoods}} 9 {{#if notValidGoods}}
8 <div class="invalid-goods"> 10 <div class="invalid-goods">