Showing
4 changed files
with
13 additions
and
9 deletions
@@ -148,12 +148,14 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | @@ -148,12 +148,14 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | ||
148 | } | 148 | } |
149 | }, function() { | 149 | }, function() { |
150 | var id = $this.closest('.shopping-cart-good').data('id'); | 150 | var id = $this.closest('.shopping-cart-good').data('id'); |
151 | + var count = $this.data('count'); | ||
151 | 152 | ||
152 | $.ajax({ | 153 | $.ajax({ |
153 | method: 'post', | 154 | method: 'post', |
154 | url: '/cart/index/del', | 155 | url: '/cart/index/del', |
155 | data: { | 156 | data: { |
156 | - id: id | 157 | + sku: id, |
158 | + count: count | ||
157 | } | 159 | } |
158 | }).then(function(data) { | 160 | }).then(function(data) { |
159 | if (data.code === 200) { | 161 | if (data.code === 200) { |
@@ -127,16 +127,17 @@ class CartModel | @@ -127,16 +127,17 @@ class CartModel | ||
127 | * 移出购物车 | 127 | * 移出购物车 |
128 | * | 128 | * |
129 | * @param int $uid 用户ID | 129 | * @param int $uid 用户ID |
130 | - * @param string $sku 商品sku列表 | 130 | + * @param string $sku 商品sku |
131 | + * @param string $count 要删除的数目 | ||
131 | * @param string $shoppingKey 未登录用户唯一识别码 | 132 | * @param string $shoppingKey 未登录用户唯一识别码 |
132 | * @return array 接口返回的数据 | 133 | * @return array 接口返回的数据 |
133 | */ | 134 | */ |
134 | - public static function removeFromCart($uid, $sku, $shoppingKey) | 135 | + public static function removeFromCart($uid, $sku, $count, $shoppingKey) |
135 | { | 136 | { |
136 | $result = array('code' => 400, 'message' => '出错啦~'); | 137 | $result = array('code' => 400, 'message' => '出错啦~'); |
137 | 138 | ||
138 | // 处理sku | 139 | // 处理sku |
139 | - $sku_list = json_encode(array($sku => 1)); | 140 | + $sku_list = json_encode(array($sku => $count)); |
140 | 141 | ||
141 | $remove = CartData::removeFromCart($uid, $sku_list, $shoppingKey); | 142 | $remove = CartData::removeFromCart($uid, $sku_list, $shoppingKey); |
142 | if ($remove && isset($remove['code'])) { | 143 | if ($remove && isset($remove['code'])) { |
@@ -80,7 +80,7 @@ class IndexController extends AbstractAction | @@ -80,7 +80,7 @@ class IndexController extends AbstractAction | ||
80 | if ($this->isAjax()) { | 80 | if ($this->isAjax()) { |
81 | $productId = $this->post('id', 0); | 81 | $productId = $this->post('id', 0); |
82 | $uid = $this->getUid(true); | 82 | $uid = $this->getUid(true); |
83 | - $shoppingKey = $this->getSession('shoppingKey'); | 83 | + $shoppingKey = Helpers::getShoppingKeyByCookie(); |
84 | $result = CartModel::selectGoods($uid, $productId, $shoppingKey); | 84 | $result = CartModel::selectGoods($uid, $productId, $shoppingKey); |
85 | } | 85 | } |
86 | 86 | ||
@@ -99,10 +99,11 @@ class IndexController extends AbstractAction | @@ -99,10 +99,11 @@ class IndexController extends AbstractAction | ||
99 | $result = array(); | 99 | $result = array(); |
100 | 100 | ||
101 | if ($this->isAjax()) { | 101 | if ($this->isAjax()) { |
102 | - $productId = $this->post('id', 0); | 102 | + $sku = $this->post('sku', 0); |
103 | + $count = $this->post('count', 0); | ||
103 | $uid = $this->getUid(true); | 104 | $uid = $this->getUid(true); |
104 | - $shoppingKey = $this->getSession('shoppingKey'); | ||
105 | - $result = CartModel::removeFromCart($uid, $productId, $shoppingKey); | 105 | + $shoppingKey = Helpers::getShoppingKeyByCookie(); |
106 | + $result = CartModel::removeFromCart($uid, $sku, $count, $shoppingKey); | ||
106 | } | 107 | } |
107 | 108 | ||
108 | if (empty($result)) { | 109 | if (empty($result)) { |
-
Please register or login to post a comment