Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
周少峰
8 years ago
Commit
9ccf69b510fee4c7f37d1e6600fd7b4ae60f4adc
2 parents
25791dd6
4e03117f
Merge branch 'feature/cartAdd' of git.yoho.cn:fe/yohobuy-node into feature/cartAdd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
5 deletions
apps/cart/controllers/cart.js
apps/cart/router.js
apps/cart/controllers/cart.js
View file @
9ccf69b
...
...
@@ -127,7 +127,7 @@ const delCartGoods = (req, res, next) => {
};
/**
* 加入购物车
* 加入购物车
商品详情页
*
* @param string productSku 商品的SKU
* @param int buyNumber 购买数量
...
...
@@ -153,7 +153,8 @@ const cartAddIndex = (req, res) => {
uid
,
shoppingKey
);
// 设置加入购物车凭证到客户端浏览器
if
(
!
shoppingKey
&&
result
&&
result
.
data
&&
result
.
data
.
shopping_key
)
{
if
(
!
shoppingKey
&&
_
.
get
(
result
,
'data.shopping_key'
))
{
res
.
cookie
(
'_SPK'
,
result
.
data
.
shopping_key
,
{
expires
:
new
Date
(
Date
.
now
()
+
86400
*
360
),
domain
:
config
.
cookieDomain
...
...
@@ -161,8 +162,17 @@ const cartAddIndex = (req, res) => {
}
// 更新头部购物车COOKIE
if
(
result
&&
result
.
code
===
200
)
{
yield
setShoppingCookie
(
req
,
res
);
//eslint-disable-line
if
(
_
.
get
(
result
,
'data.shopping_key'
))
{
res
.
cookie
(
'_g'
,
JSON
.
stringify
({
_k
:
result
.
data
.
shopping_key
,
_nac
:
result
.
data
.
goods_count
,
_ac
:
0
,
_r
:
1
}),
{
expires
:
new
Date
(
Date
.
now
()
+
86400
*
360
),
domain
:
config
.
cookieDomain
});
}
res
.
send
(
result
);
...
...
apps/cart/router.js
View file @
9ccf69b
...
...
@@ -17,7 +17,7 @@ const easypay = require(`${cRoot}/easypay`);
const
ensure
=
require
(
`
$
{
cRoot
}
/order-ensure`
)
;
router
.
get
(
'/index/getProductInfo'
,
cart
.
getProductInfo
);
router
.
post
(
'/cart/index/add'
,
cart
.
cartAddIndex
);
router
.
post
(
'/cart/index/add'
,
cart
.
cartAddIndex
);
// 加入购物车 商品详情页
router
.
get
(
'/coupon/list'
,
cart
.
getCoupons
);
// 优惠券列表
...
...
Please
register
or
login
to post a comment