Authored by 梁志锋

购物车勾选逻辑

@@ -67,7 +67,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { @@ -67,7 +67,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
67 } 67 }
68 68
69 goodInfo.goods_type = getCartType(); 69 goodInfo.goods_type = getCartType();
70 - goodInfo.selected = isSelected ? 'Y' : 'N'; 70 + goodInfo.selected = isSelected ? 'N' : 'Y';
71 goodInfo.product_sku = id; 71 goodInfo.product_sku = id;
72 goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', ''); 72 goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', '');
73 73
@@ -98,6 +98,11 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { @@ -98,6 +98,11 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
98 $('#good-totalprice').html('¥' + data.commonCart.price); 98 $('#good-totalprice').html('¥' + data.commonCart.price);
99 $('#good-activityPrice').html('¥' + data.commonCart.activityPrice); 99 $('#good-activityPrice').html('¥' + data.commonCart.activityPrice);
100 $('#good-total').html('总计:¥' + data.commonCart.sumPrice + ' (' + data.commonCart.count + '件)'); 100 $('#good-total').html('总计:¥' + data.commonCart.sumPrice + ' (' + data.commonCart.count + '件)');
  101 + if (data.commonCart.isAllSelected) {
  102 + $('.balance span').removeClass('icon-checkbox').addClass('icon-cb-checked');
  103 + } else {
  104 + $('.balance span').removeClass('icon-cb-checked').addClass('icon-checkbox');
  105 + }
101 } 106 }
102 }, 107 },
103 error: function() { 108 error: function() {
@@ -49,7 +49,11 @@ @@ -49,7 +49,11 @@
49 </div> 49 </div>
50 50
51 <div class="balance"> 51 <div class="balance">
52 - <span class="iconfont icon-cb-checked"></span> 52 + {{#if isAllSelected}}
  53 + <span class="checkbox icon-cb-checked iconfont"></span>
  54 + {{^}}
  55 + <span class="checkbox icon-checkbox iconfont"></span>
  56 + {{/if}}
53 <p> 57 <p>
54 <span id="good-total"> 58 <span id="good-total">
55 总计:¥{{sumPrice}} ({{count}}件) 59 总计:¥{{sumPrice}} ({{count}}件)
@@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
10 {{/if}} 10 {{/if}}
11 11
12 <div class="info"> 12 <div class="info">
13 - <img class="thumb lazy" data-original={{thumb}}> 13 + <img class="thumb lazy" data-original={{url}}>
14 {{#if isAdvanceBuy}} 14 {{#if isAdvanceBuy}}
15 <p class="few-tag plus-tag">加价购</p> 15 <p class="few-tag plus-tag">加价购</p>
16 {{^}} 16 {{^}}
@@ -719,6 +719,7 @@ class CartModel @@ -719,6 +719,7 @@ class CartModel
719 $result['price'] = Helpers::transPrice($data['shopping_cart_data']['order_amount']); 719 $result['price'] = Helpers::transPrice($data['shopping_cart_data']['order_amount']);
720 $result['activityPrice'] = Helpers::transPrice($data['shopping_cart_data']['discount_amount']); 720 $result['activityPrice'] = Helpers::transPrice($data['shopping_cart_data']['discount_amount']);
721 $result['count'] = $data['shopping_cart_data']['selected_goods_count']; 721 $result['count'] = $data['shopping_cart_data']['selected_goods_count'];
  722 + $result['isAllSelected'] = ($data['shopping_cart_data']['goods_count'] === $data['shopping_cart_data']['selected_goods_count']) && ($data['shopping_cart_data']['selected_goods_count'] >0);
722 $result['sumPrice'] = Helpers::transPrice($data['shopping_cart_data']['order_amount']); 723 $result['sumPrice'] = Helpers::transPrice($data['shopping_cart_data']['order_amount']);
723 }while(0); 724 }while(0);
724 725
@@ -45,10 +45,10 @@ class IndexController extends AbstractAction @@ -45,10 +45,10 @@ class IndexController extends AbstractAction
45 'shoppingCartPage' => true, 45 'shoppingCartPage' => true,
46 'shoppingCart' => CartModel::getCartData($uid, $shoppingKey) 46 'shoppingCart' => CartModel::getCartData($uid, $shoppingKey)
47 ); 47 );
  48 +
48 // 渲染模板 49 // 渲染模板
49 $this->_view->display('index', $data); 50 $this->_view->display('index', $data);
50 } 51 }
51 -  
52 /* 52 /*
53 * 异步获取购物车数据 53 * 异步获取购物车数据
54 */ 54 */
@@ -78,9 +78,9 @@ class IndexController extends AbstractAction @@ -78,9 +78,9 @@ class IndexController extends AbstractAction
78 $result = array(); 78 $result = array();
79 79
80 if ($this->isAjax()) { 80 if ($this->isAjax()) {
81 - $productId = $this->post('skuList', 0); 81 + $productId = $this->post('id', 0);
82 $uid = $this->getUid(true); 82 $uid = $this->getUid(true);
83 - $shoppingKey = Helpers::getShoppingKeyByCookie(); 83 + $shoppingKey = $this->getSession('shoppingKey');
84 $result = CartModel::selectGoods($uid, $productId, $shoppingKey); 84 $result = CartModel::selectGoods($uid, $productId, $shoppingKey);
85 } 85 }
86 86
@@ -101,7 +101,7 @@ class IndexController extends AbstractAction @@ -101,7 +101,7 @@ class IndexController extends AbstractAction
101 if ($this->isAjax()) { 101 if ($this->isAjax()) {
102 $productId = $this->post('id', 0); 102 $productId = $this->post('id', 0);
103 $uid = $this->getUid(true); 103 $uid = $this->getUid(true);
104 - $shoppingKey = Helpers::getShoppingKeyByCookie(); 104 + $shoppingKey = $this->getSession('shoppingKey');
105 $result = CartModel::removeFromCart($uid, $productId, $shoppingKey); 105 $result = CartModel::removeFromCart($uid, $productId, $shoppingKey);
106 } 106 }
107 107
@@ -192,7 +192,6 @@ class IndexController extends AbstractAction @@ -192,7 +192,6 @@ class IndexController extends AbstractAction
192 192
193 /* 193 /*
194 * 获取购物车加价购商品数据模板 194 * 获取购物车加价购商品数据模板
195 - * 需要返回模板的html代码,不能渲染  
196 */ 195 */
197 public function giftinfoTplAction() 196 public function giftinfoTplAction()
198 { 197 {
@@ -229,7 +228,7 @@ class IndexController extends AbstractAction @@ -229,7 +228,7 @@ class IndexController extends AbstractAction
229 $result = array(); 228 $result = array();
230 229
231 if ($this->isAjax()) { 230 if ($this->isAjax()) {
232 - $shoppingKey = Helpers::getShoppingKeyByCookie(); 231 + $shoppingKey = $this->getSession('shoppingKey');
233 $uid = $this->getUid(true); 232 $uid = $this->getUid(true);
234 233
235 $sku= $this->post('sku', 0); 234 $sku= $this->post('sku', 0);
@@ -253,7 +252,7 @@ class IndexController extends AbstractAction @@ -253,7 +252,7 @@ class IndexController extends AbstractAction
253 $result = array(); 252 $result = array();
254 253
255 if ($this->isAjax()) { 254 if ($this->isAjax()) {
256 - $shoppingKey = Helpers::getShoppingKeyByCookie(); 255 + $shoppingKey = $this->getSession('shoppingKey');
257 $uid = $this->getUid(true); 256 $uid = $this->getUid(true);
258 257
259 $params = array(); 258 $params = array();
@@ -358,7 +357,7 @@ class IndexController extends AbstractAction @@ -358,7 +357,7 @@ class IndexController extends AbstractAction
358 } 357 }
359 358
360 if (empty($result)) { 359 if (empty($result)) {
361 - echo '[]'; 360 + echo ' ';
362 } else { 361 } else {
363 $this->echoJson($result); 362 $this->echoJson($result);
364 } 363 }