修复未登录、未添加商品到购物车的情况下进入购物车页面,显示普通和预售商品tab的bug,同时添加随便逛逛和为您优选
Code Review By Rock Zhang
Showing
3 changed files
with
6 additions
and
2 deletions
framework @ e9d066dd
@@ -50,7 +50,7 @@ class CartModel | @@ -50,7 +50,7 @@ class CartModel | ||
50 | */ | 50 | */ |
51 | public static function getCartData($uid, $shoppingKey, $cartType = 'all', $onlyGift = false, $onlyAdvanceBuy = false) | 51 | public static function getCartData($uid, $shoppingKey, $cartType = 'all', $onlyGift = false, $onlyAdvanceBuy = false) |
52 | { | 52 | { |
53 | - $result = array('cartNav' => true); | 53 | + $result = array(); |
54 | 54 | ||
55 | // 用户是否登录 | 55 | // 用户是否登录 |
56 | if (empty($uid)) { | 56 | if (empty($uid)) { |
@@ -63,11 +63,14 @@ class CartModel | @@ -63,11 +63,14 @@ class CartModel | ||
63 | // 处理普通购物车和预售购物车的数据 | 63 | // 处理普通购物车和预售购物车的数据 |
64 | do { | 64 | do { |
65 | if (!isset($cartData['data']) || empty($cartData['data'])) { | 65 | if (!isset($cartData['data']) || empty($cartData['data'])) { |
66 | + $result['isEmptyCart'] = true; | ||
66 | break; | 67 | break; |
67 | } | 68 | } |
68 | 69 | ||
69 | $cart = $cartData['data']; | 70 | $cart = $cartData['data']; |
70 | 71 | ||
72 | + $result['cartNav'] = true; | ||
73 | + | ||
71 | if ($cartType !== 'all') { // 加价购或者赠品数据 | 74 | if ($cartType !== 'all') { // 加价购或者赠品数据 |
72 | $result = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy); | 75 | $result = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy); |
73 | break; | 76 | break; |
@@ -45,6 +45,7 @@ class IndexController extends AbstractAction | @@ -45,6 +45,7 @@ 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 | } |
-
Please register or login to post a comment