...
|
...
|
@@ -9,100 +9,101 @@ use Plugin\Helpers; |
|
|
*/
|
|
|
class ShoppingCartController extends AbstractAction
|
|
|
{
|
|
|
protected $_uid;
|
|
|
|
|
|
/**
|
|
|
* 初始化
|
|
|
*/
|
|
|
public function init()
|
|
|
{
|
|
|
// 检查用户是否登录, 未登录则跳转到登录页
|
|
|
$this->_uid = $this->getUid();
|
|
|
if (!$this->_uid) {
|
|
|
$this->go(Helpers::url('/signin.html'));
|
|
|
}
|
|
|
|
|
|
parent::init();
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 首页
|
|
|
*/
|
|
|
|
|
|
protected $_uid;
|
|
|
|
|
|
/**
|
|
|
* 通过当前用户审判是否跳到登录
|
|
|
*
|
|
|
* @param int $useSession (true:从服务端session中检查, false:从客户端cookie中检查)
|
|
|
* @return void
|
|
|
*/
|
|
|
protected function auditJumpLogin($useSession = true)
|
|
|
{
|
|
|
$uid = $this->getUid($useSession);
|
|
|
if (!$uid) {
|
|
|
$this->go(Helpers::url('/signin.html', array('refer' => $this->server('HTTP_REFERER', SITE_MAIN))));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 首页
|
|
|
*/
|
|
|
public function indexAction()
|
|
|
{
|
|
|
$this->setTitle('购物车');
|
|
|
$this->setNavHeader('购物车');
|
|
|
$this->setTitle('购物车');
|
|
|
$this->setNavHeader('购物车');
|
|
|
|
|
|
$data = array(
|
|
|
'shoppingCartPage' => true,
|
|
|
'shoppingCart' => CartModel::getCartData($this->_uid)
|
|
|
'shoppingCartPage' => true,
|
|
|
'shoppingCart' => CartModel::getCartData($this->_uid)
|
|
|
);
|
|
|
|
|
|
// 渲染模板
|
|
|
$this->_view->display('index', $data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 移出购物车
|
|
|
*/
|
|
|
public function delAction()
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
if ($this->isAjax()) {
|
|
|
$productId = $this->post('id', 0);
|
|
|
$result = CartModel::removeFromCart($this->_uid, $productId);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 移入收藏夹
|
|
|
*/
|
|
|
public function colAction()
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
if ($this->isAjax()) {
|
|
|
$productId = $this->post('id', 0);
|
|
|
$result = CartModel::addToFav($this->_uid, $productId);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改购物车商品数据
|
|
|
*/
|
|
|
public function modifyAction()
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
if ($this->isAjax()) {
|
|
|
|
|
|
$params = array();
|
|
|
$params['old_product_sku']= $this->post('old_product_sku', 0);
|
|
|
$params['new_product_sku']= $this->post('new_product_sku', 0);
|
|
|
$params['buy_number']= $this->post('buy_number', 0);
|
|
|
$params['selected']= $this->post('selected', null);
|
|
|
$result = CartModel::modifyCartProduct($this->_uid, $params);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 移出购物车
|
|
|
*/
|
|
|
public function delAction()
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
if ($this->isAjax()) {
|
|
|
$productId = $this->post('id', 0);
|
|
|
$result = CartModel::removeFromCart($this->_uid, $productId);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 移入收藏夹
|
|
|
*/
|
|
|
public function colAction()
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
if ($this->isAjax()) {
|
|
|
$productId = $this->post('id', 0);
|
|
|
$result = CartModel::addToFav($this->_uid, $productId);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改购物车商品数据
|
|
|
*/
|
|
|
public function modifyAction()
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
if ($this->isAjax()) {
|
|
|
|
|
|
$params = array();
|
|
|
$params['old_product_sku'] = $this->post('old_product_sku', 0);
|
|
|
$params['new_product_sku'] = $this->post('new_product_sku', 0);
|
|
|
$params['buy_number'] = $this->post('buy_number', 0);
|
|
|
$params['selected'] = $this->post('selected', null);
|
|
|
$result = CartModel::modifyCartProduct($this->_uid, $params);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public function giftAdvanceAction()
|
|
|
{
|
...
|
...
|
@@ -146,10 +147,11 @@ class ShoppingCartController extends AbstractAction |
|
|
);
|
|
|
|
|
|
$this->_view->display('gift-advance', array('giftAdvancePage' => true, 'pageHeader' => array(
|
|
|
'navBack' => true, 'navTitle' => '加价购'), 'shoppingCart' => $data));
|
|
|
'navBack' => true, 'navTitle' => '加价购'), 'shoppingCart' => $data));
|
|
|
}
|
|
|
|
|
|
public function orderEnsureAction() {
|
|
|
public function orderEnsureAction()
|
|
|
{
|
|
|
$data = array(
|
|
|
'orderEnsurePage' => true,
|
|
|
'orderEnsure' => array(
|
...
|
...
|
@@ -216,13 +218,13 @@ class ShoppingCartController extends AbstractAction |
|
|
|
|
|
$this->_view->display('order-ensure', $data);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 读取chose-panel内容
|
|
|
*/
|
|
|
public function tplAction()
|
|
|
{
|
|
|
if($this->isAjax()) {
|
|
|
if ($this->isAjax()) {
|
|
|
$data = file_get_contents('../../../template/m.yohobuy.com/partials/shopping-cart/chose-panel.phtml');
|
|
|
|
|
|
echo($data);
|
...
|
...
|
@@ -231,19 +233,20 @@ class ShoppingCartController extends AbstractAction |
|
|
|
|
|
public function goodinfoAction()
|
|
|
{
|
|
|
$result = array();
|
|
|
$result = array();
|
|
|
|
|
|
if ($this->isAjax()) {
|
|
|
$num = $this->get('buy_num', 1);
|
|
|
$skn = $this->get('id', 1);
|
|
|
$result = CartModel::cartProductData($this->_uid, $skn, $num); // 测试skn的ID为51172055
|
|
|
$result['num'] = $num;
|
|
|
$num = $this->get('buy_num', 1);
|
|
|
$skn = $this->get('id', 1);
|
|
|
$result = CartModel::cartProductData($this->_uid, $skn, $num); // 测试skn的ID为51172055
|
|
|
$result['num'] = $num;
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|