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
htoooth
8 years ago
Commit
3889984416f4b7c641eeb9a63a4d63846f85cdd3
1 parent
2575d629
add
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
40 deletions
apps/product/views/action/product/detail.hbs
public/js/product/detail.page.js
apps/product/views/action/product/detail.hbs
View file @
3889984
...
...
@@ -124,7 +124,8 @@
</div>
{{/if}}
{{#if
size
}}
<div
class=
"description-material-tab info-block getnav"
id=
"sizeMessage"
data-id=
"1"
>
{{#if
size
.
tbody
}}
<div
class=
"description-material-tab info-block getnav"
id=
"sizeMessage"
data-id=
"1"
>
<p
class=
"block-title"
id=
"sizeTitle"
>
<span
class=
"title-head"
>
<span
class=
"title cur"
>
尺码信息
</span>
</span>
</p>
...
...
public/js/product/detail.page.js
View file @
3889984
...
...
@@ -23,6 +23,7 @@ var bindEvent = $.Callbacks(); // eslint-disable-line
var
cartEvent
=
new
EventProxy
();
var
Dialog
=
require
(
'../common/dialog'
).
Dialog
;
var
Alert
=
require
(
'../common/dialog'
).
Alert
;
var
yasAtHead
=
require
(
'./yas-head'
);
var
yasAtBottom
=
require
(
'./yas-bottom'
);
var
$main
=
$
(
'.main'
),
...
...
@@ -83,21 +84,76 @@ function isEmpty(el) {
function
showSellOut
()
{
$shoppingCarBtn
.
addClass
(
'disable'
)
.
find
(
'i'
).
html
(
''
).
end
()
.
data
(
'gocart'
,
0
)
.
find
(
'span'
).
html
(
'已售罄'
);
}
function
showAddCart
()
{
$shoppingCarBtn
.
removeClass
(
'disable'
)
.
data
(
'gocart'
,
0
)
.
find
(
'i'
).
html
(
''
).
end
()
.
find
(
'span'
).
html
(
'加入购物车'
);
}
function
showHasAddCart
()
{
$shoppingCarBtn
.
removeClass
(
'disable'
)
.
data
(
'gocart'
,
1
)
.
find
(
'i'
).
html
(
''
).
end
()
.
find
(
'span'
).
html
(
'去购物车结算'
);
}
cartEvent
.
on
(
'selling'
,
showAddCart
);
cartEvent
.
on
(
'sellout'
,
showSellOut
);
cartEvent
.
on
(
'gocart'
,
showHasAddCart
);
require
(
'../plugins/slider'
);
require
(
'../common/center-slider'
);
// 获取当前选择的商品数目
function
getNum
()
{
return
+
$
(
'#num'
).
text
();
}
function
getSku
()
{
return
$
(
'.size:not(.hide) li.focus'
).
data
(
'sku'
);
}
function
addCart
()
{
return
$
.
ajax
({
type
:
'POST'
,
url
:
'/cart/index/add'
,
data
:
{
productSku
:
getSku
(),
buyNumber
:
getNum
()
}
}).
then
(
function
(
data
)
{
var
code
=
data
.
code
;
var
alert
;
if
(
code
===
200
)
{
$
(
'#type-chose'
).
slideUp
(
SLIDETIME
);
$
(
'#balance'
).
slideDown
(
SLIDETIME
);
$
(
'#cart-num'
).
text
(
data
.
data
.
goods_count
);
// 更新数目
return
$
.
Deferred
().
resolve
().
promise
();
}
else
if
(
code
===
500
)
{
if
(
deposit
)
{
alert
=
new
Alert
(
'定金预售商品只能在APP端购买'
);
alert
.
show
();
}
if
(
secKill
)
{
alert
=
new
Alert
(
'秒杀商品只能在APP端购买'
);
alert
.
show
();
}
}
return
$
.
Deferred
().
reject
().
promise
();
});
}
bindEvent
.
add
(
function
()
{
var
$imgShow
=
$
(
'#img-show'
),
$thumbs
=
$
(
'#thumbs > .thumb-wrap'
);
...
...
@@ -128,8 +184,6 @@ bindEvent.add(function() {
var
brandDomain
=
$
(
'.home'
).
attr
(
'href'
);
var
Alert
=
require
(
'../common/dialog'
).
Alert
;
/** 优惠券开始 **/
var
$moreCoupon
=
$
(
'.more-coupon'
),
$couponItem
=
$
(
'.coupon-item'
);
...
...
@@ -235,10 +289,6 @@ bindEvent.add(function() {
/** 优惠券结束 **/
function
getSku
()
{
return
$
(
'.size:not(.hide) li.focus'
).
data
(
'sku'
);
}
function
imgShow
(
src
)
{
$imgShow
.
attr
(
'src'
,
src
);
}
...
...
@@ -328,11 +378,6 @@ bindEvent.add(function() {
}
});
// 获取当前选择的商品数目
function
getNum
()
{
return
+
$num
.
text
();
}
// 是否能:量贩购买,量贩小于库存才能购买
function
canBundleBuy
()
{
return
goodsBaseNum
<
maxStock
;
...
...
@@ -407,9 +452,11 @@ bindEvent.add(function() {
if
(
sellout
())
{
$itemBuy
.
addClass
(
'hide'
);
$soldOut
.
removeClass
(
'hide'
);
cartEvent
.
emit
(
'sellout'
);
}
else
{
$itemBuy
.
removeClass
(
'hide'
);
$soldOut
.
addClass
(
'hide'
);
cartEvent
.
emit
(
'selling'
);
}
// 尺码选中的状态
...
...
@@ -417,9 +464,11 @@ bindEvent.add(function() {
if
(
canBundleBuy
())
{
$itemBuy
.
removeClass
(
'hide'
);
$soldOut
.
addClass
(
'hide'
);
cartEvent
.
emit
(
'gocart'
);
}
else
{
$itemBuy
.
addClass
(
'hide'
);
$soldOut
.
removeClass
(
'hide'
);
cartEvent
.
emit
(
'sellout'
);
}
}
...
...
@@ -431,10 +480,17 @@ bindEvent.add(function() {
if
(
maxStock
===
0
||
(
$color
&&
~~
$color
.
data
(
'total'
)
===
0
))
{
$itemBuy
.
addClass
(
'hide'
);
// 隐藏加入购物车、即将开售、立即购买等相同位置的按钮
$soldOut
.
removeClass
(
'hide'
);
cartEvent
.
emit
(
'sellout'
);
}
else
{
// 包括默认的-1情况下
$itemBuy
.
removeClass
(
'hide'
);
$soldOut
.
addClass
(
'hide'
);
if
(
maxStock
===
-
1
)
{
cartEvent
.
emit
(
'selling'
);
}
else
{
cartEvent
.
emit
(
'gocart'
);
}
}
}
...
...
@@ -773,34 +829,7 @@ bindEvent.add(function() {
PRD_SKU
:
getSku
()
});
$
.
ajax
({
type
:
'POST'
,
url
:
'/cart/index/add'
,
data
:
{
productSku
:
getSku
(),
buyNumber
:
getNum
()
}
}).
then
(
function
(
data
)
{
var
code
=
data
.
code
;
var
alert
;
if
(
code
===
200
)
{
$
(
'#type-chose'
).
slideUp
(
SLIDETIME
);
$
(
'#balance'
).
slideDown
(
SLIDETIME
);
$
(
'#cart-num'
).
text
(
data
.
data
.
goods_count
);
// 更新数目
}
else
if
(
code
===
500
)
{
if
(
deposit
)
{
alert
=
new
Alert
(
'定金预售商品只能在APP端购买'
);
alert
.
show
();
}
if
(
secKill
)
{
alert
=
new
Alert
(
'秒杀商品只能在APP端购买'
);
alert
.
show
();
}
}
});
addCart
();
});
// 收藏
...
...
@@ -1832,8 +1861,23 @@ $('.shoppingCar').on('click', '.option', function(e) {
});
$
(
'.shoppingCar-btn'
).
on
(
'click'
,
function
()
{
var
$this
=
$
(
this
);
if
(
$this
.
hasClass
(
'disable'
))
{
return
;
}
if
(
$this
.
data
(
'gocart'
)
===
1
)
{
addCart
().
then
(
function
()
{
window
.
jumpUrl
(
$
(
'.go-cart'
).
attr
(
'href'
));
});
return
;
}
var
$addToCart
=
$
(
'#add-to-cart'
);
var
sc
=
$
(
document
);
sc
.
scrollTop
(
200
);
if
(
maxStock
===
-
1
)
{
...
...
Please
register
or
login
to post a comment