Authored by Rock Zhang

修复默认不使用有货币功能导致的改变地址后一些状态不能保存的bug;当退出结算页面再次从购物车进入结算页面

时清除order-info的cookie值

Code Review By Rock Zhang
@@ -111,6 +111,10 @@ function showChooseGifDialog() { @@ -111,6 +111,10 @@ function showChooseGifDialog() {
111 }, function() { 111 }, function() {
112 window.location.href = cartContentShow().find('.freebie > a').attr('href'); 112 window.location.href = cartContentShow().find('.freebie > a').attr('href');
113 }, function() { 113 }, function() {
  114 + var info = window.cookie('order-info');
  115 + if (info) {
  116 + window.setCookie('order-info', '');
  117 + }
114 window.location.href = '/cart/index/orderEnsure?cartType=' + cartType; 118 window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
115 }); 119 });
116 } 120 }
@@ -185,6 +189,7 @@ if ($('.freebie').length > 0) { @@ -185,6 +189,7 @@ if ($('.freebie').length > 0) {
185 } 189 }
186 190
187 $('.btn-balance').on('touchend', function() { 191 $('.btn-balance').on('touchend', function() {
  192 + var info = window.cookie('order-info');
188 if (shouldLowStocks()) { 193 if (shouldLowStocks()) {
189 tip.show('所选商品中含有库存不足的商品'); 194 tip.show('所选商品中含有库存不足的商品');
190 return false; 195 return false;
@@ -196,6 +201,9 @@ $('.btn-balance').on('touchend', function() { @@ -196,6 +201,9 @@ $('.btn-balance').on('touchend', function() {
196 } 201 }
197 202
198 if (hasChecked()) { 203 if (hasChecked()) {
  204 + if (info) {
  205 + window.setCookie('order-info', '');
  206 + }
199 window.location.href = '/cart/index/orderEnsure?cartType=' + cartType; 207 window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
200 } else { 208 } else {
201 tip.show('请先勾选商品'); 209 tip.show('请先勾选商品');
@@ -105,7 +105,7 @@ $('.icon-del').on('touchstart', function(e) { @@ -105,7 +105,7 @@ $('.icon-del').on('touchstart', function(e) {
105 autoHide: true, 105 autoHide: true,
106 fast: true 106 fast: true
107 }); 107 });
108 - window.setCookie('order-info', ''); 108 + //window.setCookie('order-info', '');
109 window.setCookie('_yoho-cart-refreshByDelete', true); 109 window.setCookie('_yoho-cart-refreshByDelete', true);
110 window.location.href = '/cart/index/index?cartType=' + $('#cartType').val(); 110 window.location.href = '/cart/index/index?cartType=' + $('#cartType').val();
111 } else { 111 } else {
@@ -82,11 +82,8 @@ $('.invoice').on('touchend', '.checkbox', function() { @@ -82,11 +82,8 @@ $('.invoice').on('touchend', '.checkbox', function() {
82 } 82 }
83 }); 83 });
84 84
85 -function orderCompute(firstEnter) { 85 +function orderCompute() {
86 var yohoCoin = orderInfo('yohoCoin'); 86 var yohoCoin = orderInfo('yohoCoin');
87 - if (firstEnter) {  
88 - yohoCoin = 0;  
89 - }  
90 $.ajax({ 87 $.ajax({
91 method: 'POST', 88 method: 'POST',
92 url: '/cart/index/orderCompute', 89 url: '/cart/index/orderCompute',
@@ -124,9 +121,6 @@ function orderCompute(firstEnter) { @@ -124,9 +121,6 @@ function orderCompute(firstEnter) {
124 }); 121 });
125 } 122 }
126 123
127 -// 进入页面计算一次价格  
128 -//orderCompute(1);  
129 -  
130 function submitOrder() { 124 function submitOrder() {
131 var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'), 125 var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
132 msg = $('#msg').find('input').val() || orderInfo('msg'); 126 msg = $('#msg').find('input').val() || orderInfo('msg');
@@ -14,7 +14,7 @@ function init() { @@ -14,7 +14,7 @@ function init() {
14 deliveryId: $('.dispatch-mode .chosed').data('id') || 1, 14 deliveryId: $('.dispatch-mode .chosed').data('id') || 1,
15 deliveryTimeId: 1, 15 deliveryTimeId: 1,
16 paymentTypeId: 1, 16 paymentTypeId: 1,
17 - yohoCoin: $('.coin').data('yoho-coin') || 0, 17 + yohoCoin: 0,
18 addressId: null, 18 addressId: null,
19 couponCode: null, 19 couponCode: null,
20 couponName: null, 20 couponName: null,
@@ -30,9 +30,9 @@ function init() { @@ -30,9 +30,9 @@ function init() {
30 // info 必须是 JSON 字符串 30 // info 必须是 JSON 字符串
31 try { 31 try {
32 info = JSON.parse(info); 32 info = JSON.parse(info);
33 - 33 +
34 // 2015/12/31 hf: fixes bug to 购物车页面调用该JS, 会导致有YOHO币,值却没有传给服务端. 因此需要再设置一下 34 // 2015/12/31 hf: fixes bug to 购物车页面调用该JS, 会导致有YOHO币,值却没有传给服务端. 因此需要再设置一下
35 - info['yohoCoin'] = $('.coin').data('yoho-coin') || 0; 35 + //info['yohoCoin'] = $('.coin').data('yoho-coin') || 0;
36 } catch (e) { 36 } catch (e) {
37 init(); 37 init();
38 } 38 }
@@ -486,7 +486,7 @@ class CartModel @@ -486,7 +486,7 @@ class CartModel
486 486
487 // 优惠券数据 487 // 优惠券数据
488 $coupons = array('couponName' => ''); 488 $coupons = array('couponName' => '');
489 - if (!empty($orderCompute['coupon_amount'])) { 489 + if (isset($orderCompute['coupon_amount']) && (!empty($orderCompute['coupon_amount']) || ($orderCompute['coupon_amount'] === 0 && $orderCompute['shipping_cost'] === 0))) {
490 $coupons['couponName'] = $orderInfo['couponName']; 490 $coupons['couponName'] = $orderInfo['couponName'];
491 } 491 }
492 $result['coupon'] = $coupons; 492 $result['coupon'] = $coupons;
@@ -285,7 +285,7 @@ class IndexController extends AbstractAction @@ -285,7 +285,7 @@ class IndexController extends AbstractAction
285 $cartType = $this->get('cartType', ''); 285 $cartType = $this->get('cartType', '');
286 $cookieData = $this->getCookie('order-info', null); 286 $cookieData = $this->getCookie('order-info', null);
287 $orderInfo = array(); 287 $orderInfo = array();
288 - if (empty($cartType) && !empty($cookieData)) { 288 + if (!empty($cookieData)) {
289 $orderInfo = json_decode($cookieData, true); 289 $orderInfo = json_decode($cookieData, true);
290 $cartType = $orderInfo['cartType']; 290 $cartType = $orderInfo['cartType'];
291 } 291 }