Authored by xuqi

添加登录跳转

... ... @@ -12,6 +12,7 @@
{{{body}}}
</div>
<div id="login-tip" class="login-tip">未登录</div>
<input id="is-login" type="hidden" value="{{isLogin}}">
</body>
{{> footer}}
</html>
\ No newline at end of file
... ...
... ... @@ -19,6 +19,8 @@ exports.init = function() {
var $intro = $('#intro'),
winH = $(window).height(),
tpl;
var isLogin = $('#is-login').val();
isLogin = isLogin ? isLogin : 'N';
//登录提示变量
var $loginTip = $('#login-tip'),
winW,
... ... @@ -71,29 +73,38 @@ exports.init = function() {
//绑定商品信息的收藏和取消收藏事件(相关推荐和搭配模块)
$('.new-arrival-content').delegate('.good-islike', 'touchstart', function(e) {
var $cur = $(e.currentTarget),
$good = $cur.closest('.good-info'),
var $cur,
$good,
id;
if (isLogin === 'N') {
$cur = $(e.currentTarget);
$good = $cur.closest('.good-info');
id = $good.data('id');
$.ajax({
type: 'GET',
url: '/favorite/product',
data: {
st: 0,
product_skn: id
}
}).then(function(data) {
if (data.code === 200) {
$cur.toggleClass('good-like');
} else if (data.code === 400) {
//提示登录信息
$('#login-tip').fadeIn(500, function() {
setTimeout(function() {
$('#login-tip').fadeOut(500);
}, 1000);
});
}
});
$.ajax({
type: 'GET',
url: '/favorite/product',
data: {
st: 0,
product_skn: id
}
}).then(function(data) {
if (data.code === 200) {
$cur.toggleClass('good-like');
} else if (data.code === 400) {
//提示登录信息
$('#login-tip').fadeIn(500, function() {
setTimeout(function() {
$('#login-tip').fadeOut(500);
}, 1000);
});
}
});
}
}).delegate('.good-islike', 'click', function(e) {
if (isLogin === 'N') {
e.preventDefault();
}
});
//文章点赞
... ... @@ -129,27 +140,37 @@ exports.init = function() {
});
});
$('#brand-like').bind('touchstart', function() {
var $cur = $(this),
$('#brand-like').bind('touchstart', function(e) {
var $cur,
id;
if (isLogin === 'N') {
$cur = $(this);
id = $(this).closest('.brand-info').data('id');
$.ajax({
type: 'GET',
url: '/favorite/brand',
data: {
brand_id: id
}
}).then(function(data) {
if (data.code === 200) {
$cur.toggleClass('like');
} else if (data.code === 400) {
$('#login-tip').fadeIn(500, function() {
setTimeout(function() {
$('#login-tip').fadeOut(500);
}, 1000);
});
}
});
//
$.ajax({
type: 'GET',
url: '/favorite/brand',
data: {
brand_id: id
}
}).then(function(data) {
if (data.code === 200) {
$cur.toggleClass('like');
} else if (data.code === 400) {
$('#login-tip').fadeIn(500, function() {
setTimeout(function() {
$('#login-tip').fadeOut(500);
}, 1000);
});
}
});
}
}).bind('click', function(e) {
if (isLogin === 'N') {
//阻止链接跳转
e.preventDefault();
}
});
});
};
\ No newline at end of file
... ...
... ... @@ -21,6 +21,9 @@ exports.init = function() {
tipH,
tipW;
var isLogin = $('#is-login').val();
isLogin = isLogin ? isLogin : 'N';
//头部作者信息样式计算(在描述信息过长时换行显示, 去除intro的padding-top)
var $linkC = $('#link-container'),
$avatar = $linkC.find('.avatar'),
... ... @@ -56,29 +59,38 @@ exports.init = function() {
//绑定商品信息的收藏和取消收藏事件(相关推荐和搭配模块)
$('.good-list, .prod-list').delegate('.good-islike', 'touchstart', function(e) {
var $cur = $(e.currentTarget),
$good = $cur.closest('.good-info'),
var $cur,
$good,
id;
if (isLogin === 'N') {
$cur = $(e.currentTarget);
$good = $cur.closest('.good-info');
id = $good.data('id');
$.ajax({
type: 'GET',
url: '/favorite/product',
data: {
st: 1,
product_skn: id
}
}).then(function(data) {
if (data.code === 200) {
$cur.toggleClass('good-like');
} else if (data.code === 400) {
//提示登录信息
$('#login-tip').fadeIn(500, function() {
setTimeout(function() {
$('#login-tip').fadeOut(500);
}, 1000);
});
}
});
$.ajax({
type: 'GET',
url: '/favorite/product',
data: {
st: 1,
product_skn: id
}
}).then(function(data) {
if (data.code === 200) {
$cur.toggleClass('good-like');
} else if (data.code === 400) {
//提示登录信息
$('#login-tip').fadeIn(500, function() {
setTimeout(function() {
$('#login-tip').fadeOut(500);
}, 1000);
});
}
});
}
}).delegate('.good-islike', 'click', function(e) {
if (isLogin === 'N') {
e.preventDefault();
}
});
});
};
\ No newline at end of file
... ...
... ... @@ -24,7 +24,10 @@ exports.init = function() {
$svc = $goodList.filter('.sales-volume-container'),
$pc = $goodList.filter('.price-container'),
tpl; //商品信息模板
var isLogin = $('#is-login').val();
isLogin = isLogin ? isLogin : 'N';
//筛选相关变量
var curFilter = {
brand: '',
... ... @@ -400,28 +403,37 @@ exports.init = function() {
//Like
$('#goods-content').delegate('.good-islike', 'touchstart', function(e) {
var $cur = $(e.currentTarget),
$good = $cur.closest('.good-info'),
var $cur,
$good,
id;
if (isLogin === 'N') {
$cur = $(e.currentTarget);
$good = $cur.closest('.good-info');
id = $good.data('id');
$.ajax({
type: 'GET',
url: '/favorite/product',
data: {
product_skn: id
}
}).then(function(data) {
if (data.code === 200) {
$cur.toggleClass('good-like');
} else if (data.code === 400) {
//提示登录信息
$('#login-tip').fadeIn(500, function() {
setTimeout(function() {
$('#login-tip').fadeOut(500);
}, 1000);
});
}
});
$.ajax({
type: 'GET',
url: '/favorite/product',
data: {
product_skn: id
}
}).then(function(data) {
if (data.code === 200) {
$cur.toggleClass('good-like');
} else if (data.code === 400) {
//提示登录信息
$('#login-tip').fadeIn(500, function() {
setTimeout(function() {
$('#login-tip').fadeOut(500);
}, 1000);
});
}
});
}
}).delegate('.good-islike', 'click', function(e) {
if (isLogin === 'N') {
e.preventDefault();
}
});
});
};
\ No newline at end of file
... ...
... ... @@ -6,7 +6,7 @@
<div class="header-content">
<p class="name-islike-container">
<span class="name">{{name}}</span>
<a id="brand-like" class="brand-islike iconfont {{# isLike}}like{{/ isLike}}" href="javascript:void(0)">
<a id="brand-like" class="brand-islike iconfont {{# isLike}}like{{/ isLike}}" href="{{likeUrl}}">
&#xe605;
</a>
</p>
... ...
<div class="good-info" data-id="{{id}}">
<div class="good-detail-img">
<a class="good-islike {{# isLike}}good-like{{/ isLike}} iconfont" href="javascript:;">&#xe605;</a>
<a class="good-islike {{# isLike}}good-like{{/ isLike}} iconfont" href="{{likeUrl}}">&#xe605;</a>
<a class="good-thumb" href="{{url}}">
<img class="lazy" data-original="{{thumb}}">
</a>
... ...