Authored by xuqi

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

@@ -583,8 +583,11 @@ class Helpers @@ -583,8 +583,11 @@ class Helpers
583 $oneGoods['isVipPrice'] = $value['sales_price'] !== $value['last_vip_price']; 583 $oneGoods['isVipPrice'] = $value['sales_price'] !== $value['last_vip_price'];
584 $oneGoods['count'] = $value['buy_number']; 584 $oneGoods['count'] = $value['buy_number'];
585 585
586 - if ($isValid) { // 库存不足 586 + if ($isValid) {
  587 + // 库存不足
587 $oneGoods['lowStocks'] = ($value['buy_number'] > $value['storage_number']); 588 $oneGoods['lowStocks'] = ($value['buy_number'] > $value['storage_number']);
  589 + } else { // 失效商品
  590 + $oneGoods['inValid'] = true;
588 } 591 }
589 592
590 //gift=>是否赠品,advanceBuy=>是否加价购,soldOut=>失效商品; 593 //gift=>是否赠品,advanceBuy=>是否加价购,soldOut=>失效商品;
@@ -66,7 +66,7 @@ $('.freebie').on('touchend', function() { @@ -66,7 +66,7 @@ $('.freebie').on('touchend', function() {
66 66
67 $('.btn-balance').on('touchend', function() { 67 $('.btn-balance').on('touchend', function() {
68 if ($('.low-stocks').length > 0) { 68 if ($('.low-stocks').length > 0) {
69 - tip.show('请先删除库存不足商品'); 69 + tip.show('库存不足无法结算');
70 return false; 70 return false;
71 } 71 }
72 72
@@ -277,6 +277,10 @@ $yohoPage.on('touchstart', '.btn-minus', function() { @@ -277,6 +277,10 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
277 if (num === 1 || 0 === leftNum - 0) { 277 if (num === 1 || 0 === leftNum - 0) {
278 return; 278 return;
279 } 279 }
  280 + if (num < 1) {
  281 + $num.val(1);
  282 + return;
  283 + }
280 284
281 $num.val(num - 1); 285 $num.val(num - 1);
282 }).on('touchstart', '.btn-plus', function() { 286 }).on('touchstart', '.btn-plus', function() {
@@ -294,7 +298,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() { @@ -294,7 +298,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
294 } 298 }
295 299
296 //TODO:库存数验证 300 //TODO:库存数验证
297 - if (num > leftNum) { 301 + if (num > leftNum - 1) {
298 $num.val(leftNum); 302 $num.val(leftNum);
299 return; 303 return;
300 } 304 }
@@ -306,7 +310,6 @@ $yohoPage.on('touchstart', '.btn-minus', function() { @@ -306,7 +310,6 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
306 310
307 promotionId, 311 promotionId,
308 isEdit = 0, 312 isEdit = 0,
309 - numInCart = $('.num-tag').html() - 0,  
310 num = parseInt($num.val(), 10); 313 num = parseInt($num.val(), 10);
311 314
312 //颜色尺码没有选择 315 //颜色尺码没有选择
@@ -329,7 +332,10 @@ $yohoPage.on('touchstart', '.btn-minus', function() { @@ -329,7 +332,10 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
329 tip.show('您选择的数量超过了最大库存量~'); 332 tip.show('您选择的数量超过了最大库存量~');
330 return; 333 return;
331 } 334 }
332 - 335 + if (num < 0) {
  336 + tip.show('您选择的数量小于一件~');
  337 + return;
  338 + }
333 $chosed = $('.block-list>ul>li.chosed'); 339 $chosed = $('.block-list>ul>li.chosed');
334 340
335 if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) { 341 if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) {
@@ -352,9 +358,15 @@ $yohoPage.on('touchstart', '.btn-minus', function() { @@ -352,9 +358,15 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
352 cartType: queryString.cartType 358 cartType: queryString.cartType
353 } 359 }
354 }).done(function(res) { 360 }).done(function(res) {
  361 + var cartNum;
  362 +
355 loading.hideLoadingMask(); 363 loading.hideLoadingMask();
356 if (res.code === 200) { 364 if (res.code === 200) {
357 - $('.num-tag').html(numInCart + buyNumber).removeClass('hide'); 365 + cartNum = res.data.goods_count;
  366 + if (cartNum > 99) {
  367 + cartNum = '99+';
  368 + }
  369 + $('.num-tag').html(cartNum).removeClass('hide');
358 confirming = false; 370 confirming = false;
359 371
360 if (cbFn) { 372 if (cbFn) {
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 6
7 var $ = require('jquery'), 7 var $ = require('jquery'),
8 lazyLoad = require('yoho.lazyload'), 8 lazyLoad = require('yoho.lazyload'),
  9 + Hammer = require('yoho.hammer'),
9 tip = require('../plugin/tip'), 10 tip = require('../plugin/tip'),
10 loading = require('../plugin/loading'), 11 loading = require('../plugin/loading'),
11 chosePanel = require('./chose-panel'); 12 chosePanel = require('./chose-panel');
@@ -35,10 +36,22 @@ function getProductInfo(skn, promotionId) { @@ -35,10 +36,22 @@ function getProductInfo(skn, promotionId) {
35 }); 36 });
36 } 37 }
37 38
38 -$page.on('touchend', '.chose', function() {  
39 - var $this = $(this),  
40 - id = $this.closest('.gift-advance-good').data('id'),  
41 - promotionId = $this.closest('.advance-block').data('promotion-id'); 39 +$page.find('.chose').each(function(i, elem) {
  40 + var choseHammer = new Hammer(elem);
42 41
43 - getProductInfo(id, promotionId); 42 + choseHammer.on('tap', function(e) {
  43 + var $this = $(e.target),
  44 + id = $this.closest('.gift-advance-good').data('id'),
  45 + promotionId = $this.closest('.advance-block').data('promotion-id');
  46 +
  47 + getProductInfo(id, promotionId);
  48 + });
44 }); 49 });
  50 +
  51 +// $page.on('touchend', '.chose', function() {
  52 +// var $this = $(this),
  53 +// id = $this.closest('.gift-advance-good').data('id'),
  54 +// promotionId = $this.closest('.advance-block').data('promotion-id');
  55 +//
  56 +// getProductInfo(id, promotionId);
  57 +// });
@@ -27,6 +27,13 @@ $('.shopping-cart-good .name').each(function() { @@ -27,6 +27,13 @@ $('.shopping-cart-good .name').each(function() {
27 this.mlellipsis(2); 27 this.mlellipsis(2);
28 }); 28 });
29 29
  30 +function GoodInfo(properties) {
  31 + this.goods_type = properties.goods_type;
  32 + this.buy_number = properties.buy_number;
  33 + this.product_sku = properties.product_sku;
  34 + this.selected = properties.selected;
  35 +}
  36 +
30 //TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods 37 //TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
31 $('.cart-goods').on('touchstart', '.checkbox', function() { 38 $('.cart-goods').on('touchstart', '.checkbox', function() {
32 var $this = $(this), 39 var $this = $(this),
@@ -43,12 +50,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { @@ -43,12 +50,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
43 isSelected = false; 50 isSelected = false;
44 } 51 }
45 52
46 - function GoodInfo(properties) {  
47 - this.goods_type = properties.goods_type;  
48 - this.buy_number = properties.buy_number;  
49 - this.product_sku = properties.product_sku;  
50 - this.selected = properties.selected;  
51 - } 53 +
52 54
53 goodInfo.goods_type = cartType; 55 goodInfo.goods_type = cartType;
54 goodInfo.selected = isSelected ? 'N' : 'Y'; 56 goodInfo.selected = isSelected ? 'N' : 'Y';
@@ -174,17 +176,10 @@ function didUpdateAllGoodsCheckStatus() { @@ -174,17 +176,10 @@ function didUpdateAllGoodsCheckStatus() {
174 } 176 }
175 177
176 function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) { 178 function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) {
177 - var goodInfo = {};  
178 - var $goods = $('.cart-content:not(.hide) .shopping-cart-good');  
179 - var $good = null;  
180 - var goodsList = [];  
181 -  
182 - function GoodInfo(properties) {  
183 - this.goods_type = properties.goods_type;  
184 - this.buy_number = properties.buy_number;  
185 - this.product_sku = properties.product_sku;  
186 - this.selected = properties.selected;  
187 - } 179 + var goodInfo = {},
  180 + $goods = $('.cart-content:not(.hide) .shopping-cart-good'),
  181 + $good = null,
  182 + goodsList = [];
188 183
189 goodInfo.goods_type = type; 184 goodInfo.goods_type = type;
190 goodInfo.selected = isSelected ? 'N' : 'Y'; 185 goodInfo.selected = isSelected ? 'N' : 'Y';
@@ -39,17 +39,18 @@ @@ -39,17 +39,18 @@
39 39
40 .thumb { 40 .thumb {
41 float: left; 41 float: left;
42 - width: 80rem / $pxConvertRem; 42 + width: 100rem / $pxConvertRem;
43 } 43 }
44 44
45 .text-info { 45 .text-info {
46 - position: absolute;  
47 height: auto; 46 height: auto;
48 - left: pxToRem(95px);  
49 - top:50%;  
50 - transform: translateY(-50%);  
51 .name { 47 .name {
52 font-size: 28rem / $pxConvertRem; 48 font-size: 28rem / $pxConvertRem;
  49 + height: 74rem / $pxConvertRem;
  50 + overflow: hidden;
  51 + display: -webkit-box;
  52 + -webkit-line-clamp: 2;
  53 + -webkit-box-orient: vertical;
53 } 54 }
54 55
55 .price{ 56 .price{
@@ -119,7 +119,10 @@ @@ -119,7 +119,10 @@
119 } 119 }
120 120
121 .coupon-use { 121 .coupon-use {
  122 + box-sizing: border-box;
  123 + position: relative;
122 float: right; 124 float: right;
  125 + padding-right: 30rem / $pxConvertRem;
123 color: #999; 126 color: #999;
124 text-align: right; 127 text-align: right;
125 width: 360rem / $pxConvertRem; 128 width: 360rem / $pxConvertRem;
@@ -128,6 +131,9 @@ @@ -128,6 +131,9 @@
128 overflow: hidden; 131 overflow: hidden;
129 132
130 .iconfont { 133 .iconfont {
  134 + position: absolute;
  135 + top:0;
  136 + right: 0;
131 color: #999; 137 color: #999;
132 } 138 }
133 } 139 }
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 {{/if}} 11 {{/if}}
12 {{#if isEmptyCart}} 12 {{#if isEmptyCart}}
13 <div class="cart-zero"> 13 <div class="cart-zero">
14 - <i class="iconfont">&#xe62c</i> 14 + <i class="iconfont">&#xe640;</i>
15 <p>您的购物车暂无商品</p> 15 <p>您的购物车暂无商品</p>
16 <a href="/product/new">随便逛逛</a> 16 <a href="/product/new">随便逛逛</a>
17 </div> 17 </div>
@@ -118,8 +118,7 @@ @@ -118,8 +118,7 @@
118 118
119 {{#cartInfo}} 119 {{#cartInfo}}
120 <div class="cart-bar"> 120 <div class="cart-bar">
121 - <span class="num-tag hide"></span>  
122 - <a href="{{cartUrl}}" class="num-incart iconfont">&#xe62c;</a> 121 + <a href="{{cartUrl}}" class="num-incart iconfont"><span class="num-tag hide"></span>&#xe62c;</a>
123 122
124 {{#if addToCartUrl}} 123 {{#if addToCartUrl}}
125 <!-- <a id="addtoCart" href="{{addToCartUrl}}" class="addto-cart">加入购物车</a> --> 124 <!-- <a id="addtoCart" href="{{addToCartUrl}}" class="addto-cart">加入购物车</a> -->
@@ -19,8 +19,8 @@ @@ -19,8 +19,8 @@
19 <a href="/cart/index/gift?cartType={{cartType}}"> 19 <a href="/cart/index/gift?cartType={{cartType}}">
20 <span class="iconfont">&#xe620;</span> 20 <span class="iconfont">&#xe620;</span>
21 赠品 21 赠品
22 - <span class="count">{{count}}</span>  
23 <span class="iconfont icon-right-arrow">&#xe614;</span> 22 <span class="iconfont icon-right-arrow">&#xe614;</span>
  23 + <span class="count">{{count}}</span>
24 </a> 24 </a>
25 </li> 25 </li>
26 {{/ freebie}} 26 {{/ freebie}}
@@ -29,8 +29,8 @@ @@ -29,8 +29,8 @@
29 <a href="/cart/index/advanceBuy?cartType={{cartType}}"> 29 <a href="/cart/index/advanceBuy?cartType={{cartType}}">
30 <span class="iconfont">&#xe61b;</span> 30 <span class="iconfont">&#xe61b;</span>
31 加价购 31 加价购
32 - <span class="count">{{advanceBuyCount}}</span>  
33 <span class="iconfont icon-right-arrow">&#xe614;</span> 32 <span class="iconfont icon-right-arrow">&#xe614;</span>
  33 + <span class="count">{{advanceBuyCount}}</span>
34 </a> 34 </a>
35 </li> 35 </li>
36 {{/if}} 36 {{/if}}
@@ -10,9 +10,6 @@ @@ -10,9 +10,6 @@
10 {{#if price}} 10 {{#if price}}
11 <span class="price market-price">&yen;{{marketPrice}}</span> 11 <span class="price market-price">&yen;{{marketPrice}}</span>
12 {{/if}} 12 {{/if}}
13 - <span class="count">  
14 - ×{{count}}  
15 - </span>  
16 </p> 13 </p>
17 <button class="chose">选择</button> 14 <button class="chose">选择</button>
18 </div> 15 </div>