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
yyq
8 years ago
Commit
a50b514caee5227220be6e7609b6a6dd7c337a59
1 parent
71899878
加价购多档合一
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
31 deletions
apps/cart/models/cart-helper.js
apps/cart/models/cart-service.js
public/hbs/cart/cart-gifts-win-tpl.hbs
public/js/cart/cart-goods-win.js
apps/cart/models/cart-helper.js
View file @
a50b514
...
...
@@ -297,6 +297,7 @@ const formatPriceGiftOne = (it) => {
// isShowGift: isGift, // 控制是否显示赠品
// isFold: true, // 控制是否[展开]
promotionId
:
it
.
promotion_id
,
promotionTitle
:
it
.
promotion_title
,
promotionDesc
:
identIconReplace
(
it
.
promotion_desc
),
// + '(注:您看到的商品可能因为下单时间差已售完)', // subjoinType
maxSelectNumber
:
it
.
max_select_number
,
promotionType
:
it
.
promotion_type
,
...
...
apps/cart/models/cart-service.js
View file @
a50b514
...
...
@@ -945,48 +945,53 @@ const queryUserPromotionGift = (promotionId, uid, shoppingKey) => {
let
currentProduct
=
null
;
// 默认展示第一个商品
if
(
promotionGifts
&&
promotionGifts
.
code
===
200
)
{
// chelper.formatPriceGiftOne(promotionGifts.data);
let
promotionList
=
chelper
.
formatPriceGifts
(
_
.
get
(
promotionGifts
,
'data.arrays'
));
let
promotionList
=
chelper
.
formatPriceGifts
(
_
.
get
(
promotionGifts
,
'data.arrays'
,
[]));
if
(
promotionList
&&
promotionList
.
length
>=
0
)
{
promotionGifts
.
data
=
promotionList
[
0
];
}
else
{
promotionGifts
.
data
=
{};
}
if
(
promotionGifts
.
data
.
goodsList
&&
promotionGifts
.
data
.
goodsList
.
length
)
{
currentProduct
=
promotionGifts
.
data
.
goodsList
[
0
];
currentProduct
.
active
=
true
;
}
promotionGifts
.
data
=
_
.
get
(
promotionList
,
'[0]'
,
{});
// 处理是否选中状态
if
(
selectedGift
&&
selectedGift
.
length
)
{
_
.
forEach
(
promotionGifts
.
data
.
goodsList
,
(
it
)
=>
{
let
goodsList
=
[];
let
checked
;
let
isSelected
=
false
;
_
.
forEach
(
promotionList
,
value
=>
{
if
(
!
value
.
goodsList
||
!
value
.
goodsList
.
length
)
{
return
;
}
_
.
forEach
(
selectedGift
,
sg
=>
{
if
(
it
.
skn
===
sg
.
skn
)
{
isSelected
=
true
;
return
true
;
}
_
.
forEach
(
value
.
goodsList
,
it
=>
{
if
(
!
checked
)
{
checked
=
true
;
it
.
active
=
true
;
currentProduct
=
it
;
promotionGifts
.
data
.
promotionDesc
=
value
.
promotionTitle
;
}
Object
.
assign
(
it
,
{
isSelected
:
!!
_
.
find
(
selectedGift
,
[
'skn'
,
it
.
skn
]),
promotionId
:
value
.
promotionId
,
promotionTitle
:
value
.
promotionTitle
,
maxSelectNumber
:
value
.
maxSelectNumber
});
it
.
isSelected
=
isSelected
;
goodsList
.
push
(
it
)
;
});
}
}
});
promotionGifts
.
data
.
goodsList
=
goodsList
;
// 获取选中商品的数据详情
if
(
currentProduct
&&
currentProduct
.
id
)
{
promotionGifts
.
data
.
productInfo
=
yield
getProductInfoAsync
(
currentProduct
.
id
);
// 获取选中商品的数据详情
if
(
currentProduct
&&
currentProduct
.
id
)
{
let
prodInfo
=
yield
getProductInfoAsync
(
currentProduct
.
id
);
// 价格为活动价
if
(
promotionGifts
.
data
.
productInfo
)
{
promotionGifts
.
data
.
productInfo
.
salePrice
=
'¥'
+
currentProduct
.
subjoinPrice
;
// 价格为活动价
if
(
prodInfo
)
{
prodInfo
.
salePrice
=
'¥'
+
currentProduct
.
subjoinPrice
;
}
promotionGifts
.
data
.
productInfo
=
prodInfo
;
}
}
return
promotionGifts
;
})();
...
...
public/hbs/cart/cart-gifts-win-tpl.hbs
View file @
a50b514
...
...
@@ -9,6 +9,9 @@
<li
class=
"img-item
{{#if
active
}}
active
{{/if}}
"
data-id=
"
{{
id
}}
"
data-skn=
"
{{
skn
}}
"
{{#if
promotionId
}}
data-promotionid=
"
{{
promotionId
}}
"
{{/if}}
{{#if
promotionTitle
}}
data-promotiontitle=
"
{{
promotionTitle
}}
"
{{/if}}
{{#if
maxSelectNumber
}}
data-maxselectnum=
"
{{
maxSelectNumber
}}
"
{{/if}}
{{#if
subjoinPrice
}}
data-subjoinprice=
"
{{
subjoinPrice
}}
"
{{/if}}
{{#if
isPriceGift
}}
data-ispricegift=
"
{{
isPriceGift
}}
"
{{/if}}
{{#if
isGift
}}
data-isgift=
"
{{
isGift
}}
"
{{/if}}
>
...
...
public/js/cart/cart-goods-win.js
View file @
a50b514
...
...
@@ -106,10 +106,15 @@ GoodsWinAction = {
var
$this
=
$
(
this
);
var
id
=
$this
.
data
(
'id'
);
var
skn
=
$this
.
data
(
'skn'
);
var
title
=
$this
.
data
(
'promotiontitle'
);
$this
.
siblings
(
'li'
).
removeClass
(
'active'
);
$this
.
addClass
(
'active'
);
if
(
title
)
{
$this
.
closest
(
'.slide-img'
).
children
(
'.sell-class-title'
).
text
(
title
);
}
capi
.
getProductInfo
(
id
,
skn
).
then
(
function
(
res
)
{
// 赠品价格为 0, 加价购价格为 活动价
...
...
@@ -343,9 +348,13 @@ GoodsWinAction = {
var
allNum
=
$curSize
.
data
(
'num'
);
var
sku
=
$curSize
.
data
(
'sku'
);
var
skn
=
$this
.
closest
(
'.detail-goods'
).
data
(
'skn'
);
var
promotionId
=
$this
.
closest
(
'.
product-detail-info
'
).
data
(
'promotionid'
)
||
0
;
var
promotionId
=
$this
.
closest
(
'.
detail-body'
).
find
(
'.img-item.active
'
).
data
(
'promotionid'
)
||
0
;
var
isSwap
=
$this
.
closest
(
'.product-detail-info'
).
data
(
'isswap'
);
if
(
!
promotionId
)
{
promotionId
=
$this
.
closest
(
'.product-detail-info'
).
data
(
'promotionid'
)
||
0
;
}
if
(
$curSize
.
length
<=
0
)
{
$this
.
closest
(
'.detail-info'
).
find
(
'.size-p-tip'
).
show
();
$this
.
closest
(
'.detail-info'
).
find
(
'.submit'
).
css
(
'marginTop'
,
'0'
);
...
...
Please
register
or
login
to post a comment