Authored by 梁志锋

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

@@ -567,41 +567,41 @@ class Helpers @@ -567,41 +567,41 @@ class Helpers
567 { 567 {
568 $arr = array(); 568 $arr = array();
569 569
570 - $oneGoods = array();  
571 - foreach ($cartGoods as $key => $value) {  
572 - $oneGoods['id'] = $value['product_sku'];  
573 - $oneGoods['skn'] = $value['product_skn'];  
574 - $oneGoods['name'] = $value['product_name'];  
575 - $oneGoods['thumb'] = !empty($value['goods_images']) ? Images::getImageUrl($value['goods_images'], 90, 100) : '';  
576 - $oneGoods['color'] = $value['color_name'];  
577 - $oneGoods['size'] = $value['size_name']; 570 + $oneGoods = array();
  571 + foreach ($cartGoods as $key => $value) {
  572 + $oneGoods['id'] = $value['product_sku'];
  573 + $oneGoods['skn'] = $value['product_skn'];
  574 + $oneGoods['name'] = $value['product_name'];
  575 + $oneGoods['thumb'] = !empty($value['goods_images']) ? Images::getImageUrl($value['goods_images'], 90, 100) : '';
  576 + $oneGoods['color'] = $value['color_name'];
  577 + $oneGoods['size'] = $value['size_name'];
578 $oneGoods['isSelected'] = $value['selected'] === 'Y'; 578 $oneGoods['isSelected'] = $value['selected'] === 'Y';
579 - $oneGoods['price'] = self::transPrice($value['sales_price']);  
580 - $oneGoods['count'] = $value['buy_number']; 579 + $oneGoods['price'] = self::transPrice($value['sales_price']);
  580 + $oneGoods['count'] = $value['buy_number'];
581 581
582 if ($isValid) { 582 if ($isValid) {
583 $oneGoods['lowStocks'] = ($value['buy_number'] > $value['storage_number']); 583 $oneGoods['lowStocks'] = ($value['buy_number'] > $value['storage_number']);
584 } 584 }
585 585
586 - //gift=>是否赠品,advanceBuy=>是否加价购,soldOut=>失效商品;  
587 - if (!isset($value['goods_type'])) {  
588 - $oneGoods['isSoldOut'] = true;  
589 - } elseif ($value['goods_type'] == 'gift' && !isset($value['isAdvanceBuy'])) {  
590 - $oneGoods['isGift'] = true;  
591 - } elseif ($value['goods_type'] == 'price_gift') {  
592 - $oneGoods['isAdvanceBuy'] = true;  
593 - }  
594 - // 上市期  
595 - if (!empty($value['expect_arrival_time'])) {  
596 - $oneGoods['appearDate'] = $value['expect_arrival_time'];  
597 - }  
598 - // 商品链接  
599 - if (isset($value['cn_alphabet']) ) {  
600 - $oneGoods['url'] = self::url('/product/pro_' . $value['product_id'] . '_' . $value['goods_id'] . '/' . $value['cn_alphabet'] . '.html');  
601 - }  
602 -  
603 - $arr[$key] = $oneGoods;  
604 - } 586 + //gift=>是否赠品,advanceBuy=>是否加价购,soldOut=>失效商品;
  587 + if (!isset($value['goods_type'])) {
  588 + $oneGoods['isSoldOut'] = true;
  589 + } elseif ($value['goods_type'] == 'gift' && !isset($value['isAdvanceBuy'])) {
  590 + $oneGoods['isGift'] = true;
  591 + } elseif ($value['goods_type'] == 'price_gift') {
  592 + $oneGoods['isAdvanceBuy'] = true;
  593 + }
  594 + // 上市期
  595 + if (!empty($value['expect_arrival_time'])) {
  596 + $oneGoods['appearDate'] = $value['expect_arrival_time'];
  597 + }
  598 + // 商品链接
  599 + if (isset($value['cn_alphabet'])) {
  600 + $oneGoods['url'] = self::url('/product/pro_' . $value['product_id'] . '_' . $value['goods_id'] . '/' . $value['cn_alphabet'] . '.html');
  601 + }
  602 +
  603 + $arr[$key] = $oneGoods;
  604 + }
605 605
606 return $arr; 606 return $arr;
607 } 607 }
@@ -617,30 +617,30 @@ class Helpers @@ -617,30 +617,30 @@ class Helpers
617 { 617 {
618 $arr = array(); 618 $arr = array();
619 619
620 - $gift = array();  
621 - $oneGoods = array();  
622 - foreach ($advanceGoods as $value) {  
623 - $gift = array();  
624 - $gift['promotionId'] = $value['promotion_id'];  
625 - $gift['promotionTitle'] = $value['promotion_title'];  
626 -  
627 - foreach ($value['goods_list'] as $single) {  
628 - $oneGoods['id'] = $single['product_skn'];  
629 - $oneGoods['name'] = $single['product_name'];  
630 - $oneGoods['thumb'] = !empty($single['goods_images']) ? Images::getImageUrl($single['goods_images'], 120, 160) : '';  
631 - $oneGoods['appearDate'] = '12月'; // 目前app接口没有返回该数据  
632 - $oneGoods['price'] = self::transPrice($single['last_price']);  
633 - $oneGoods['marketPrice'] = self::transPrice($single['market_price']);  
634 - $oneGoods['count'] = $single['storage_number'];  
635 -  
636 - $gift['goods'][] = $oneGoods;  
637 - }  
638 -  
639 - $arr[] = $gift;  
640 -  
641 - // 计算加价购商品数目  
642 - $count += $value['max_select_number'];  
643 - } 620 + $gift = array();
  621 + $oneGoods = array();
  622 + foreach ($advanceGoods as $value) {
  623 + $gift = array();
  624 + $gift['promotionId'] = $value['promotion_id'];
  625 + $gift['promotionTitle'] = $value['promotion_title'];
  626 +
  627 + foreach ($value['goods_list'] as $single) {
  628 + $oneGoods['id'] = $single['product_skn'];
  629 + $oneGoods['name'] = $single['product_name'];
  630 + $oneGoods['thumb'] = !empty($single['goods_images']) ? Images::getImageUrl($single['goods_images'], 120, 160) : '';
  631 + $oneGoods['appearDate'] = '12月'; // 目前app接口没有返回该数据
  632 + $oneGoods['price'] = self::transPrice($single['last_price']);
  633 + $oneGoods['marketPrice'] = self::transPrice($single['market_price']);
  634 + $oneGoods['count'] = $single['storage_number'];
  635 +
  636 + $gift['goods'][] = $oneGoods;
  637 + }
  638 +
  639 + $arr[] = $gift;
  640 +
  641 + // 计算加价购商品数目
  642 + $count += $value['max_select_number'];
  643 + }
644 644
645 return $arr; 645 return $arr;
646 } 646 }
@@ -8,7 +8,8 @@ var $ = require('jquery'), @@ -8,7 +8,8 @@ var $ = require('jquery'),
8 lazyLoad = require('yoho.lazyload'), 8 lazyLoad = require('yoho.lazyload'),
9 Hammer = require('yoho.hammer'); 9 Hammer = require('yoho.hammer');
10 10
11 -var chosePanel = require('./chose-panel'); 11 +var chosePanel = require('./chose-panel'),
  12 + tip = require('../plugin/tip');
12 13
13 var $cartContent = $('.cart-content'); 14 var $cartContent = $('.cart-content');
14 15
@@ -46,7 +47,11 @@ if ($('.cart-nav').length > 0) { @@ -46,7 +47,11 @@ if ($('.cart-nav').length > 0) {
46 } 47 }
47 48
48 $('.btn-balance').on('touchend', function() { 49 $('.btn-balance').on('touchend', function() {
49 - window.location.href = '/cart/index/orderEnsure?cartType=' + cartType; 50 + if($('.balance span').hasClass('icon-cb-checked')){
  51 + window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
  52 + } else {
  53 + tip.show('请先勾选商品~');
  54 + }
50 }); 55 });
51 56
52 $('.chose').on('touchend', function() { 57 $('.chose').on('touchend', function() {
@@ -52,7 +52,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { @@ -52,7 +52,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
52 this.selected = properties.selected; 52 this.selected = properties.selected;
53 } 53 }
54 54
55 - goodInfo.goods_type = getCartType(); 55 + goodInfo.goods_type = cartType;
56 goodInfo.selected = isSelected ? 'N' : 'Y'; 56 goodInfo.selected = isSelected ? 'N' : 'Y';
57 goodInfo.product_sku = id; 57 goodInfo.product_sku = id;
58 goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', ''); 58 goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', '');
@@ -16,9 +16,10 @@ var page = 1, @@ -16,9 +16,10 @@ var page = 1,
16 isGetData; 16 isGetData;
17 17
18 var conponTmpl = Handlebars.compile($('#tmpl-coupon').html()), 18 var conponTmpl = Handlebars.compile($('#tmpl-coupon').html()),
19 - conponNotAvaliableTmpl = Handlebars.compile($('#tmpl-coupon-not-avaliable').html()),  
20 $newCoupon = $('#new-coupon'); 19 $newCoupon = $('#new-coupon');
21 20
  21 +// conponNotAvaliableTmpl = Handlebars.compile($('#tmpl-coupon-not-avaliable').html()),
  22 +
22 ellipsis.init(); 23 ellipsis.init();
23 24
24 $newCoupon.on('submit', function() { 25 $newCoupon.on('submit', function() {
@@ -54,6 +55,12 @@ $('#coupon-list').on('touchend', '.employ-main', function() { @@ -54,6 +55,12 @@ $('#coupon-list').on('touchend', '.employ-main', function() {
54 orderInfo('couponValue', $this.data('coupon-value')); 55 orderInfo('couponValue', $this.data('coupon-value'));
55 }); 56 });
56 57
  58 +$('body').on('touchend', '.not-use', function() {
  59 + orderInfo('couponCode', null);
  60 + orderInfo('couponValue', null);
  61 +});
  62 +
  63 +
57 $newCoupon.find('input').on('input', function() { 64 $newCoupon.find('input').on('input', function() {
58 if ($(this).val() !== '') { 65 if ($(this).val() !== '') {
59 $newCoupon.find('.submit').css('background', '#444'); 66 $newCoupon.find('.submit').css('background', '#444');
@@ -109,15 +116,17 @@ function getCouponHandle(coupons) { @@ -109,15 +116,17 @@ function getCouponHandle(coupons) {
109 } 116 }
110 }); 117 });
111 118
112 - if (notAvailableCoupons.length) {  
113 - $('.not-avaliable-coupon-line').show();  
114 - }  
115 $('#coupon-list').append(conponTmpl({ 119 $('#coupon-list').append(conponTmpl({
116 coupons: coupons 120 coupons: coupons
117 })); 121 }));
118 - $('#coupon-list-not').append(conponNotAvaliableTmpl({  
119 - notAvailableCoupons: notAvailableCoupons  
120 - })); 122 +
  123 + // 产品说,暂时不做不可使用的优惠券
  124 + // if (notAvailableCoupons.length) {
  125 + // $('.not-avaliable-coupon-line').show();
  126 + // }
  127 + // $('#coupon-list-not').append(conponNotAvaliableTmpl({
  128 + // notAvailableCoupons: notAvailableCoupons
  129 + // }));
121 window.rePosFooter(); 130 window.rePosFooter();
122 } 131 }
123 132
@@ -89,6 +89,10 @@ @@ -89,6 +89,10 @@
89 margin-left: 20rem / $pxConvertRem; 89 margin-left: 20rem / $pxConvertRem;
90 } 90 }
91 } 91 }
  92 +
  93 + .name {
  94 + max-width: pxToRem(400px);
  95 + }
92 } 96 }
93 97
94 .sale-invoice { 98 .sale-invoice {
@@ -46,6 +46,17 @@ @@ -46,6 +46,17 @@
46 height: 0; 46 height: 0;
47 } 47 }
48 48
  49 + .not-use {
  50 + display: block;
  51 + width: pxToRem(560px);
  52 + margin: pxToRem(30px) auto;
  53 + text-align: center;
  54 + font-size: pxToRem(32px);
  55 + line-height: 2.5;
  56 + border: 1px solid #444;
  57 + @include border-radius(4px);
  58 + }
  59 +
49 .not-avaliable-coupon-line { 60 .not-avaliable-coupon-line {
50 position: relative; 61 position: relative;
51 margin-top: pxToRem(30px); 62 margin-top: pxToRem(30px);
@@ -45,11 +45,9 @@ @@ -45,11 +45,9 @@
45 <a href="/cart/index/selectCoupon"> 45 <a href="/cart/index/selectCoupon">
46 <span class="title">优惠券</span> 46 <span class="title">优惠券</span>
47 {{# coupon}} 47 {{# coupon}}
48 - {{#if count}}  
49 - <span class="coupon-count">  
50 - {{count}}张可用  
51 - </span>  
52 - {{/if}} 48 + <span class="coupon-count">
  49 + {{count}}张可用
  50 + </span>
53 51
54 {{#if value}} 52 {{#if value}}
55 <span class="used coupon-use"> 53 <span class="used coupon-use">
@@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
20 </a> 20 </a>
21 \{{/ notAvailable}} 21 \{{/ notAvailable}}
22 \{{/coupons}} 22 \{{/coupons}}
  23 +<a class="not-use" href="/cart/index/orderEnsure">不使用任何优惠券</a>
23 </script> 24 </script>
24 <script id="tmpl-coupon-not-avaliable" type="text/tmpl"> 25 <script id="tmpl-coupon-not-avaliable" type="text/tmpl">
25 \{{# notAvailableCoupons}} 26 \{{# notAvailableCoupons}}
@@ -84,7 +84,7 @@ class CartModel @@ -84,7 +84,7 @@ class CartModel
84 $result['isEmptyCart'] = true; 84 $result['isEmptyCart'] = true;
85 break; 85 break;
86 } 86 }
87 - 87 +
88 // 普通购物车空,则显示预售购物车 88 // 普通购物车空,则显示预售购物车
89 if ($ordinaryCount === '0') { 89 if ($ordinaryCount === '0') {
90 $result['cartNav'] = false; 90 $result['cartNav'] = false;
@@ -100,14 +100,14 @@ class CartModel @@ -100,14 +100,14 @@ class CartModel
100 $result['cartNav'] = true; 100 $result['cartNav'] = true;
101 $result['cartType'] = 'ordinary'; 101 $result['cartType'] = 'ordinary';
102 } 102 }
103 - 103 +
104 /* 普通购物车 */ 104 /* 普通购物车 */
105 $result['commonGoodsCount'] = $ordinaryCount; 105 $result['commonGoodsCount'] = $ordinaryCount;
106 $result['commonCart'] = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy); 106 $result['commonCart'] = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy);
107 /* 预售购物车 */ 107 /* 预售购物车 */
108 $result['presellGoodsCount'] = $advanceCount; 108 $result['presellGoodsCount'] = $advanceCount;
109 $result['preSellCart'] = self::procCartData($cart['advance_cart_data'], $onlyGift, $onlyAdvanceBuy); 109 $result['preSellCart'] = self::procCartData($cart['advance_cart_data'], $onlyGift, $onlyAdvanceBuy);
110 - 110 +
111 } while(false); 111 } while(false);
112 112
113 return $result; 113 return $result;
@@ -416,7 +416,7 @@ class CartModel @@ -416,7 +416,7 @@ class CartModel
416 foreach ($payReturn['goods_list'] as $single) { 416 foreach ($payReturn['goods_list'] as $single) {
417 $oneGoods = array(); 417 $oneGoods = array();
418 $oneGoods['id'] = $single['product_sku']; // TODO 未确定用哪个 418 $oneGoods['id'] = $single['product_sku']; // TODO 未确定用哪个
419 - $oneGoods['thumb'] = Images::getImageUrl($single['goods_images'], 120, 120); 419 + $oneGoods['thumb'] = Images::getImageUrl($single['goods_images'], 120, 160);
420 $oneGoods['name'] = $single['product_name']; 420 $oneGoods['name'] = $single['product_name'];
421 $oneGoods['color'] = $single['color_name']; 421 $oneGoods['color'] = $single['color_name'];
422 $oneGoods['size'] = $single['size_name']; 422 $oneGoods['size'] = $single['size_name'];
@@ -153,8 +153,9 @@ class DetailModel @@ -153,8 +153,9 @@ class DetailModel
153 // 商品信息 153 // 商品信息
154 if (!empty($baseInfo['goodsList'])) { 154 if (!empty($baseInfo['goodsList'])) {
155 $colorGroup = array(); 155 $colorGroup = array();
156 - $sizeList = array(); 156 + $sizeGroup = array();
157 $goodsGroup = array(); 157 $goodsGroup = array();
  158 + $sizeList = array();
158 $thumbImageList = array(); 159 $thumbImageList = array();
159 $colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔 160 $colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔
160 $sizeStorageStr = ''; // 尺码库存总数集合, 多个之间用/分隔 161 $sizeStorageStr = ''; // 尺码库存总数集合, 多个之间用/分隔
@@ -177,7 +178,7 @@ class DetailModel @@ -177,7 +178,7 @@ class DetailModel
177 // 商品的尺码列表 178 // 商品的尺码列表
178 if (isset($value['goodsSizeBoList'])) { 179 if (isset($value['goodsSizeBoList'])) {
179 foreach ($value['goodsSizeBoList'] as $size) { 180 foreach ($value['goodsSizeBoList'] as $size) {
180 - $sizeList[] = array( 181 + $sizeList[ $value['colorId'] ][] = array(
181 'id' => $size['id'], 182 'id' => $size['id'],
182 'skuId' => $size['goodsSizeSkuId'], 183 'skuId' => $size['goodsSizeSkuId'],
183 'goodsId' => $size['goodsId'], 184 'goodsId' => $size['goodsId'],
@@ -189,22 +190,21 @@ class DetailModel @@ -189,22 +190,21 @@ class DetailModel
189 $sizeStorageStr .= $size['goodsSizeStorageNum'] . '/'; 190 $sizeStorageStr .= $size['goodsSizeStorageNum'] . '/';
190 $colorStorageGroup[ $size['sizeName'] ][ $value['colorName'] ] = $size['goodsSizeStorageNum']; 191 $colorStorageGroup[ $size['sizeName'] ][ $value['colorName'] ] = $size['goodsSizeStorageNum'];
191 } 192 }
  193 +
  194 + // 颜色分组
  195 + $colorGroup[] = array(
  196 + 'id' => $value['colorId'],
  197 + 'skcId' => $value['productSkc'],
  198 + 'name' => $value['colorName'],
  199 + 'goodsName' => $value['goodsName'],
  200 + 'colorNum' => $colorStorageNum,
  201 + 'sizeNumStr' => rtrim($sizeStorageStr, '/'),
  202 + );
192 } 203 }
193 -  
194 - // 颜色分组  
195 - $colorGroup[] = array(  
196 - 'id' => $value['colorId'],  
197 - 'skcId' => $value['productSkc'],  
198 - 'name' => $value['colorName'],  
199 - 'goodsName' => $value['goodsName'],  
200 - 'colorNum' => $colorStorageNum,  
201 - 'sizeNumStr' => rtrim($sizeStorageStr, '/'),  
202 - );  
203 204
204 // 缩略图 205 // 缩略图
205 $thumbImageList[] = array('img' => Helpers::getImageUrl($value['colorImage'], 60, 60) ); 206 $thumbImageList[] = array('img' => Helpers::getImageUrl($value['colorImage'], 60, 60) );
206 -  
207 - // 统计尺码对应的各个颜色的库存量 207 +
208 foreach ($sizeList as &$sizeArr) { 208 foreach ($sizeList as &$sizeArr) {
209 $sizeArr['colorNumStr'] = implode('/', array_values($colorStorageGroup[ $sizeArr['name'] ]) ); 209 $sizeArr['colorNumStr'] = implode('/', array_values($colorStorageGroup[ $sizeArr['name'] ]) );
210 } 210 }
@@ -212,6 +212,11 @@ class DetailModel @@ -212,6 +212,11 @@ class DetailModel
212 // 商品库存总数 212 // 商品库存总数
213 $totalStorageNum += $colorStorageNum; 213 $totalStorageNum += $colorStorageNum;
214 } 214 }
  215 +
  216 + // 统计尺码对应的各个颜色的库存量
  217 + foreach ($colorGroup as $value) {
  218 + $sizeGroup[]['size'] = $sizeList[ $value['colorId'] ];
  219 + }
215 220
216 // 商品图: 多个 221 // 商品图: 多个
217 if (isset($goodsGroup[1])) { 222 if (isset($goodsGroup[1])) {
@@ -247,7 +252,7 @@ class DetailModel @@ -247,7 +252,7 @@ class DetailModel
247 $result['cartInfo']['salePrice'] = isset($result['goodsPrice']['currentPrice']) ? $result['goodsPrice']['currentPrice'] : ''; 252 $result['cartInfo']['salePrice'] = isset($result['goodsPrice']['currentPrice']) ? $result['goodsPrice']['currentPrice'] : '';
248 $result['cartInfo']['totalNum'] = $totalStorageNum; 253 $result['cartInfo']['totalNum'] = $totalStorageNum;
249 $result['cartInfo']['colors'] = $colorGroup; 254 $result['cartInfo']['colors'] = $colorGroup;
250 - $result['cartInfo']['sizes'] = $sizeList; 255 + $result['cartInfo']['sizes'] = $sizeGroup;
251 } 256 }
252 // 非卖品 257 // 非卖品
253 elseif ($notForSale) { 258 elseif ($notForSale) {
@@ -469,6 +474,7 @@ class DetailModel @@ -469,6 +474,7 @@ class DetailModel
469 '</p>' => '', 474 '</p>' => '',
470 '<img src=' => "<img class=\"lazy\" src=\"data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw==\" data-original=", 475 '<img src=' => "<img class=\"lazy\" src=\"data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw==\" data-original=",
471 '<img border="0" src=' => "<img border=\"0\" class=\"lazy\" src=\"data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw==\" data-original=", 476 '<img border="0" src=' => "<img border=\"0\" class=\"lazy\" src=\"data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw==\" data-original=",
  477 + '.jpg' => '.jpg?imageMogr2/thumbnail/750x/quality/90',
472 )), 478 )),
473 ); 479 );
474 } 480 }