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
Lynnic
9 years ago
Commit
c9d6709cbaf198edfbd1375ac74149aa2872c3e1
1 parent
22923c1c
点赞功能
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
10 deletions
static/js/product/detail/desc.js
static/js/product/detail/detail.js
static/js/product/detail/like.js
static/sass/product/_detail.scss
template/m.yohobuy.com/actions/product/detail/index.phtml
static/js/product/detail/desc.js
View file @
c9d6709
...
...
@@ -5,9 +5,8 @@
*/
var
$
=
require
(
'jquery'
),
lazyLoad
=
require
(
'yoho.lazyload'
),
Swiper
=
require
(
'yoho.iswiper'
);
var
loading
=
require
(
'../../plugin/loading'
),
Swiper
=
require
(
'yoho.iswiper'
),
loading
=
require
(
'../../plugin/loading'
),
tip
=
require
(
'../../plugin/tip'
);
var
introUrl
=
$
(
'#introUrl'
).
val
(),
...
...
static/js/product/detail/detail.js
View file @
c9d6709
...
...
@@ -11,6 +11,7 @@ var goodsSwiper;
require
(
'./desc'
);
require
(
'./comments-consults'
);
require
(
'./like.js'
);
require
(
'../recommend-for-you.js'
);
lazyLoad
(
$
(
'img.lazy'
));
...
...
static/js/product/detail/like.js
0 → 100644
View file @
c9d6709
/**
* 商品详情
* @author: Lynnic
* @date: 2015/11/24
*/
var
$
=
require
(
'jquery'
),
Hammer
=
require
(
'yoho.hammer'
),
tip
=
require
(
'../../plugin/tip'
);
var
likeHammer
=
new
Hammer
(
'#likeBtn'
);
likeHammer
.
on
(
'tap'
,
function
(
e
)
{
var
productId
=
$
(
'#productId'
).
val
(),
opt
;
var
$this
=
$
(
this
);
if
(
$this
.
hasClass
(
'liked'
))
{
opt
=
'cancel'
;
}
else
{
opt
=
'ok'
;
}
$
.
ajax
({
type
:
'POST'
,
url
:
'/product/opt/favoriteProduct'
,
data
:
{
id
:
productId
,
opt
:
opt
},
success
:
function
(
data
)
{
if
(
data
.
code
===
200
)
{
$this
.
toggleClass
(
'liked'
);
}
else
if
(
data
.
code
===
400
)
{
location
.
href
=
data
.
data
;
//未登录跳转登录页
}
else
{
tip
.
show
(
data
.
message
);
}
},
error
:
function
()
{
tip
.
show
(
'网络断开连接了~'
);
}
});
});
\ No newline at end of file
...
...
static/sass/product/_detail.scss
View file @
c9d6709
...
...
@@ -346,14 +346,14 @@ $basicBtnC:#eb0313;
font-size
:
pxToRem
(
47px
);
color
:
#444
;
}
&
.unfavorite
{
font-size
:
pxToRem
(
34px
);
color
:
#ccc
;
}
&
.favorite
{
font-size
:
pxToRem
(
34px
);
color
:
$basicBtnC
;
color
:
#ccc
}
&
.favorite.liked
{
color
:
$basicBtnC
;;
}
&
.addto-cart
,
&
.sold-out
{
height
:
pxToRem
(
80px
);
...
...
template/m.yohobuy.com/actions/product/detail/index.phtml
View file @
c9d6709
...
...
@@ -119,9 +119,9 @@
<a
href=
""
class=
"sold-out"
>已售罄</a>
{
{/if
}
}
{
{#if
favorite
}
}
<a
href=
""
class=
"favorite iconfont
"
>
605
;</a>
<a
href=
""
id=
"likeBtn"
class=
"favorite iconfont liked
"
>
605
;</a>
{
{else
}
}
<a
href=
""
class=
"
unfavorite iconfont
"
>
605
;</a>
<a
href=
""
class=
"
favorite iconfont
"
>
605
;</a>
{
{/if
}
}
</div>
{
{/cartInfo
}
}
...
...
@@ -129,6 +129,10 @@
{
{#if
introUrl
}
}
<input
id=
"introUrl"
type=
"hidden"
value=
{
{introUrl
}
}>
{
{/if
}
}
{
{#if
id
}
}
<input
id=
"productId"
type=
"hidden"
value=
{
{id
}
}>
{
{/if
}
}
</div>
{
{>
layout/footer
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment