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
Email Patches
Plain Diff
Browse Files
Authored by
刘传洋
8 years ago
Commit
7432456396102187e378be7aede3122ed1024d18
1 parent
ced2aa59
m
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
20 deletions
apps/cart/controllers/cart.js
apps/cart/models/cart-service.js
apps/cart/views/action/cart.hbs
apps/cart/views/partial/cart-sel-gift-tpl.hbs
public/js/cart/cart-action.js
apps/cart/controllers/cart.js
View file @
7432456
...
...
@@ -31,14 +31,14 @@ const getProductData = (req, res, next) => {
/**
* 设置购物车COOKIE信息
*/
const
setShoppingCookie
=
(
req
)
=>
{
const
setShoppingCookie
=
(
req
,
res
)
=>
{
let
uid
=
req
.
user
.
uid
||
true
;
let
shoppingKey
=
helper
.
getShoppingKeyByCookie
(
req
);
return
service
.
getCartCount
(
uid
,
shoppingKey
).
then
(
ret
=>
{
if
(
ret
&&
ret
.
data
&&
ret
.
data
.
cart_goods_count
)
{
re
q
.
cookies
(
'_g'
,
{
re
s
.
cookie
(
'_g'
,
{
_k
:
shoppingKey
,
_nac
:
ret
.
data
.
cart_goods_count
,
_ac
:
0
,
...
...
@@ -179,7 +179,7 @@ const modifyProductNum = (req, res, next) => {
return
service
.
modifyProductNum
(
uid
,
sku
,
increaseNum
,
decreaseNum
,
shoppingKey
)
.
then
(
ret
=>
{
if
(
ret
&&
ret
.
code
===
200
)
{
return
setShoppingCookie
().
then
(()
=>
{
return
setShoppingCookie
(
req
,
res
).
then
(()
=>
{
return
res
.
send
(
ret
);
});
}
else
{
...
...
@@ -206,7 +206,7 @@ const removeProduct = (req, res) => {
let
ret
=
yield
service
.
removeFromCart
(
uid
,
shoppingKey
,
skuList
,
hasPromotion
);
if
(
ret
&&
ret
.
code
===
200
)
{
yield
setShoppingCookie
();
yield
setShoppingCookie
(
req
,
res
);
}
return
res
.
send
(
ret
);
...
...
@@ -229,7 +229,7 @@ const moveToFav = (req, res) => {
let
ret
=
yield
service
.
addToFav
(
uid
,
skuList
,
hasPromotion
);
if
(
ret
&&
ret
.
code
===
200
)
{
yield
setShoppingCookie
();
yield
setShoppingCookie
(
req
,
res
);
}
return
res
.
send
(
ret
);
...
...
apps/cart/models/cart-service.js
View file @
7432456
...
...
@@ -593,7 +593,7 @@ const modifyProductNum = (uid, sku, increaseNum, decreaseNum, shoppingKey) => {
return
result
;
}
let
modify
=
cartApi
.
modifyProductNum
(
uid
,
sku
,
increaseNum
,
decreaseNum
,
shoppingKey
);
let
modify
=
yield
cartApi
.
modifyProductNum
(
uid
,
sku
,
increaseNum
,
decreaseNum
,
shoppingKey
);
if
(
modify
&&
modify
.
code
)
{
result
=
modify
;
...
...
@@ -630,7 +630,7 @@ const removeFromCart = (uid, shoppingKey, skuList, hasPromotion) => {
return
result
;
}
let
remove
=
cartApi
.
removeFromCart
(
uid
,
shoppingKey
,
skuList
,
hasPromotion
);
let
remove
=
yield
cartApi
.
removeFromCart
(
uid
,
shoppingKey
,
skuList
,
hasPromotion
);
if
(
remove
&&
remove
.
code
)
{
result
.
code
=
remove
.
code
;
...
...
@@ -680,7 +680,7 @@ const addToFav = (uid, skuList, hasPromotion) => {
return
result
;
}
let
add
=
cartApi
.
addToFav
(
uid
,
skuList
,
hasPromotion
);
let
add
=
yield
cartApi
.
addToFav
(
uid
,
skuList
,
hasPromotion
);
if
(
add
&&
add
.
code
)
{
result
=
add
;
...
...
apps/cart/views/action/cart.hbs
View file @
7432456
...
...
@@ -133,9 +133,13 @@
<a href="javascript:void(0);" data-role="gift-view-btn">查看赠品</a>
{{/if}}--}}
{{#if
isSelected
}}
<a
href=
"javascript:void(0);"
data-role=
"pg-resel-btn"
>
重新换购
</a>
<a
href=
"javascript:void(0);"
class=
"order-pay-link"
data-role=
"pg-resel-btn"
>
重新换购
</a>
{{else}}
{{#if
isReach
}}
<a
href=
"javascript:void(0);"
data-role=
"pg-sel-btn"
>
去换购
</a>
{{/if}}
{{#if
isReach
}}
<a
href=
"javascript:void(0);"
class=
"order-pay-link"
data-role=
"pg-sel-btn"
>
去换购
</a>
{{/if}}
{{/if}}
{{#if
isNotReach
}}
...
...
apps/cart/views/partial/cart-sel-gift-tpl.hbs
View file @
7432456
...
...
@@ -22,7 +22,7 @@
<li
class=
"img-item"
>
<span
class=
"hide goods-id"
>
{{
goods_id
}}
</span>
<div
class=
"good"
>
<a
href=
"
{{
link
}}
"
target=
"_blank"
>
<a
href=
"
javascript:void(0)"
target=
"_blank"
>
{{!--{{link}}--}}
<img
class=
"lazy"
src=
"
{{
imgCover
}}
"
/>
</a>
</div>
...
...
public/js/cart/cart-action.js
View file @
7432456
...
...
@@ -269,7 +269,7 @@ function updateCartItem(newSku, oldSku) {
$
.
ajax
({
type
:
'POST'
,
url
:
'/
shopping/cart
/updateProduct'
,
url
:
'/
cart/index
/updateProduct'
,
data
:
{
swapData
:
JSON
.
stringify
([{
buy_number
:
'1'
,
...
...
@@ -302,7 +302,11 @@ var Cart = {
var
$this
=
$
(
this
);
var
$pitem
=
$this
.
closest
(
'li[data-role="pitem"]'
);
var
item
=
{
var
item
;
$this
.
toggleClass
(
'cart-item-checked'
);
item
=
{
product_sku
:
$pitem
.
data
(
'id'
),
selected
:
$this
.
hasClass
(
'cart-item-checked'
)
?
'Y'
:
'N'
,
buy_number
:
$pitem
.
data
(
'productnum'
),
...
...
@@ -578,20 +582,19 @@ var Cart = {
var
$this
=
$
(
this
);
var
index
=
$this
.
index
(
'.dt'
);
var
$srows
=
$this
.
closest
(
'.goods-info'
).
find
(
'.choose-size .size-row'
);
var
$bigImgs
=
$this
.
closest
(
'.goods-choose-box'
).
find
(
'.goods-info-bigImg'
);
var
$bigImgs
=
$this
.
closest
(
'.goods-choose-box'
).
find
(
'.goods-info-bigImg .bigImg'
);
if
(
$this
.
hasClass
(
'active'
))
return
;
$this
.
siblings
(
'.dt'
).
remove
(
'active'
);
$this
.
siblings
(
'.dt'
).
remove
Class
(
'active'
);
$this
.
addClass
(
'active'
);
$srows
.
find
(
'.dt'
).
removeClass
(
'active'
);
$srows
.
hide
();
$srows
.
indexOf
(
index
).
show
();
$srows
.
addClass
(
'hide'
);
$srows
.
eq
(
index
).
removeClass
(
'hide'
);
$bigImgs
.
hide
();
$bigImgs
.
indexOf
(
index
).
show
();
$bigImgs
.
addClass
(
'hide'
);
$bigImgs
.
eq
(
index
).
removeClass
(
'hide'
);
},
selectSize
:
function
()
{
...
...
Please
register
or
login
to post a comment