...
|
...
|
@@ -45,9 +45,11 @@ class IndexController extends AbstractAction |
|
|
'shoppingCartPage' => true,
|
|
|
'shoppingCart' => CartModel::getCartData($uid, $shoppingKey)
|
|
|
);
|
|
|
|
|
|
// 渲染模板
|
|
|
$this->_view->display('index', $data);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 异步获取购物车数据
|
|
|
*/
|
...
|
...
|
@@ -70,6 +72,22 @@ class IndexController extends AbstractAction |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 异步获取购物车商品数目
|
|
|
*/
|
|
|
public function countAction()
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
if ($this->isAjax()) {
|
|
|
$uid = $this->getUid(true);
|
|
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
|
|
$result = CartModel::getCartCount($uid, $shoppingKey);
|
|
|
}
|
|
|
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 购物车商品选择与取消
|
|
|
*/
|
|
|
public function selectAction()
|
...
|
...
|
@@ -77,17 +95,13 @@ class IndexController extends AbstractAction |
|
|
$result = array();
|
|
|
|
|
|
if ($this->isAjax()) {
|
|
|
$productId = $this->post('id', 0);
|
|
|
$productId = $this->post('skuList', 0);
|
|
|
$uid = $this->getUid(true);
|
|
|
$shoppingKey = $this->getSession('shoppingKey');
|
|
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
|
|
$result = CartModel::selectGoods($uid, $productId, $shoppingKey);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -98,17 +112,14 @@ class IndexController extends AbstractAction |
|
|
$result = array();
|
|
|
|
|
|
if ($this->isAjax()) {
|
|
|
$productId = $this->post('id', 0);
|
|
|
$sku = $this->post('sku', 0);
|
|
|
$count = $this->post('count', 0);
|
|
|
$uid = $this->getUid(true);
|
|
|
$shoppingKey = $this->getSession('shoppingKey');
|
|
|
$result = CartModel::removeFromCart($uid, $productId, $shoppingKey);
|
|
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
|
|
$result = CartModel::removeFromCart($uid, $sku, $count, $shoppingKey);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -124,11 +135,7 @@ class IndexController extends AbstractAction |
|
|
$result = CartModel::addToFav($uid, $productId);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
|
|
|
/*
|
...
|
...
|
@@ -182,11 +189,7 @@ class IndexController extends AbstractAction |
|
|
$result['num'] = $num;
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
|
|
|
/*
|
...
|
...
|
@@ -212,11 +215,7 @@ class IndexController extends AbstractAction |
|
|
$result = CartModel::giftProductData($skn, $promotionId);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -236,11 +235,7 @@ class IndexController extends AbstractAction |
|
|
$result = CartModel::modifyProductNum($uid, $sku, $increaseNum, $decreaseNum, $shoppingKey);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -262,11 +257,7 @@ class IndexController extends AbstractAction |
|
|
$result = CartModel::modifyCartProduct($uid, $params, $shoppingKey);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -316,11 +307,7 @@ class IndexController extends AbstractAction |
|
|
$result = CartModel::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -331,16 +318,12 @@ class IndexController extends AbstractAction |
|
|
$result = array();
|
|
|
|
|
|
if ($this->isAjax()) {
|
|
|
$couponCode = $this->get('couponCode', '');
|
|
|
$couponCode = $this->post('couponCode', '');
|
|
|
$uid = $this->getUid(true);
|
|
|
$result = CartModel::searchCoupon($uid, $couponCode);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -464,7 +447,7 @@ class IndexController extends AbstractAction |
|
|
|
|
|
// 设置加入购物车凭证到客户端浏览器
|
|
|
if (isset($result['data']['shopping_key'])) {
|
|
|
$this->setCookie('_spk', $shoppingKey);
|
|
|
$this->setCookie('_spk', $result['data']['shopping_key']);
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|