|
|
/**
|
|
|
* 浏览记录
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/11/28
|
|
|
*/
|
|
|
var $ = require('yoho-jquery');
|
|
|
|
|
|
var lazyLoad = require('yoho-jquery-lazyload'),
|
|
|
load = require('../plugin/loading'),
|
|
|
tip = require('../plugin/tip');
|
|
|
|
|
|
var dialog = require('../plugin/dialog');
|
|
|
|
|
|
var $page = $('.records');
|
|
|
|
|
|
var $loadMore = $('.load-more'),
|
|
|
$more = $loadMore.children('.more'),
|
|
|
$noMore = $loadMore.children('.no-more');
|
|
|
|
|
|
var page = 0;
|
|
|
|
|
|
var end = false,
|
|
|
loading = false;
|
|
|
|
|
|
var winH = $(window).height();
|
|
|
|
|
|
require('../common');
|
|
|
load.init();
|
|
|
function moreRecord(cb) {
|
|
|
var count = $page.children('.browse-record-good').length;
|
|
|
|
|
|
if (loading) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (page === 1) {
|
|
|
$loadMore.removeClass('hide');
|
|
|
}
|
|
|
|
|
|
loading = true;
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/home/recordContent',
|
|
|
data: {
|
|
|
page: page + 1
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data === ' ') {
|
|
|
end = true;
|
|
|
|
|
|
$more.addClass('hide');
|
|
|
$noMore.removeClass('hide');
|
|
|
} else {
|
|
|
|
|
|
if (count === 0) {
|
|
|
$page.html(data);
|
|
|
|
|
|
lazyLoad();
|
|
|
} else {
|
|
|
$page.append(data);
|
|
|
|
|
|
lazyLoad($page.find('.browse-record-good:gt(' + (count - 1) + ') .lazy'));
|
|
|
}
|
|
|
window.rePosFooter();
|
|
|
page++;
|
|
|
|
|
|
if (cb) {
|
|
|
cb();
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
complete: function() {
|
|
|
loading = false;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
load.showLoadingMask();
|
|
|
moreRecord(load.hideLoadingMask);
|
|
|
|
|
|
$(window).scroll(function() {
|
|
|
if (end) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (winH + $(window).scrollTop() > $(document).height() - 0.25 * $page.height()) {
|
|
|
moreRecord();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$page.on('touchstart', '.del-icon', function() {
|
|
|
var $good = $(this).closest('.browse-record-good'),
|
|
|
skn = $good.data('skn');
|
|
|
|
|
|
dialog.showDialog({
|
|
|
dialogText: '确定删除此条浏览记录吗?',
|
|
|
hasFooter: {
|
|
|
leftBtnText: '取消',
|
|
|
rightBtnText: '确定'
|
|
|
}
|
|
|
}, function() {
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/home/delRecord',
|
|
|
data: {
|
|
|
skn: skn
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
dialog.showDialog({
|
|
|
dialogText: '删除浏览记录成功',
|
|
|
autoHide: 2000,
|
|
|
fast: true
|
|
|
});
|
|
|
setTimeout(function() {
|
|
|
window.history.go(0);
|
|
|
}, 1200);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
|
|
|
$('.deps').on('touchstart', 'span', function() {
|
|
|
$(this).css('background', '#eee');
|
|
|
}).on('touchend touchcancel', 'span', function() {
|
|
|
$(this).css('background', 'transparent');
|
|
|
});
|
|
|
|
|
|
$('.invalidGoods').on('touchstart touchend', function(e) {
|
|
|
var $this = $(e.target).closest('span');
|
|
|
|
|
|
if ($this.hasClass('del-icon')) {
|
|
|
return;
|
|
|
}
|
|
|
tip.show('商品已下架');
|
|
|
return false;
|
|
|
}); |
...
|
...
|
|