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
6e7e31c15dbd5fb3e24f171f7d2d992119a4845e
1 parent
2a8b3682
m
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
25 deletions
apps/cart/views/partial/cart-item.hbs
public/hbs/cart/select-color-panel.hbs
public/js/cart/cart-action.js
public/js/cart/cart.page.js
apps/cart/views/partial/cart-item.hbs
View file @
6e7e31c
...
...
@@ -4,7 +4,9 @@
{{#if
skn
}}
data-skn=
"
{{
skn
}}
"
{{/if}}
{{#if
sku
}}
data-sku=
"
{{
sku
}}
"
{{/if}}
{{#if
productNum
}}
data-productnum=
"
{{
productNum
}}
"
{{/if}}
{{#if
goodsType
}}
data-goodstype=
"
{{
goodsType
}}
"
{{/if}}
>
{{#if
goodsType
}}
data-goodstype=
"
{{
goodsType
}}
"
{{/if}}
data-color=
"
{{
productColor
}}
"
data-size=
"
{{
productSize
}}
"
>
<div
class=
"pay-pro td"
style=
"width: 45%;"
>
<i
class=
"cart-item-check iconfont
{{#
isChecked
}}
cart-item-checked
{{/
isChecked
}}
"
readonly=
"readonly"
data-goodstype=
"
{{
goodsType
}}
"
...
...
@@ -15,7 +17,7 @@
</a>
<p
class=
"pay-pro-info"
>
<a
href=
"
{{
link
}}
"
target=
"_blank"
>
{{
productTitle
}}
</a>
<em
class=
"pay-pro-detail"
><span><b
title=
"
{{
productColor
}}
"
>
颜色:
红色
{{
productColor
}}
</b>
尺码:
{{
productSize
}}
<i
class=
"iconfont"
>

</i></span></em>
<em
class=
"pay-pro-detail"
><span><b
title=
"
{{
productColor
}}
"
>
颜色:
{{
productColor
}}
</b>
尺码:
{{
productSize
}}
<i
class=
"iconfont"
>

</i></span></em>
</p>
</div>
<div
class=
"product-price td"
style=
"width:17%;"
>
¥
{{
productPrice
}}
...
...
public/hbs/cart/select-color-panel.hbs
View file @
6e7e31c
...
...
@@ -21,7 +21,7 @@
{{#
each
colors
}}
<div
class=
"size-row
{{#
unless
focus
}}
hide
{{/
unless
}}
"
>
{{#
each
sizes
}}
<div
class=
"dt
active
"
<div
class=
"dt
{{#if
sizeFocus
}}
active
{{/if}}
"
{{#
unless
num
}}
class=
"disable"
{{/
unless
}}
data-sku=
"
{{
sku
}}
"
data-num=
"
{{
num
}}
"
...
...
public/js/cart/cart-action.js
View file @
6e7e31c
...
...
@@ -3,8 +3,9 @@
*/
var
$
=
require
(
'yoho-jquery'
);
var
Dialog
=
require
(
'../common/dialog'
).
Dialog
;
var
Alert
=
Dialog
.
Alert
;
// var Dialog = require('../common/dialog').Dialog;
var
Alert
=
require
(
'../common/dialog'
).
Alert
;
var
Confirm
=
require
(
'../common/dialog'
).
Confirm
;
var
$cartnewTips
=
$
(
'.cartnew-tips'
),
$payWapper
=
$
(
'.pay-wapper'
),
...
...
@@ -140,6 +141,7 @@ var cartItemNumChg = (function(data) {
url
:
'/cart/index/modify'
,
data
:
data
}).
then
(
function
(
d
)
{
alert
(
JSON
.
stringify
(
d
));
if
(
d
.
code
===
200
)
{
window
.
history
.
go
(
0
);
}
else
{
...
...
@@ -227,7 +229,8 @@ function parseProductInfo(productInfo, defaultInfo) {
// 默认选中用户选择的sku,若已售罄或下架,则选中列表中第一个非售罄的sku
for
(
index
=
0
;
index
<
filterSet
.
length
;
index
++
)
{
curColor
=
filterSet
[
index
];
if
(
!
hasActiveColor
&&
curColor
.
color
===
defaultInfo
.
color
)
{
if
(
!
hasActiveColor
&&
String
(
curColor
.
name
)
===
String
(
defaultInfo
.
color
))
{
curColor
.
active
=
true
;
curColor
.
hasActiveColor
=
hasActiveColor
=
true
;
...
...
@@ -235,8 +238,10 @@ function parseProductInfo(productInfo, defaultInfo) {
}
curSize
=
curColor
.
sizes
;
for
(
sizeIdx
=
0
;
sizeIdx
<
curSize
.
length
;
sizeIdx
++
)
{
if
(
curColor
.
hasActiveColor
&&
curSize
[
sizeIdx
].
name
===
defaultInfo
.
size
)
{
if
(
curColor
.
hasActiveColor
&&
curSize
[
sizeIdx
].
sku
===
defaultInfo
.
sku
)
{
// console.log(curSize[sizeIdx]);
curSize
[
sizeIdx
].
sizeFocus
=
true
;
break
;
}
...
...
@@ -259,23 +264,38 @@ function parseProductInfo(productInfo, defaultInfo) {
};
}
function
renderAndShowSelWin
(
$edit
,
pinfo
)
{
function
updateCartItem
(
newSku
,
oldSku
)
{
$
.
ajax
({
type
:
'POST'
,
url
:
'/shopping/cart/updateProduct'
,
data
:
{
swapData
:
JSON
.
stringify
([{
buy_number
:
'1'
,
selected
:
'Y'
,
new_product_sku
:
newSku
,
old_product_sku
:
oldSku
}])
}
}).
then
(
function
(
d
)
{
if
(
d
.
code
===
200
)
{
window
.
history
.
go
(
0
);
}
else
{
new
Alert
(
d
.
message
===
''
?
'修改商品失败哦~~'
:
d
.
message
).
show
();
}
});
}
function
renderAndShowSelWin
(
$item
,
pinfo
)
{
$edit
.
find
(
'.goods-choose-box'
).
remove
();
var
$selWin
=
$
(
selColorWinTpl
(
pinfo
)).
appendTo
(
$edit
);
$item
.
find
(
'.goods-choose-box'
).
remove
();
var
$selWin
=
$
(
selColorWinTpl
(
pinfo
)).
appendTo
(
$item
);
$selWin
.
show
();
}
var
Cart
=
{
addToCart
:
function
(
params
)
{
<<<<<<<
HEAD
$payWapper
.
find
(
'.cart-item-check'
).
each
(
function
()
{
var
$item
=
$
(
this
);
var
$chk
=
$item
.
find
(
'.cart-item-check'
);
if
(
$chk
.
hasClass
(
'cart-item-checked'
))
{
=======
},
toggleSelectOne
:
function
()
{
// 单选
...
...
@@ -288,7 +308,6 @@ var Cart = {
goods_type
:
$pitem
.
data
(
'goodstype'
),
promotion_id
:
$pitem
.
data
(
'promotionid'
)
?
$pitem
.
data
(
'promotionid'
)
:
0
};
>>>>>>>
3
a2b8fa435f608cc40704e327ea3ee303f3c3da4
return
choiceOut
(
item
);
},
...
...
@@ -488,13 +507,15 @@ var Cart = {
var
$this
=
$
(
this
);
var
$item
=
$this
.
closest
(
'li[data-role="pitem"]'
);
var
pinfo
=
$this
.
data
(
'_p_info'
);
var
$selWin
=
$
this
.
find
(
'.goods-choose-box'
);
var
$selWin
=
$
item
.
find
(
'.goods-choose-box'
);
var
pid
=
$item
.
data
(
'pid'
);
var
skn
=
$item
.
data
(
'skn'
);
var
sku
=
$item
.
data
(
'id'
);
var
defaultInfo
=
{
color
:
$this
.
find
(
'.default-color'
).
text
(),
size
:
$this
.
find
(
'.default-size'
).
text
(),
color
:
$item
.
data
(
'color'
),
size
:
$item
.
data
(
'size'
),
pid
:
pid
,
sku
:
sku
,
skn
:
skn
};
...
...
@@ -507,18 +528,65 @@ var Cart = {
getProductInfo
(
pid
,
skn
).
done
(
function
(
productInfo
)
{
pinfo
=
parseProductInfo
(
productInfo
,
defaultInfo
);
$this
.
data
(
'_p_info'
,
pinfo
);
renderAndShowSelWin
(
$
this
,
pinfo
);
renderAndShowSelWin
(
$
item
,
pinfo
);
}).
fail
(
function
()
{
new
Alert
(
'此商品无法编辑颜色和尺寸'
).
show
();
});
return
;
}
renderAndShowSelWin
(
$
this
,
pinfo
);
renderAndShowSelWin
(
$
item
,
pinfo
);
},
editColorOrSize
:
function
(
productId
,
skn
,
defaultColor
,
defaultSize
,
editTarget
)
{
editColorOrSize
:
function
()
{
var
$this
=
$
(
this
);
var
$item
=
$this
.
closest
(
'li[data-role="pitem"]'
);
var
pid
=
$item
.
data
(
'pid'
);
var
oldSku
=
$item
.
data
(
'id'
);
var
$size
=
$this
.
closest
(
'.goods-choose-box'
).
find
(
'.choose-size .dt.active'
);
var
newSku
=
$size
.
data
(
'sku'
);
// 没有重新选择颜色-尺码,则不用重新请求显示
if
(
!
oldSku
||
!
newSku
||
oldSku
===
newSku
)
{
Cart
.
_hideColorSizePanel
(
$item
);
return
false
;
}
updateCartItem
(
newSku
,
oldSku
);
},
_hideColorSizePanel
:
function
(
$item
){
$item
.
find
(
'.goods-choose-box'
).
hide
();
$item
.
find
(
'.pay-pro-detail'
).
removeClass
(
'active'
);
},
hideColorSizePanel
:
function
(
event
){
var
$this
=
$
(
this
);
event
.
stopPropagation
();
Cart
.
_hideColorSizePanel
(
$this
.
closest
(
'li[data-role="pitem"]'
))
},
selectColor
:
function
()
{
var
$this
=
$
(
this
);
var
index
=
$this
.
index
(
'.dt'
);
var
$srows
=
$this
.
closest
(
'.goods-info'
).
find
(
'.choose-size .size-row'
);
if
(
$this
.
hasClass
(
'active'
))
return
;
$this
.
siblings
(
'.dt'
).
remove
(
'active'
)
$this
.
addClass
(
'active'
);
$srows
.
find
(
'.dt'
).
removeClass
(
'active'
);
$srows
.
hide
();
$srows
.
indexOf
(
index
).
show
()
},
selectSize
:
function
()
{
var
$this
=
$
(
this
);
$this
.
siblings
(
'.dt'
).
removeClass
(
'active'
);
$this
.
addClass
(
'active'
);
},
submit
:
function
()
{
/* understock = '';
...
...
@@ -573,6 +641,11 @@ $cartnewSum.on('click', '.clean-all-disable', Cart.cleanAllDisable);
$
(
'.btn_account'
).
on
(
'click'
,
Cart
.
submit
);
// 结算
$payWapper
.
on
(
'click'
,
'li[data-role="pitem"] .pay-pro-detail'
,
Cart
.
showColorSizePanel
);
$payWapper
.
on
(
'click'
,
'li[data-role="pitem"] .button-cancel'
,
Cart
.
hideColorSizePanel
);
$payWapper
.
on
(
'click'
,
'li[data-role="pitem"] .button-sure'
,
Cart
.
editColorOrSize
);
$payWapper
.
on
(
'click'
,
'li[data-role="pitem"] .goods-choose-box .choose-color .dt'
,
Cart
.
selectColor
);
$payWapper
.
on
(
'click'
,
'li[data-role="pitem"] .goods-choose-box .choose-size .dt'
,
Cart
.
selectSize
);
// / 绑定颜色尺码弹窗事件 begin
/*
...
...
public/js/cart/cart.page.js
View file @
6e7e31c
...
...
@@ -469,4 +469,4 @@ $('.shop-cart').on('click', giftBtn, function() {
});
//
require('./cart-action');
require
(
'./cart-action'
);
...
...
Please
register
or
login
to post a comment