Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-blk
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
1
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
jinhu.tung
9 years ago
Commit
650151915c9dee09080c1d45af0c2b78ba684cc2
1 parent
9a4ac821
modify cart number
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
7 deletions
apps/shopping/controllers/cart.js
apps/shopping/models/cart.js
public/js/plugins/README.md
apps/shopping/controllers/cart.js
View file @
6501519
...
...
@@ -190,5 +190,38 @@ exports.toggleSelectGoods = (req, res) => {
});
};
// 购物车商品选择与取消选择
exports
.
modifyProductNum
=
(
req
,
res
)
=>
{
const
uid
=
req
.
cookies
.
uid
;
const
shoppingKey
=
req
.
cookies
.
_SPK
;
const
changeType
=
req
.
body
.
changeType
;
const
changeNum
=
req
.
body
.
changeNum
;
const
sku
=
req
.
body
.
sku
;
let
params
=
{
uid
,
shoppingKey
,
sku
};
if
(
changeType
===
'INCREASE'
)
{
_
.
merge
(
params
,
{
increaseNum
:
changeNum
});
}
else
if
(
changeType
===
'DECREASE'
)
{
_
.
merge
(
params
,
{
decreaseNum
:
changeNum
});
}
else
{
// TODO
// CHANGE
}
cartModel
.
modifyProductNum
(
params
).
then
(
result
=>
{
res
.
json
(
_
.
merge
(
cartModel
.
filterCartData
(
result
,
uid
),
{
code
:
result
.
code
}));
});
}
...
...
apps/shopping/models/cart.js
View file @
6501519
...
...
@@ -259,15 +259,72 @@ const filterCartData = (result, uid) => {
selectedNum
:
selectedAdvanceNum
+
selectedOrdinaryNum
,
checkAll
:
totalNum
===
(
selectedAdvanceNum
+
selectedOrdinaryNum
),
totalMoney
:
totalAdvanceMoney
+
totalOrdinaryMoney
});
};
/**
* 增减购物车商品数量
* @function modifyProductNum
* @param { Number } uid 用户ID
* @param { String } sku 商品SKU
* @param { Number } increaseNum 增加的数目
* @param { Number } decreaseNum 减少的数目
* @param { String } shoppingKey 未登录用户唯一识别码
* @return { Array } 接口返回的数据
*/
const
modifyProductNum
=
(
options
)
=>
{
const
increaseNum
=
options
.
increaseNum
;
const
decreaseNum
=
options
.
decreaseNum
;
const
uid
=
options
.
uid
;
const
shoppingKey
=
options
.
shoppingKey
;
const
sku
=
options
.
sku
;
let
params
=
{
product_sku
:
options
.
sku
}
// 增加
if
(
increaseNum
)
{
_
.
merge
(
params
,
{
method
:
'app.Shopping.increase'
,
increase_number
:
parseInt
(
increaseNum
,
10
)
});
}
// 减少
if
(
decreaseNum
)
{
_
.
merge
(
params
,
{
method
:
'app.Shopping.decrease'
,
decrease_number
:
parseInt
(
decreaseNum
,
10
)
});
}
if
(
uid
)
{
_
.
merge
(
params
,
{
uid
});
}
if
(
shoppingKey
)
{
_
.
merge
(
params
,
{
shopping_key
:
shoppingKey
});
}
if
(
sku
)
{
_
.
merge
(
params
,
{
product_sku
:
sku
});
}
return
api
.
get
(
''
,
params
);
}
module
.
exports
=
{
addToCart
,
getCartData
,
transferToFavorite
,
toggleSelectGoods
,
removeGoods
,
filterCartData
filterCartData
,
modifyProductNum
};
...
...
public/js/plugins/README.md
View file @
6501519
...
...
@@ -12,11 +12,7 @@
API使用:
var address = cascadingAddress({
el: '#address',
url: 'http://localhost:3000/areas/0',
resource: 'areas'
});
var address = cascadingAddress({el: '#address'});
获取选择地址文本:
...
...
Please
register
or
login
to post a comment