Authored by 梁志锋

购物车勾选逻辑

... ... @@ -67,7 +67,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
}
goodInfo.goods_type = getCartType();
goodInfo.selected = isSelected ? 'Y' : 'N';
goodInfo.selected = isSelected ? 'N' : 'Y';
goodInfo.product_sku = id;
goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', '');
... ... @@ -98,6 +98,11 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
$('#good-totalprice').html('¥' + data.commonCart.price);
$('#good-activityPrice').html('¥' + data.commonCart.activityPrice);
$('#good-total').html('总计:¥' + data.commonCart.sumPrice + ' (' + data.commonCart.count + '件)');
if (data.commonCart.isAllSelected) {
$('.balance span').removeClass('icon-checkbox').addClass('icon-cb-checked');
} else {
$('.balance span').removeClass('icon-cb-checked').addClass('icon-checkbox');
}
}
},
error: function() {
... ...
... ... @@ -49,7 +49,11 @@
</div>
<div class="balance">
<span class="iconfont icon-cb-checked"></span>
{{#if isAllSelected}}
<span class="checkbox icon-cb-checked iconfont"></span>
{{^}}
<span class="checkbox icon-checkbox iconfont"></span>
{{/if}}
<p>
<span id="good-total">
总计:¥{{sumPrice}} ({{count}}件)
... ...
... ... @@ -10,7 +10,7 @@
{{/if}}
<div class="info">
<img class="thumb lazy" data-original={{thumb}}>
<img class="thumb lazy" data-original={{url}}>
{{#if isAdvanceBuy}}
<p class="few-tag plus-tag">加价购</p>
{{^}}
... ...
... ... @@ -719,6 +719,7 @@ class CartModel
$result['price'] = Helpers::transPrice($data['shopping_cart_data']['order_amount']);
$result['activityPrice'] = Helpers::transPrice($data['shopping_cart_data']['discount_amount']);
$result['count'] = $data['shopping_cart_data']['selected_goods_count'];
$result['isAllSelected'] = ($data['shopping_cart_data']['goods_count'] === $data['shopping_cart_data']['selected_goods_count']) && ($data['shopping_cart_data']['selected_goods_count'] >0);
$result['sumPrice'] = Helpers::transPrice($data['shopping_cart_data']['order_amount']);
}while(0);
... ...
... ... @@ -45,10 +45,10 @@ class IndexController extends AbstractAction
'shoppingCartPage' => true,
'shoppingCart' => CartModel::getCartData($uid, $shoppingKey)
);
// 渲染模板
$this->_view->display('index', $data);
}
/*
* 异步获取购物车数据
*/
... ... @@ -78,9 +78,9 @@ class IndexController extends AbstractAction
$result = array();
if ($this->isAjax()) {
$productId = $this->post('skuList', 0);
$productId = $this->post('id', 0);
$uid = $this->getUid(true);
$shoppingKey = Helpers::getShoppingKeyByCookie();
$shoppingKey = $this->getSession('shoppingKey');
$result = CartModel::selectGoods($uid, $productId, $shoppingKey);
}
... ... @@ -101,7 +101,7 @@ class IndexController extends AbstractAction
if ($this->isAjax()) {
$productId = $this->post('id', 0);
$uid = $this->getUid(true);
$shoppingKey = Helpers::getShoppingKeyByCookie();
$shoppingKey = $this->getSession('shoppingKey');
$result = CartModel::removeFromCart($uid, $productId, $shoppingKey);
}
... ... @@ -192,7 +192,6 @@ class IndexController extends AbstractAction
/*
* 获取购物车加价购商品数据模板
* 需要返回模板的html代码,不能渲染
*/
public function giftinfoTplAction()
{
... ... @@ -229,7 +228,7 @@ class IndexController extends AbstractAction
$result = array();
if ($this->isAjax()) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$shoppingKey = $this->getSession('shoppingKey');
$uid = $this->getUid(true);
$sku= $this->post('sku', 0);
... ... @@ -253,7 +252,7 @@ class IndexController extends AbstractAction
$result = array();
if ($this->isAjax()) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$shoppingKey = $this->getSession('shoppingKey');
$uid = $this->getUid(true);
$params = array();
... ... @@ -358,7 +357,7 @@ class IndexController extends AbstractAction
}
if (empty($result)) {
echo '[]';
echo ' ';
} else {
$this->echoJson($result);
}
... ...