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
OF1706
8 years ago
Commit
028cf1ab24ee82367e8345e0fba0da666a6f27ef
2 parents
584c397f
78d25f70
Merge branch 'feature/shoppingCart' of
http://git.yoho.cn/fe/yohobuy-node
into feature/shoppingCart
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
46 deletions
apps/cart/controllers/cart.js
apps/cart/models/cart-helper.js
apps/cart/models/cart-service.js
mix/mix/cart/cart-list.hbs
public/js/cart/cart-action.js
public/js/cart/cart-api.js
apps/cart/controllers/cart.js
View file @
028cf1a
...
...
@@ -60,8 +60,6 @@ const setShoppingCookie = (req, res) => {
_r
:
1
});
}
}).
finally
(()
=>
{
return
;
});
};
...
...
@@ -151,12 +149,10 @@ const cartAdd = (req, res) => {
}
if
(
result
&&
result
.
code
===
200
)
{
return
setShoppingCookie
(
req
,
res
).
then
(()
=>
{
return
res
.
send
(
result
);
});
}
else
{
res
.
send
(
result
);
yield
setShoppingCookie
(
req
,
res
);
}
res
.
send
(
result
);
})();
};
...
...
@@ -179,7 +175,7 @@ const cartTotal = (req, res) => {
/**
* 购物车商品选择与取消
*/
const
selectProduct
=
(
req
,
res
)
=>
{
const
selectProduct
=
(
req
,
res
,
next
)
=>
{
let
uid
=
req
.
user
.
uid
;
let
productId
=
req
.
body
.
skuList
;
...
...
@@ -190,11 +186,7 @@ const selectProduct = (req, res) => {
service
.
selectGoods
(
uid
,
productId
,
shoppingKey
,
hasPromotion
,
cartDelList
)
.
then
(
ret
=>
{
res
.
send
(
ret
);
}).
catch
(()
=>
{
res
.
send
({
code
:
400
});
});
}).
catch
(
next
);
};
/**
...
...
@@ -241,11 +233,6 @@ const removeProduct = (req, res) => {
if
(
ret
&&
ret
.
code
===
200
)
{
yield
setShoppingCookie
(
req
,
res
);
/* res.cookie('cart-del-list', cartDelList, {
domain: '.yohobuy.com',
path: '/'
});*/
}
return
res
.
send
(
ret
);
...
...
@@ -321,12 +308,6 @@ const getTogetherProduct = (req, res) => {
co
(
function
*
()
{
let
page
=
req
.
query
.
page
;
/* let ret = {
code: 200,
message: '凑单商品'
};*/
let
ret
=
yield
service
.
getTogetherProduct
(
page
);
return
res
.
send
(
ret
);
...
...
@@ -363,12 +344,6 @@ const getIncreasePurchase = (req, res) => {
co
(
function
*
()
{
let
page
=
req
.
query
.
page
;
/* let ret = {
code: 200,
message: '凑单商品'
};*/
let
ret
=
yield
service
.
getTogetherProduct
(
page
);
return
res
.
send
(
ret
);
...
...
apps/cart/models/cart-helper.js
View file @
028cf1a
...
...
@@ -207,9 +207,8 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys
}
// 商品链接
let
cnAlphaBet
=
it
.
cn_alphabet
?
it
.
cn_alphabet
:
md5
(
it
.
product_name
);
goods
.
link
=
helpers
.
urlFormat
(
`
/
product
/
pro_$
{
it
.
product_id
}
_$
{
it
.
goods_id
}
/${cnAlphaBet}.html`, null, 'item'
)
;
// let cnAlphaBet = it.cn_alphabet ? it.cn_alphabet : md5(it.product_name);
goods
.
link
=
helpers
.
getUrlBySkc
(
it
.
product_id
,
it
.
goods_id
,
it
.
cn_alphabet
);
return
goods
;
});
...
...
@@ -307,10 +306,8 @@ const formatPriceGiftOne = (it) => {
// 商品链接
if
(
g
.
goods_id
)
{
let
cnAlphaBet
=
g
.
cn_alphabet
?
g
.
cn_alphabet
:
md5
(
g
.
product_name
);
goods
.
subjoinLink
=
helpers
.
urlFormat
(
`
/
product
/
pro_$
{
g
.
product_id
}
_$
{
g
.
goods_id
}
/${cnAlphaBet}.html`
,
null
,
'item'
);
// let cnAlphaBet = g.cn_alphabet ? g.cn_alphabet : md5(g.product_name);
goods
.
subjoinLink
=
helpers
.
getUrlBySkc
(
g
.
product_id
,
g
.
goods_id
,
g
.
cn_alphabet
);
}
else
{
let
uri
=
`
/
product
/
show_$
{
g
.
product_id
}
_$
{
g
.
product_skn
}
/${makeToken
(
g.product_skn
)
}.html`
;
...
...
apps/cart/models/cart-service.js
View file @
028cf1a
...
...
@@ -11,7 +11,8 @@ const co = Promise.coroutine;
const
_
=
require
(
'lodash'
);
const
api
=
global
.
yoho
.
API
;
const
helpers
=
global
.
yoho
.
helpers
;
const
md5
=
require
(
'md5'
);
// const md5 = require('md5');
const
ERROR_400_MESSAGE
=
'系统繁忙,请稍候再试!'
;
const
productAPI
=
require
(
'./product-api'
);
...
...
@@ -743,11 +744,11 @@ const getRecommendProduct = (channel, uid, udid, page) => {
};
// 商品链接
let
cnAlphaBet
=
it
.
cn_alphabet
?
it
.
cn_alphabet
:
md5
(
it
.
product_name
);
//
let cnAlphaBet = it.cn_alphabet ? it.cn_alphabet : md5(it.product_name);
let
firstGoods
=
it
.
goods_list
&&
it
.
goods_list
[
0
];
let
productSkc
=
firstGoods
&&
firstGoods
.
product_skc
;
item
.
href
=
helpers
.
url
(
`
/
product
/
pro_$
{
it
.
product_id
}
_$
{
productSkc
}
/${cnAlphaBet}.html`, null, 'item'
)
;
item
.
href
=
helpers
.
getUrlBySkc
(
it
.
product_id
,
productSkc
,
it
.
cn_alphabet
);
if
(
it
.
sales_price
!==
it
.
market_price
)
{
it
.
marketPrice
=
chelper
.
transPrice
(
it
.
market_price
);
...
...
@@ -973,10 +974,8 @@ const getMiniCartData = (uid, shoppingKey) => {
product_sku
:
g
.
product_sku
,
promotion_id
:
g
.
promotion_id
};
let
cnAlphaBet
=
g
.
cn_alphabet
?
g
.
cn_alphabet
:
md5
(
g
.
product_name
);
let
uri
=
`
/
product
/
pro_$
{
g
.
product_id
}
_$
{
g
.
goods_id
}
/${cnAlphaBet}.html`
;
goods
.
product_url
=
helpers
.
urlFormat
(
uri
,
null
,
'item'
);
goods
.
product_url
=
helpers
.
getUrlBySkc
(
g
.
product_id
,
g
.
goods_id
,
g
.
cn_alphabet
);
return
goods
;
});
...
...
mix/mix/cart/cart-list.hbs
View file @
028cf1a
...
...
@@ -90,7 +90,7 @@
{{#
ordinaryCart
}}
{{#
pools
}}
<div
class=
"promotion-pool"
data-role=
"promotion-pool"
>
<div
class=
"promotion-pool
{{#
unless
@first
}}
mt20
{{/
unless
}}
"
data-role=
"promotion-pool"
>
{{#if
promotionInfos
}}
<div
class=
"gift-sell mt20"
>
{{#
promotionInfos
}}
...
...
public/js/cart/cart-action.js
View file @
028cf1a
...
...
@@ -196,7 +196,7 @@ Cart = {
if
(
!
$
.
isEmptyObject
(
selectArray
))
{
var
content
=
'<div><i class="iconfont"></i>清除失效商品</div><p>确定要清除失效商品吗?</p>'
;
// eslint-disable-line
new
RConfirm
(
content
,
function
()
{
// eslint-disable-line
capi
.
cartItemDel
(
selectArray
,
true
,
PromotionArray
);
capi
.
cartItemDel
(
selectArray
,
true
);
}).
show
();
}
else
{
var
content
=
'<div class="alert-main"><i class="iconfont"></i>购物车中没有失效商品!</div>'
;
// eslint-disable-line
...
...
public/js/cart/cart-api.js
View file @
028cf1a
...
...
@@ -242,7 +242,7 @@ function addcart(data, cookieList) {
});
}
}
else
{
new
Alert
(
d
.
message
===
''
?
'加入购物车失败哦~~'
:
d
.
message
).
show
();
new
Alert
(
!
d
.
message
?
'加入购物车失败哦~~'
:
d
.
message
).
show
();
}
});
}
...
...
Please
register
or
login
to post a comment