Authored by Rock Zhang

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

时清除order-info的cookie值

Code Review By Rock Zhang
... ... @@ -111,6 +111,10 @@ function showChooseGifDialog() {
}, function() {
window.location.href = cartContentShow().find('.freebie > a').attr('href');
}, function() {
var info = window.cookie('order-info');
if (info) {
window.setCookie('order-info', '');
}
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
});
}
... ... @@ -185,6 +189,7 @@ if ($('.freebie').length > 0) {
}
$('.btn-balance').on('touchend', function() {
var info = window.cookie('order-info');
if (shouldLowStocks()) {
tip.show('所选商品中含有库存不足的商品');
return false;
... ... @@ -196,6 +201,9 @@ $('.btn-balance').on('touchend', function() {
}
if (hasChecked()) {
if (info) {
window.setCookie('order-info', '');
}
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
} else {
tip.show('请先勾选商品');
... ...
... ... @@ -105,7 +105,7 @@ $('.icon-del').on('touchstart', function(e) {
autoHide: true,
fast: true
});
window.setCookie('order-info', '');
//window.setCookie('order-info', '');
window.setCookie('_yoho-cart-refreshByDelete', true);
window.location.href = '/cart/index/index?cartType=' + $('#cartType').val();
} else {
... ...
... ... @@ -82,11 +82,8 @@ $('.invoice').on('touchend', '.checkbox', function() {
}
});
function orderCompute(firstEnter) {
function orderCompute() {
var yohoCoin = orderInfo('yohoCoin');
if (firstEnter) {
yohoCoin = 0;
}
$.ajax({
method: 'POST',
url: '/cart/index/orderCompute',
... ... @@ -124,9 +121,6 @@ function orderCompute(firstEnter) {
});
}
// 进入页面计算一次价格
//orderCompute(1);
function submitOrder() {
var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
msg = $('#msg').find('input').val() || orderInfo('msg');
... ...
... ... @@ -14,7 +14,7 @@ function init() {
deliveryId: $('.dispatch-mode .chosed').data('id') || 1,
deliveryTimeId: 1,
paymentTypeId: 1,
yohoCoin: $('.coin').data('yoho-coin') || 0,
yohoCoin: 0,
addressId: null,
couponCode: null,
couponName: null,
... ... @@ -30,9 +30,9 @@ function init() {
// info 必须是 JSON 字符串
try {
info = JSON.parse(info);
// 2015/12/31 hf: fixes bug to 购物车页面调用该JS, 会导致有YOHO币,值却没有传给服务端. 因此需要再设置一下
info['yohoCoin'] = $('.coin').data('yoho-coin') || 0;
//info['yohoCoin'] = $('.coin').data('yoho-coin') || 0;
} catch (e) {
init();
}
... ...
... ... @@ -486,7 +486,7 @@ class CartModel
// 优惠券数据
$coupons = array('couponName' => '');
if (!empty($orderCompute['coupon_amount'])) {
if (isset($orderCompute['coupon_amount']) && (!empty($orderCompute['coupon_amount']) || ($orderCompute['coupon_amount'] === 0 && $orderCompute['shipping_cost'] === 0))) {
$coupons['couponName'] = $orderInfo['couponName'];
}
$result['coupon'] = $coupons;
... ...
... ... @@ -285,7 +285,7 @@ class IndexController extends AbstractAction
$cartType = $this->get('cartType', '');
$cookieData = $this->getCookie('order-info', null);
$orderInfo = array();
if (empty($cartType) && !empty($cookieData)) {
if (!empty($cookieData)) {
$orderInfo = json_decode($cookieData, true);
$cartType = $orderInfo['cartType'];
}
... ...