Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
刘传洋
8 years ago
Commit
132a3b1d7f63c327f7320a838cfd407eb27fd1c2
1 parent
0ab60315
m
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
5 deletions
template/www.yohobuy.com/partials/layout/page-header.phtml
web-static/js/header.js
template/www.yohobuy.com/partials/layout/page-header.phtml
View file @
132a3b1
...
...
@@ -165,7 +165,7 @@
<ul
class=
"goods-list"
>
\
{
\{#main_goods\
}
\}
\
{
{#notzero
buy_number
}
}
<li
class=
"goods-item"
>
<li
class=
"goods-item
{{#gt @index 4}} hide {{/gt}}
"
>
<a
href=
"\{\{product_url\}\}"
>
<img
src=
"\{\{default_img\}\}"
alt=
""
class=
"goods-img"
/>
</a>
...
...
@@ -214,12 +214,13 @@
\
{
\{/if\
}
\}
</ul>
</div>
<div
class=
"gobuy-notempty-footer"
>
<h
3
>
<div
class=
"go-full-cart"
>
<div>
<p
data-role=
"totalinfo"
data-total=
"{{total}}"
>购物车里还有<span
data-role=
"last-num"
>
{
{total
}
}</span>件商品</p>
<a
href=
"//www.yohobuy.com/cart/cart"
>查看我的购物车</a>
</h
3
>
</div>
</div>
\
{
\{/carData\
}
\}
</script>
...
...
web-static/js/header.js
View file @
132a3b1
...
...
@@ -350,6 +350,20 @@ handlebars.registerHelper('notzero', function(v1, options) {
}
});
handlebars
.
registerHelper
(
'gt'
,
function
(
v1
,
v2
,
options
)
{
var
ret
=
v1
>
v2
;
if
(
options
.
fn
)
{
if
(
ret
)
{
return
options
.
fn
(
this
);
}
else
{
return
options
.
inverse
(
this
);
}
}
else
{
return
ret
;
}
});
/**
* 获取头部banner的回调函数
* @param {[type]} data [description]
...
...
@@ -1108,6 +1122,28 @@ function actionUpdateCartNum() {
cartNum
:
'.ic-infomation'
});
}
function
refreshCartNum
()
{
var
$miniCart
=
$
(
'#miniCartBox'
);
var
$totalInfo
=
$miniCart
.
find
(
'[data-role=totalinfo]'
);
var
total
=
0
;
$miniCart
.
find
(
'.goods-list .goods-item.hide'
).
each
(
function
()
{
var
$t
=
$
(
this
);
var
val
=
$t
.
data
(
'num'
)
||
0
;
total
+=
Number
(
val
);
});
if
(
total
>
0
)
{
$totalInfo
.
show
();
$totalInfo
.
find
(
'[data-role=last-num]'
).
text
(
total
);
}
else
{
$totalInfo
.
hide
();
}
}
/**
* 加载购物车数据
* @return {[type]} [description]
...
...
@@ -1124,6 +1160,9 @@ function loadCartData() {
$
(
'#miniCartBox'
).
children
(
'.gobuy-wrapper'
).
html
(
cartTpl
({
carData
:
jsonData
}));
refreshCartNum
();
if
(
parseInt
(
$
(
'.ic-infomation'
).
html
())
===
0
)
{
$
(
'#miniCartBox .gobuy-wrapper'
).
html
(
'<div class="gobuy-empty">'
+
'<h3 class="information">您的购物车暂无商品</h3></div>'
);
...
...
Please
register
or
login
to post a comment