...
|
...
|
@@ -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,18 +95,14 @@ 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);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 移出购物车
|
...
|
...
|
@@ -98,18 +112,15 @@ 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);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 移入收藏夹
|
...
|
...
|
@@ -124,12 +135,8 @@ class IndexController extends AbstractAction |
|
|
$result = CartModel::addToFav($uid, $productId);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 赠品页面
|
...
|
...
|
@@ -182,12 +189,8 @@ class IndexController extends AbstractAction |
|
|
$result['num'] = $num;
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 获取购物车加价购商品数据模板
|
...
|
...
|
@@ -212,12 +215,8 @@ class IndexController extends AbstractAction |
|
|
$result = CartModel::giftProductData($skn, $promotionId);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改购物车商品数量
|
...
|
...
|
@@ -236,12 +235,8 @@ class IndexController extends AbstractAction |
|
|
$result = CartModel::modifyProductNum($uid, $sku, $increaseNum, $decreaseNum, $shoppingKey);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改购物车商品数据
|
...
|
...
|
@@ -262,12 +257,8 @@ class IndexController extends AbstractAction |
|
|
$result = CartModel::modifyCartProduct($uid, $params, $shoppingKey);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 购物车结算请求
|
...
|
...
|
@@ -316,12 +307,8 @@ class IndexController extends AbstractAction |
|
|
$result = CartModel::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 购物车输入优惠券码使用优惠券
|
...
|
...
|
@@ -331,17 +318,13 @@ 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);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 购物车结算--获取优惠券列表
|
...
|
...
|
@@ -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']);
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|