Authored by hf

format shopping cart

... ... @@ -23,30 +23,32 @@ class CartModel
*/
public static function getCartData($uid)
{
$result = array(
'cartNav' => true,
'showLoginInfo' => true
);
$result = array();
// 提示登录
if (!$uid) {
$result['showLoginInfo'] = true;
}
// 普通购物车和预售购物车的数据总数
$result['cartNav']['commonGoodsCount'] = '0';
$result['cartNav']['presellGoodsCount'] = '0';
// 调用接口获取购物车的数据
$cartData = CartData::cartData($uid);
// 处理普通购物车和预售购物车的数据
if (isset($cartData['data']) && !empty($cartData['data'])) {
$cart = $cartData['data'];
/* 普通购物车 */
if(isset($cart['ordinary_cart_data'])) {
$result['commonGoodsCount'] = count($cart['ordinary_cart_data']['goods_list']);
$result['commonCart'] = self::procCartData($cart['ordinary_cart_data']);
if (!empty($cartData['data']['ordinary_cart_data']['goods_list'])) {
$result['cartNav']['commonGoodsCount'] = count($cartData['data']['ordinary_cart_data']['goods_list']);
$result['commonCart'] = self::procCartData($cartData['data']['ordinary_cart_data']);
}
/* 预售购物车 */
if(isset($cart['advance_cart_data'])) {
$result['presellGoodsCount'] = count($cart['advance_cart_data']['goods_list']);
$result['preSellCart'] = self::procCartData($cart['advance_cart_data']);
}
if (!empty($cartData['data']['advance_cart_data']['goods_list'])) {
$result['cartNav']['presellGoodsCount'] = count($cartData['data']['advance_cart_data']['goods_list']);
$result['preSellCart'] = self::procCartData($cartData['data']['advance_cart_data']);
}
return $result;
... ... @@ -185,7 +187,6 @@ class CartModel
return $result;
}
/**
* 处理不同类型的购物车数据
*
... ...