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
e66ad1cb942f5ecbea91f85d82b64d34bbcb934f
1 parent
3b3c38c5
m
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
16 deletions
apps/cart/controllers/cart.js
apps/cart/models/cart-api.js
apps/cart/models/cart-service.js
public/hbs/cart/cart-gifts-win-tpl.hbs
public/hbs/cart/cart-product-info-tpl.hbs
public/js/cart/cart-goods-win.js
apps/cart/controllers/cart.js
View file @
e66ad1c
...
...
@@ -29,7 +29,7 @@ const getProductInfo = (req, res, next) => {
const
getProductData
=
(
req
,
res
,
next
)
=>
{
let
pid
=
req
.
query
.
productId
||
''
;
service
.
getProductInfoAsync
(
pid
).
then
((
result
)
=>
{
service
.
getProductInfoAsync
(
pid
,
req
.
user
.
uid
).
then
((
result
)
=>
{
return
res
.
send
(
result
);
}).
catch
(
next
);
};
...
...
apps/cart/models/cart-api.js
View file @
e66ad1c
...
...
@@ -537,6 +537,16 @@ const checkUserIsFavProductList = (uid, pidList) => {
});
};
const
checkProductIsFav
=
(
uid
,
pid
)
=>
{
return
api
.
get
(
''
,
{
method
:
'app.favorite.isFavorite'
,
id
:
pid
,
uid
:
uid
,
type
:
'product'
});
};
/**
* 个人中心页面优选新品数据
*
...
...
@@ -662,6 +672,7 @@ module.exports = {
savePrePayInfo
,
addTicket
,
checkUserIsFavProductList
,
checkProductIsFav
,
newPreference
,
modifyProduct
,
swapGift
,
...
...
apps/cart/models/cart-service.js
View file @
e66ad1c
...
...
@@ -347,7 +347,7 @@ const _detailDataPkg = (origin) => {
/**
* 获取某一个商品详情主页面
*/
const
getProductInfoAsync
=
(
pid
)
=>
{
const
getProductInfoAsync
=
(
pid
,
uid
)
=>
{
return
co
(
function
*
()
{
if
(
!
pid
)
{
return
{};
...
...
@@ -373,7 +373,17 @@ const getProductInfoAsync = (pid) => {
let
productInfo
=
requestData
[
1
];
let
intro
=
_getIntroInfo
(
productSkn
,
productDescription
);
return
Object
.
assign
(
productInfo
,
intro
);
let
isFav
=
false
;
if
(
uid
)
{
let
isFavRet
=
yield
cartApi
.
checkProductIsFav
(
uid
,
pid
);
if
(
isFavRet
&&
isFavRet
.
code
===
200
)
{
isFav
=
isFavRet
.
data
;
}
}
return
Object
.
assign
({
isFav
:
isFav
},
productInfo
,
intro
);
})();
};
...
...
@@ -750,6 +760,18 @@ const checkUserIsFav = (uid, skuList) => {
};
/**
* 检查用户是否收藏这一批商品
*
* @param int $uid 用户ID
* @param array $skuList 商品SKU列表
* @return array
*/
const
checkProductIsFav
=
(
uid
,
pid
)
=>
{
return
cartApi
.
checkProductIsFav
(
uid
,
pid
);
};
/**
* 获取为你优选商品 待处理
*
* @param $channel 频道
...
...
@@ -966,7 +988,7 @@ const queryUserPromotionGift = (promotionId, uid, shoppingKey) => {
// 获取选中商品的数据详情
if
(
currentProduct
&&
currentProduct
.
id
)
{
promotionGifts
.
data
.
productInfo
=
yield
getProductInfoAsync
(
currentProduct
.
id
);
promotionGifts
.
data
.
productInfo
=
yield
getProductInfoAsync
(
currentProduct
.
id
,
uid
);
// 价格为活动价
if
(
promotionGifts
.
data
.
productInfo
)
{
...
...
@@ -989,6 +1011,7 @@ module.exports = {
removeFromCart
,
addToFav
,
checkUserIsFav
,
checkProductIsFav
,
getRecommendProduct
,
getTogetherProduct
,
modifyProduct
,
...
...
public/hbs/cart/cart-gifts-win-tpl.hbs
View file @
e66ad1c
...
...
@@ -38,7 +38,8 @@
<div
class=
"product-detail-info"
data-promotionid=
"
{{
promotionId
}}
"
data-maxselectnum=
"
{{
maxSelectNumber
}}
"
{{#if
swap
}}
data-swap=
"
{{
swap
}}
"
{{/if}}
>
{{#if
isSwap
}}
data-isswap=
"
{{
isSwap
}}
"
{{/if}}
{{#if
isView
}}
data-isview=
"
{{
isView
}}
"
{{/if}}
>
{{#
productInfo
}}
{{>
cart-product-info-tpl
}}
{{/
productInfo
}}
...
...
public/hbs/cart/cart-product-info-tpl.hbs
View file @
e66ad1c
...
...
@@ -76,7 +76,7 @@
{{/
each
}}
</div>
{{/
each
}}
<p
class=
"size-p-tip"
><i
class=
"iconfont"
>

</i>
请选择尺码
</p>
<p
class=
"size-p-tip"
style=
"display:none;"
><i
class=
"iconfont"
>

</i>
请选择尺码
</p>
<!--<p class="size-p">内长 25.5com</p>-->
</dt>
</dl>
...
...
@@ -92,13 +92,24 @@
</dl>
</div>
<div
class=
"submit"
>
<button
class=
"btn-red addcart"
><i
class=
"addCart iconfont"
>

</i>
添加到购物车
</button>
<button
class=
"addcart btn-grey"
><i
class=
"addCart iconfont"
>

</i>
添加到购物车
</button>
<button
class=
"btn-sellOut btn-grey"
><i
class=
"sellOut iconfont"
>

</i>
已售罄
</button>
<button
class=
"btn-favCount"
><i
class=
"favCount iconfont"
>

</i>
收藏商品
</button>
<button
class=
"btn-favCount"
><i
class=
"favCount iconfont coled"
>

</i>
已收藏
</button>
{{#
unless
isView
}}
<button
class=
"btn-red addcart"
><i
class=
"addCart iconfont"
>

</i>
添加到购物车
</button>
{{/
unless
}}
{{#if
isView
}}
<button
class=
"addcart btn-grey"
><i
class=
"addCart iconfont"
>

</i>
添加到购物车
</button>
{{/if}}
<button
class=
"btn-sellOut btn-grey"
style=
"display:none;"
>
<i
class=
"sellOut iconfont"
>

</i>
已售罄
</button>
{{#if
isFav
}}
<button
class=
"btn-favCount"
><i
class=
"favCount iconfont coled"
>

</i>
已收藏
</button>
{{else}}
<button
class=
"btn-favCount"
><i
class=
"favCount iconfont"
>

</i>
收藏商品
</button>
{{/if}}
</div>
<p
class=
"submit-tip"
>
未满足活动条件
</p>
{{#if
isView
}}
<p
class=
"submit-tip"
>
未满足活动条件
</p>
{{/if}}
</div>
<div
class=
"detail-size"
>
<h3>
尺码信息
<span>
(单位:厘米)
</span></h3>
...
...
public/js/cart/cart-goods-win.js
View file @
e66ad1c
...
...
@@ -34,6 +34,7 @@ GoodsWinAction = {
var
promotionInfo
=
$wrap
.
data
(
'_promotionInfo'
);
var
role
=
$this
.
data
(
'role'
);
var
isSwap
=
role
===
'pg-resel-btn'
||
role
===
'gift-resel-btn'
;
var
isView
=
role
===
'gift-view-btn'
;
var
$selectedItem
;
var
selectedSkn
;
...
...
@@ -63,6 +64,7 @@ GoodsWinAction = {
promotionInfo
=
pinfo
.
data
;
promotionInfo
.
isSwap
=
isSwap
;
promotionInfo
.
isView
=
isView
;
if
(
selectedSkn
)
{
promotionInfo
.
selectedSkn
=
selectedSkn
;
}
...
...
@@ -101,6 +103,8 @@ GoodsWinAction = {
}
}
res
.
isView
=
$this
.
closest
(
'.detail-body'
).
find
(
'.product-detail-info'
).
data
(
'isview'
);
$goodsSelWin
.
find
(
'.product-detail-info'
).
empty
().
append
(
productInfoTpl
(
res
));
});
},
...
...
@@ -187,13 +191,14 @@ GoodsWinAction = {
$this
.
siblings
(
'span'
).
removeClass
(
'active'
);
$this
.
addClass
(
'active'
);
$this
.
closest
(
'[data-role=sizes]'
).
find
(
'.size-p-tip'
).
hide
();
if
(
shopNumAll
>
0
)
{
$goodsSelWin
.
find
(
'.addcart'
).
removeClass
(
'none'
);
$goodsSelWin
.
find
(
'.btn
_sello
ut'
).
addClass
(
'none'
);
$goodsSelWin
.
find
(
'.btn
-sellO
ut'
).
addClass
(
'none'
);
}
else
{
$goodsSelWin
.
find
(
'.addcart'
).
addClass
(
'none'
);
$goodsSelWin
.
find
(
'.btn
_sello
ut'
).
removeClass
(
'none'
);
$goodsSelWin
.
find
(
'.btn
-sellO
ut'
).
removeClass
(
'none'
);
}
},
changeNum
:
function
()
{
...
...
@@ -237,10 +242,11 @@ GoodsWinAction = {
var
sku
=
$curSize
.
data
(
'sku'
);
var
skn
=
$this
.
closest
(
'.detail-goods'
).
data
(
'skn'
);
var
promotionId
=
$this
.
closest
(
'.product-detail-info'
).
data
(
'promotionid'
)
||
0
;
var
isSwap
=
$this
.
closest
(
'.product-detail-info'
).
data
(
'swap'
);
var
isSwap
=
$this
.
closest
(
'.product-detail-info'
).
data
(
'
is
swap'
);
if
(
$curSize
.
length
<=
0
)
{
new
Alert
(
'请选择尺码'
).
show
();
$this
.
closest
(
'.detail-info'
).
find
(
'.size-p-tip'
).
show
();
// new Alert('请选择尺码').show();
return
false
;
}
...
...
Please
register
or
login
to post a comment