Authored by 梁志锋

update

/**
* 男首
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
* @date: 2015/10/12
*/
var $ = require('yoho.zepto'),
lazyLoad = require('yoho.lazyload');
//Init LazyLoad
lazyLoad($('img.lazy'));
\ No newline at end of file
/**
* kids,lifestyle商品模块JS
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
* @date: 2015/10/12
*/
\ No newline at end of file
/**
* 女首
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
* @date: 2015/10/12
*/
require('./home');
\ No newline at end of file
... ... @@ -11,6 +11,8 @@ var $ = require('yoho.zepto'),
trendTopicSwiper,
goodsSwiper;
require('./maybe-like');
var swiperClass;
var requestFrame,
... ...
... ... @@ -4,4 +4,5 @@
* @date: 2015/10/12
*/
require('./home');
\ No newline at end of file
require('./home');
require('./maybe-like');
\ No newline at end of file
... ...
/**
* 儿童
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
* @date: 2015/10/12
*/
require('./home');
\ No newline at end of file
/**
* 创意生活
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
* @date: 2015/10/12
*/
require('./home');
\ No newline at end of file
... ... @@ -4,120 +4,57 @@
* @date: 2015/10/12
*/
/**
* “你可能喜欢”模块JS
* @author: xuqi(qi.xu@yoho.cn)
* @date: 2015/7/15
*/
var $ = require('yoho.zepto'),
lazyLoad = require('yoho.lazyload');
var $maybeLike = $('.maybe-like:last');
lazyLoad = require('yoho.lazyload'),
tip = require('../plugin/tip');
var winH = $(window).height(),
loadMoreH = $('#load-more').height(),
loading = false,
end = false,
page = 1,
type = '',
page = 0,
gender = '',
num,
res;
var $goodList = $maybeLike.children('.goods-list'),
mblTop; //页面内容固定,可以预先求出高度
var isLogin = 'Y'; //是否登录,后台提供,区分走Ajax还是页面跳转
if ($('.maybe-like').size() <= 0) {
return;
}
mblTop = $maybeLike.offset().top;
// 无可能喜欢模块时直接返回
if ($maybeLike.length === 0) {
return;
}
//read good-info template
/*$.get('/common/goodinfo', function (data) {
tpl = '{{# goods}}' + data + '{{/ goods}}';
Mustache.parse(tpl);
});*/
type = $('.mobile-wrap').hasClass('boys-wrap') ? 'index' : 'girl';
//商品收藏
$('.goods-list').delegate('.good-islike', 'touchstart', function (e) {
var $cur, $good, id, url;
if (isLogin === 'Y') {
e.preventDefault(); // 阻止链接跳转改AJAX
$cur = $(e.currentTarget);
$good = $cur.closest('.good-info');
id = $good.data('id');
if ($cur.hasClass('good-like')) {
url = '/' + type + '/cancelprise';
} else {
url = '/' + type + '/prise';
}
gender = $('.mobile-wrap').hasClass('boys-wrap') ? '1,3' : '2,3';
var $goodList = $('#goods-list');
//srcoll to load more
$(window).scroll(function () {
if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) {
loading = true;
num = $goodList.children('.good-info').length;
$.ajax({
type: 'GET',
url: url,
url: '/product/recom/maylike?gender='+gender,
data: {
id: id
}
}).then(function (data) {
if (data.code === 200) {
$cur.toggleClass('good-like');
page: page + 1
},
success: function(data) {
if (data.code === 200) {
res = data.data;
if (res.end) {
end = res.end;
}
$goodList.append(res.product);
//lazyLoad
lazyLoad($goodList.children('.good-info:gt(' + (num - 1) + ')').find('img.lazy'));
loading = false;
page++;
}
},
error: function() {
tip.show('网络断开连接了~');
loading = false;
}
});
}
});
//srcoll to load more
$(window).scroll(function () {
if (end || loading) {
return;
}
if ($(window).scrollTop() + winH < mblTop + $maybeLike.height()) {
return;
}
loading = true;
num = $goodList.children('.good-info').length;
$.ajax({
type: 'GET',
url: '/' + type + '/getmore',
data: {
page: page + 1
}
}).then(function (data) {
if (data.code === 200) {
res = data.data;
if (res.end) {
end = res.end;
}
/*$goodList.append(Mustache.render(tpl, {
goods: res.goods
}));*/
$goodList.append(res.goods);
//lazyLoad
lazyLoad($goodList.children('.good-info:gt(' + (num - 1) + ')').find('img.lazy'));
loading = false;
page++;
}
});
});
\ No newline at end of file
... ...
... ... @@ -2,7 +2,4 @@
* 频道选择
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
* @date: 2015/10/12
*/
var $ = require('yoho.zepto');
\ No newline at end of file
*/
\ No newline at end of file
... ...
... ... @@ -54,11 +54,9 @@
{{# plusStar}}
{{> home/plus_star}}
{{/ plusStar}}
{{! 可能喜欢}}
{{# maybeLike}}
{{> home/maybe_like}}
{{/ maybeLike}}
{{! 可能喜欢}}
{{> home/maybe_like}}
{{/ content}}
\ No newline at end of file
... ...
... ... @@ -3,9 +3,18 @@
<i class="icon"></i>
<span>你可能喜欢</span>
</p>
{{# maybeLike}}
<div class="goods-list clearfix">
{{# goods}}
{{> good}}
{{/ goods}}
</div>
{{/ maybeLike}}
<div id="load-more-info" class="load-more-info">
<div class="loading status">
正在加载...
</div>
<span class="no-more status hide">没有更多啦</span>
</div>
</div>
\ No newline at end of file
... ...