Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop
Showing
6 changed files
with
55 additions
and
33 deletions
@@ -5,7 +5,6 @@ | @@ -5,7 +5,6 @@ | ||
5 | */ | 5 | */ |
6 | 6 | ||
7 | var $ = require('jquery'), | 7 | var $ = require('jquery'), |
8 | - lazyLoad = require('yoho.lazyload'), | ||
9 | Hammer = require('yoho.hammer'); | 8 | Hammer = require('yoho.hammer'); |
10 | 9 | ||
11 | var chosePanel = require('./chose-panel'), | 10 | var chosePanel = require('./chose-panel'), |
@@ -16,14 +15,21 @@ var $cartContent = $('.cart-content'), | @@ -16,14 +15,21 @@ var $cartContent = $('.cart-content'), | ||
16 | cartType = $('#cartType').val(), | 15 | cartType = $('#cartType').val(), |
17 | hasShowCartPresellTip = false; | 16 | hasShowCartPresellTip = false; |
18 | 17 | ||
18 | +var $cartContentShow = $cartContent.not('.hide'); | ||
19 | + | ||
19 | var navHammer, | 20 | var navHammer, |
20 | advanceBuyHammer, | 21 | advanceBuyHammer, |
21 | - freebieHammer; | 22 | + freebieHammer, |
23 | + switchChose = false; | ||
24 | + | ||
25 | +require('../product/recommend-for-you'); | ||
22 | 26 | ||
23 | -var hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false; //是否有选中商品 | 27 | +function hasChecked() { |
28 | + return $cartContentShow.find('.icon-cb-checked').length > 0 ? true : false; | ||
29 | +} | ||
24 | 30 | ||
25 | function shouldSelectGift() { | 31 | function shouldSelectGift() { |
26 | - var $freebie = $('.freebie'); | 32 | + var $freebie = $cartContentShow.find('.freebie'); |
27 | 33 | ||
28 | if ($freebie.length <= 0) { | 34 | if ($freebie.length <= 0) { |
29 | return false; | 35 | return false; |
@@ -33,9 +39,15 @@ function shouldSelectGift() { | @@ -33,9 +39,15 @@ function shouldSelectGift() { | ||
33 | } | 39 | } |
34 | 40 | ||
35 | function shouldLowStocks() { | 41 | function shouldLowStocks() { |
36 | - var $lowStocks = $('.low-stocks'), | 42 | + var $lowStocks, |
37 | result = false; | 43 | result = false; |
38 | 44 | ||
45 | + if ('ordinary' === cartType) { | ||
46 | + $lowStocks = $('.common .low-stocks'); | ||
47 | + } else if ('advance' === cartType) { | ||
48 | + $lowStocks = $('.presell .low-stocks'); | ||
49 | + } | ||
50 | + | ||
39 | if ($lowStocks.length <= 0) { | 51 | if ($lowStocks.length <= 0) { |
40 | return result; | 52 | return result; |
41 | } | 53 | } |
@@ -58,7 +70,7 @@ function showChooseGifDialog() { | @@ -58,7 +70,7 @@ function showChooseGifDialog() { | ||
58 | rightBtnText: '去选择' | 70 | rightBtnText: '去选择' |
59 | } | 71 | } |
60 | }, function() { | 72 | }, function() { |
61 | - window.location.href = $('.freebie').find('a').attr('href'); | 73 | + window.location.href = $cartContentShow.find('.freebie > a').attr('href'); |
62 | }, function() { | 74 | }, function() { |
63 | window.location.href = '/cart/index/orderEnsure?cartType=' + cartType; | 75 | window.location.href = '/cart/index/orderEnsure?cartType=' + cartType; |
64 | }); | 76 | }); |
@@ -66,7 +78,7 @@ function showChooseGifDialog() { | @@ -66,7 +78,7 @@ function showChooseGifDialog() { | ||
66 | 78 | ||
67 | require('./good'); | 79 | require('./good'); |
68 | 80 | ||
69 | -lazyLoad($('img.lazy')); | 81 | +//lazyLoad($('img.lazy')); |
70 | 82 | ||
71 | if (typeof window.cookie === 'function' && 'y' === window.cookie('_hasShowCartPresellTip')) { | 83 | if (typeof window.cookie === 'function' && 'y' === window.cookie('_hasShowCartPresellTip')) { |
72 | $('#presell-tip').removeClass('show').addClass('hide'); | 84 | $('#presell-tip').removeClass('show').addClass('hide'); |
@@ -93,10 +105,6 @@ if ($('.cart-nav').length > 0) { | @@ -93,10 +105,6 @@ if ($('.cart-nav').length > 0) { | ||
93 | return; | 105 | return; |
94 | } | 106 | } |
95 | 107 | ||
96 | - $('.shopping-cart-good .name').each(function() { | ||
97 | - this.mlellipsis(2); | ||
98 | - }); | ||
99 | - | ||
100 | if (cartType === 'ordinary') { | 108 | if (cartType === 'ordinary') { |
101 | cartType = 'advance'; | 109 | cartType = 'advance'; |
102 | $('#cartType').val('advance'); | 110 | $('#cartType').val('advance'); |
@@ -111,7 +119,14 @@ if ($('.cart-nav').length > 0) { | @@ -111,7 +119,14 @@ if ($('.cart-nav').length > 0) { | ||
111 | //切换普通商品和预售商品购物车显示 | 119 | //切换普通商品和预售商品购物车显示 |
112 | $cartContent.toggleClass('hide'); | 120 | $cartContent.toggleClass('hide'); |
113 | 121 | ||
114 | - hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false; | 122 | + $cartContentShow = $cartContent.not('.hide'); |
123 | + | ||
124 | + if (switchChose === false) { | ||
125 | + $cartContentShow.find('.shopping-cart-good .name').each(function() { | ||
126 | + this.mlellipsis(2); | ||
127 | + }); | ||
128 | + switchChose = true; | ||
129 | + } | ||
115 | 130 | ||
116 | //trigger lazyload | 131 | //trigger lazyload |
117 | $(window).trigger('scroll'); | 132 | $(window).trigger('scroll'); |
@@ -141,7 +156,7 @@ if ($('.freebie').length > 0) { | @@ -141,7 +156,7 @@ if ($('.freebie').length > 0) { | ||
141 | 156 | ||
142 | $('.btn-balance').on('touchend', function() { | 157 | $('.btn-balance').on('touchend', function() { |
143 | if (shouldLowStocks()) { | 158 | if (shouldLowStocks()) { |
144 | - tip.show('库存不足无法结算'); | 159 | + tip.show('所选商品中含有库存不足的商品'); |
145 | return false; | 160 | return false; |
146 | } | 161 | } |
147 | 162 | ||
@@ -150,7 +165,7 @@ $('.btn-balance').on('touchend', function() { | @@ -150,7 +165,7 @@ $('.btn-balance').on('touchend', function() { | ||
150 | return false; | 165 | return false; |
151 | } | 166 | } |
152 | 167 | ||
153 | - if (hasChecked) { | 168 | + if (hasChecked()) { |
154 | window.location.href = '/cart/index/orderEnsure?cartType=' + cartType; | 169 | window.location.href = '/cart/index/orderEnsure?cartType=' + cartType; |
155 | } else { | 170 | } else { |
156 | tip.show('请先勾选商品'); | 171 | tip.show('请先勾选商品'); |
@@ -161,10 +176,6 @@ $('.chose').on('touchend', function() { | @@ -161,10 +176,6 @@ $('.chose').on('touchend', function() { | ||
161 | chosePanel.show(); | 176 | chosePanel.show(); |
162 | }); | 177 | }); |
163 | 178 | ||
164 | -if ($('.shopping-cart-good').length <= 0) { | ||
165 | - require('../product/recommend-for-you'); | ||
166 | -} | ||
167 | - | ||
168 | function notAllowScroll() { | 179 | function notAllowScroll() { |
169 | var docH = $(document).height(), | 180 | var docH = $(document).height(), |
170 | winH = $(window).height(); | 181 | winH = $(window).height(); |
@@ -192,13 +192,22 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) { | @@ -192,13 +192,22 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) { | ||
192 | 192 | ||
193 | //全选按钮点击事件 | 193 | //全选按钮点击事件 |
194 | $selectAllBtn.on('touchend', function() { | 194 | $selectAllBtn.on('touchend', function() { |
195 | - var isSelect = $(this).hasClass('icon-cb-checked'); | 195 | + var cartType = $('#cartType').val(), |
196 | + isSelect = $(this).hasClass('icon-cb-checked'); | ||
196 | 197 | ||
197 | - if (!isSelect && $('.low-stocks').length > 0) { | ||
198 | - tip.show('所选商品中含有库存不足的商品'); | ||
199 | - return false; | 198 | + if ('ordinary' === cartType) { |
199 | + if (!isSelect && $('.common .low-stocks').length > 0) { | ||
200 | + tip.show('所选商品中含有库存不足的商品'); | ||
201 | + return false; | ||
202 | + } | ||
203 | + } else if ('advance' === cartType) { | ||
204 | + if (!isSelect && $('.presell .low-stocks').length > 0) { | ||
205 | + tip.show('所选商品中含有库存不足的商品'); | ||
206 | + return false; | ||
207 | + } | ||
200 | } | 208 | } |
201 | - bottomCheckBoxHandeler(isSelect, $('#cartType').val(), didUpdateAllGoodsCheckStatus); | 209 | + |
210 | + bottomCheckBoxHandeler(isSelect, cartType, didUpdateAllGoodsCheckStatus); | ||
202 | }); | 211 | }); |
203 | 212 | ||
204 | $('.down').on('touchend', function() { | 213 | $('.down').on('touchend', function() { |
@@ -3,7 +3,6 @@ | @@ -3,7 +3,6 @@ | ||
3 | * @author: chenglong<chenglong.wang@yoho.cn> | 3 | * @author: chenglong<chenglong.wang@yoho.cn> |
4 | * @date: 2015/11/12 | 4 | * @date: 2015/11/12 |
5 | */ | 5 | */ |
6 | - | ||
7 | var $ = require('jquery'), | 6 | var $ = require('jquery'), |
8 | Hammer = require('yoho.hammer'), | 7 | Hammer = require('yoho.hammer'), |
9 | Swiper = require('yoho.iswiper'); | 8 | Swiper = require('yoho.iswiper'); |
@@ -27,7 +27,7 @@ | @@ -27,7 +27,7 @@ | ||
27 | } | 27 | } |
28 | } | 28 | } |
29 | 29 | ||
30 | - .few-tag{ | 30 | + .few-tag { |
31 | width: 148rem / $pxConvertRem; | 31 | width: 148rem / $pxConvertRem; |
32 | position: absolute; | 32 | position: absolute; |
33 | left: 92rem / $pxConvertRem; | 33 | left: 92rem / $pxConvertRem; |
@@ -90,6 +90,7 @@ | @@ -90,6 +90,7 @@ | ||
90 | width: 80%; | 90 | width: 80%; |
91 | color: #5a5a5a; | 91 | color: #5a5a5a; |
92 | font-size: 0.6rem; | 92 | font-size: 0.6rem; |
93 | + line-height: 0.7rem; | ||
93 | } | 94 | } |
94 | 95 | ||
95 | .color-size-row > span { | 96 | .color-size-row > span { |
@@ -313,10 +313,10 @@ class CartModel | @@ -313,10 +313,10 @@ class CartModel | ||
313 | * | 313 | * |
314 | * @param int $uid 用户ID | 314 | * @param int $uid 用户ID |
315 | * @param string $cartType 购物车类型,ordinary表示普通购物车 | 315 | * @param string $cartType 购物车类型,ordinary表示普通购物车 |
316 | - * @param null|string $cookieData cookie中记录的一些订单有关数据 | 316 | + * @param array $orderInfo cookie中记录的一些订单有关数据 |
317 | * @return array 接口返回的数据 | 317 | * @return array 接口返回的数据 |
318 | */ | 318 | */ |
319 | - public static function cartPay($uid, $cartType, $cookieData) | 319 | + public static function cartPay($uid, $cartType, $orderInfo) |
320 | { | 320 | { |
321 | $result = array(); | 321 | $result = array(); |
322 | 322 | ||
@@ -324,13 +324,11 @@ class CartModel | @@ -324,13 +324,11 @@ class CartModel | ||
324 | 324 | ||
325 | if ($pay && isset($pay['code']) && $pay['code'] === 200) { | 325 | if ($pay && isset($pay['code']) && $pay['code'] === 200) { |
326 | $payReturn = $pay['data']; | 326 | $payReturn = $pay['data']; |
327 | - $orderInfo = array(); | ||
328 | $address = array(); | 327 | $address = array(); |
329 | $orderCompute = array(); | 328 | $orderCompute = array(); |
330 | 329 | ||
331 | // cookie保存的数据 | 330 | // cookie保存的数据 |
332 | - if (!empty($cookieData)) { | ||
333 | - $orderInfo = json_decode($cookieData, true); | 331 | + if (!empty($orderInfo)) { |
334 | $orderCompute = self::orderCompute($uid, $cartType, $orderInfo['deliveryId'], $orderInfo['paymentTypeId'], $orderInfo['couponCode'], $orderInfo['yohoCoin']); | 332 | $orderCompute = self::orderCompute($uid, $cartType, $orderInfo['deliveryId'], $orderInfo['paymentTypeId'], $orderInfo['couponCode'], $orderInfo['yohoCoin']); |
335 | } | 333 | } |
336 | 334 |
@@ -277,6 +277,12 @@ class IndexController extends AbstractAction | @@ -277,6 +277,12 @@ class IndexController extends AbstractAction | ||
277 | 277 | ||
278 | // 购物车商品为空跳转到购物车页面 | 278 | // 购物车商品为空跳转到购物车页面 |
279 | $cartType = $this->get('cartType', 'ordinary'); | 279 | $cartType = $this->get('cartType', 'ordinary'); |
280 | + $cookieData = $this->getCookie('order-info', null); | ||
281 | + $orderInfo = array(); | ||
282 | + if (!empty($cookieData)) { | ||
283 | + $orderInfo = json_decode($cookieData, true); | ||
284 | + $cartType = $orderInfo['cartType']; | ||
285 | + } | ||
280 | $cartKey = 'commonCart'; | 286 | $cartKey = 'commonCart'; |
281 | if ($cartType === 'advance') { | 287 | if ($cartType === 'advance') { |
282 | $cartKey = 'preSellCart'; | 288 | $cartKey = 'preSellCart'; |
@@ -289,12 +295,10 @@ class IndexController extends AbstractAction | @@ -289,12 +295,10 @@ class IndexController extends AbstractAction | ||
289 | $this->go(Helpers::url('/cart/index/index')); | 295 | $this->go(Helpers::url('/cart/index/index')); |
290 | } | 296 | } |
291 | 297 | ||
292 | - $cookieData = $this->getCookie('order-info', null); | ||
293 | - $uid = $this->getUid(true); | ||
294 | $data = array( | 298 | $data = array( |
295 | 'orderEnsurePage' => true, | 299 | 'orderEnsurePage' => true, |
296 | 'isOrdinaryCart' => ($cartType !== 'advance'), | 300 | 'isOrdinaryCart' => ($cartType !== 'advance'), |
297 | - 'orderEnsure' => CartModel::cartPay($uid, $cartType, $cookieData) | 301 | + 'orderEnsure' => CartModel::cartPay($uid, $cartType, $orderInfo) |
298 | ); | 302 | ); |
299 | 303 | ||
300 | $this->_view->display('order-ensure', $data); | 304 | $this->_view->display('order-ensure', $data); |
-
Please register or login to post a comment