Toggle navigation
Toggle navigation
This project
Loading...
Sign in
wangshusheng
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to dashboard
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
Rock Zhang
9 years ago
Commit
ddf0463b491711490382b100d70f503bc516146d
1 parent
0adcaadf
修复删除商品时只能删除一个的bug
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
9 deletions
static/js/cart/good.js
template/m.yohobuy.com/partials/cart/good.phtml
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
yohobuy/m.yohobuy.com/application/modules/Cart/controllers/Index.php
static/js/cart/good.js
View file @
ddf0463
...
...
@@ -148,12 +148,14 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
}
},
function
()
{
var
id
=
$this
.
closest
(
'.shopping-cart-good'
).
data
(
'id'
);
var
count
=
$this
.
data
(
'count'
);
$
.
ajax
({
method
:
'post'
,
url
:
'/cart/index/del'
,
data
:
{
id
:
id
sku
:
id
,
count
:
count
}
}).
then
(
function
(
data
)
{
if
(
data
.
code
===
200
)
{
...
...
template/m.yohobuy.com/partials/cart/good.phtml
View file @
ddf0463
...
...
@@ -52,7 +52,7 @@
<span class="iconfont icon-del"></span>
<span class="iconfont icon-del"
data-count="{{count}}"
></span>
</p>
<p class="row">
{{#if lowStocks}}
...
...
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
View file @
ddf0463
...
...
@@ -127,16 +127,17 @@ class CartModel
* 移出购物车
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @param string $sku 商品sku
* @param string $count 要删除的数目
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public
static
function
removeFromCart
(
$uid
,
$sku
,
$shoppingKey
)
public
static
function
removeFromCart
(
$uid
,
$sku
,
$
count
,
$
shoppingKey
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦~'
);
// 处理sku
$sku_list
=
json_encode
(
array
(
$sku
=>
1
));
$sku_list
=
json_encode
(
array
(
$sku
=>
$count
));
$remove
=
CartData
::
removeFromCart
(
$uid
,
$sku_list
,
$shoppingKey
);
if
(
$remove
&&
isset
(
$remove
[
'code'
]))
{
...
...
yohobuy/m.yohobuy.com/application/modules/Cart/controllers/Index.php
View file @
ddf0463
...
...
@@ -80,7 +80,7 @@ class IndexController extends AbstractAction
if
(
$this
->
isAjax
())
{
$productId
=
$this
->
post
(
'id'
,
0
);
$uid
=
$this
->
getUid
(
true
);
$shoppingKey
=
$this
->
getSession
(
'shoppingKey'
);
$shoppingKey
=
Helpers
::
getShoppingKeyByCookie
(
);
$result
=
CartModel
::
selectGoods
(
$uid
,
$productId
,
$shoppingKey
);
}
...
...
@@ -99,10 +99,11 @@ 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
))
{
...
...
Please
register
or
login
to post a comment