Authored by Rock Zhang

添加异步获取购物车数据的接口

Code Review By Rock Zhang
@@ -13,7 +13,6 @@ class ShoppingCartController extends AbstractAction @@ -13,7 +13,6 @@ class ShoppingCartController extends AbstractAction
13 /* 13 /*
14 * 购物车首页 14 * 购物车首页
15 */ 15 */
16 -  
17 public function indexAction() 16 public function indexAction()
18 { 17 {
19 $this->setTitle('购物车'); 18 $this->setTitle('购物车');
@@ -30,6 +29,26 @@ class ShoppingCartController extends AbstractAction @@ -30,6 +29,26 @@ class ShoppingCartController extends AbstractAction
30 // 渲染模板 29 // 渲染模板
31 $this->_view->display('index', $data); 30 $this->_view->display('index', $data);
32 } 31 }
  32 + /*
  33 + * 异步获取购物车数据
  34 + */
  35 + public function getCartDataAction()
  36 + {
  37 + $result = array();
  38 +
  39 + if ($this->isAjax()) {
  40 + $shoppingKey = Helpers::getShoppingKeyByCookie();
  41 + $uid = $this->getUid(true);
  42 +
  43 + $result = CartModel::getCartData($uid, $shoppingKey);
  44 + }
  45 +
  46 + if (empty($result)) {
  47 + echo ' ';
  48 + } else {
  49 + $this->echoJson($result);
  50 + }
  51 + }
33 52
34 /** 53 /**
35 * 购物车商品选择与取消 54 * 购物车商品选择与取消