Authored by 梁志锋

购物车功能开发

@@ -114,7 +114,7 @@ function search() { @@ -114,7 +114,7 @@ function search() {
114 } 114 }
115 115
116 function scrollHandler() { 116 function scrollHandler() {
117 - if (!end || $(window).scrollTop() + winH >= $(document).height() - 50) { 117 + if (!end || $(window).scrollTop() + winH >= $(document).height() - 200) {
118 search(); 118 search();
119 } 119 }
120 } 120 }
@@ -18,11 +18,6 @@ var goodsDiscountEl = document.getElementById('goodsDiscount'), @@ -18,11 +18,6 @@ var goodsDiscountEl = document.getElementById('goodsDiscount'),
18 18
19 var $cart = $('.cart-bar'); 19 var $cart = $('.cart-bar');
20 20
21 -  
22 -require('./desc');  
23 -require('./comments-consults');  
24 -require('../recommend-for-you-product-desc');  
25 -  
26 //add extra marign-bottom for footer to show the yoho copyright 21 //add extra marign-bottom for footer to show the yoho copyright
27 function showFooter() { 22 function showFooter() {
28 var $cartBar = $('.cart-bar'); 23 var $cartBar = $('.cart-bar');
@@ -74,6 +69,10 @@ if (goodsDiscountHammer && $discountFolder.children().length > 0) { @@ -74,6 +69,10 @@ if (goodsDiscountHammer && $discountFolder.children().length > 0) {
74 }); 69 });
75 } 70 }
76 71
  72 +require('./desc');
  73 +require('./comments-consults');
  74 +require('../recommend-for-you-product-desc');
  75 +
77 //购物车商品数量 76 //购物车商品数量
78 $.ajax({ 77 $.ajax({
79 type: 'GET', 78 type: 'GET',
@@ -155,4 +155,17 @@ $('.btn-balance').on('touchend', function() { @@ -155,4 +155,17 @@ $('.btn-balance').on('touchend', function() {
155 window.location.href = '/shoppingCart/orderEnsure?cartType=' + cartType; 155 window.location.href = '/shoppingCart/orderEnsure?cartType=' + cartType;
156 }); 156 });
157 157
  158 +$('.advance-buy').on('touchend', function() {
  159 + var $advanceBuy = $('#advanceBuy'),
  160 + $mainCart = $('#mainCart');
  161 +
  162 + if ($advanceBuy.hasClass('hide')) {
  163 + $mainCart.removeClass('show').addClass('hide');
  164 + $advanceBuy.removeClass('hide').addClass('show');
  165 + } else {
  166 + $advanceBuy.removeClass('show').addClass('hide');
  167 + $mainCart.removeClass('hide').addClass('show');
  168 + }
  169 +});
  170 +
158 171
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 "yoho.iswiper": "3.0.1", 21 "yoho.iswiper": "3.0.1",
22 "iscroll": "5.1.2", 22 "iscroll": "5.1.2",
23 "import-style": "1.0.0", 23 "import-style": "1.0.0",
24 - "yoho.lazyload": "1.1.3", 24 + "yoho.lazyload": "1.1.4",
25 "yoho.handlebars": "3.0.3", 25 "yoho.handlebars": "3.0.3",
26 "yoho.hammer": "2.0.4" 26 "yoho.hammer": "2.0.4"
27 }, 27 },
@@ -177,4 +177,115 @@ @@ -177,4 +177,115 @@
177 font-size: 28rem / $pxConvertRem; 177 font-size: 28rem / $pxConvertRem;
178 } 178 }
179 } 179 }
  180 +
  181 + .gift-advance-good {
  182 + position: relative;
  183 + padding: 20rem / $pxConvertRem 0;
  184 + margin-left: 34rem / $pxConvertRem;
  185 + height: 160rem / $pxConvertRem;
  186 + border-bottom: 1px solid #e0e0e0;
  187 +
  188 + &:last-child {
  189 + border-bottom: none;
  190 + }
  191 + }
  192 +
  193 +
  194 + .advance-block .gift-advance-good:last-child {
  195 + border-bottom: none;
  196 + }
  197 +
  198 + .advance-block:last-child .gift-advance-good:last-child {
  199 + border-bottom: 1px solid #e0e0e0;
  200 + }
  201 +
  202 + .thumb-wrap {
  203 + position: relative;
  204 + float: left;
  205 + width: 120rem / $pxConvertRem;
  206 + height: 160rem / $pxConvertRem;
  207 +
  208 + .thumb {
  209 + width: 100%;
  210 + height: 100%;
  211 + }
  212 + }
  213 +
  214 + .tag {
  215 + position: absolute;
  216 + bottom: 0;
  217 + left: 0;
  218 + right: 0;
  219 + height: 25rem / $pxConvertRem;
  220 + color: #fff;
  221 + text-align: center;
  222 + background: #a1ce4e;
  223 +
  224 + &:before {
  225 + content: '赠品';
  226 + }
  227 + }
  228 +
  229 + .deps {
  230 + margin-left: 135rem / $pxConvertRem;
  231 + }
  232 +
  233 + .name {
  234 + font-size: 28rem / $pxConvertRem;
  235 + }
  236 +
  237 + .row:nth-child(2) {
  238 + font-size: 22rem / $pxConvertRem;
  239 + height: 45rem / $pxConvertRem;
  240 + line-height: 45rem / $pxConvertRem;
  241 +
  242 + > span {
  243 + margin-right: 15rem / $pxConvertRem;
  244 + }
  245 + }
  246 +
  247 + .row:nth-child(3) {
  248 + position: relative;
  249 + }
  250 +
  251 + .color, .size {
  252 + color: #b6b6b6;
  253 + }
  254 +
  255 + .price {
  256 + font-size: 24rem / $pxConvertRem;
  257 + color: #000;
  258 + }
  259 +
  260 + .count {
  261 + font-size: 20rem / $pxConvertRem;
  262 + color: #999;
  263 + margin-left: 22rem / $pxConvertRem;
  264 + }
  265 +
  266 + .chose {
  267 + position: absolute;
  268 + width: 88rem / $pxConvertRem;
  269 + height: 58rem / $pxConvertRem;
  270 + background: #f8f8f8;
  271 + border: 1px solid #ccc;
  272 + right: 20rem / $pxConvertRem;
  273 + top: 71rem / $pxConvertRem;
  274 + font-size: 26rem / $pxConvertRem;
  275 + }
  276 +
  277 + .title {
  278 + height: 50rem / $pxConvertRem;
  279 + line-height: 50rem / $pxConvertRem;
  280 + padding-left: 20rem / $pxConvertRem;
  281 + font-size: 24rem / $pxConvertRem;
  282 + background: #f8f8f8;
  283 + }
  284 +
  285 + .advance-block .tag {
  286 + background: #eb76aa;
  287 + &:before {
  288 + content: '加价购';
  289 + }
  290 + }
180 } 291 }
1 {{> layout/header}} 1 {{> layout/header}}
2 -<div class="shopping-cart-page yoho-page"> 2 +<div id="mainCart" class="shopping-cart-page yoho-page">
3 {{# shoppingCart}} 3 {{# shoppingCart}}
4 {{#if cartNav}} 4 {{#if cartNav}}
5 <ul class="cart-nav clearfix"> 5 <ul class="cart-nav clearfix">
@@ -44,4 +44,21 @@ @@ -44,4 +44,21 @@
44 44
45 {{/ shoppingCart}} 45 {{/ shoppingCart}}
46 </div> 46 </div>
  47 +
  48 +
  49 +<div id="advanceBuy" class="shopping-cart-page yoho-page hide">
  50 +{{# shoppingCart}}
  51 + {{# commonCart}}
  52 + {{# advanceBuy}}
  53 + <span>
  54 + {{promotionTitle}}
  55 + </span>
  56 + {{# goods}}
  57 + {{> shopping-cart/gift-advance-good}}
  58 + {{/ goods}}
  59 + {{/ advanceBuy}}
  60 + {{/ commonCart}}
  61 +{{/ shoppingCart}}
  62 +</div>
  63 +
47 {{> layout/footer}} 64 {{> layout/footer}}
@@ -16,16 +16,16 @@ @@ -16,16 +16,16 @@
16 </a> 16 </a>
17 </li> 17 </li>
18 {{/ freebie}} 18 {{/ freebie}}
19 - {{# advanceBuy}} 19 + {{#if advanceBuy}}
20 <li class="advance-buy"> 20 <li class="advance-buy">
21 <span class="iconfont">&#xe61b;</span> 21 <span class="iconfont">&#xe61b;</span>
22 加价购 22 加价购
23 - <a href={{url}}> 23 + <a href="/shoppingCart/getCartData">
24 <span class="count">{{count}}</span> 24 <span class="count">{{count}}</span>
25 <span class="iconfont icon-right-arrow">&#xe614;</span> 25 <span class="iconfont icon-right-arrow">&#xe614;</span>
26 </a> 26 </a>
27 </li> 27 </li>
28 - {{/ advanceBuy}} 28 + {{/if}}
29 </ul> 29 </ul>
30 {{/if}} 30 {{/if}}
31 31
@@ -54,4 +54,4 @@ @@ -54,4 +54,4 @@
54 <a class="btn-balance"> 54 <a class="btn-balance">
55 结算 55 结算
56 </a> 56 </a>
57 -</div>  
  57 +</div>