...
|
...
|
@@ -10,21 +10,14 @@ var $ = require('jquery'), |
|
|
|
|
|
var chosePanel = require('./chose-panel');
|
|
|
|
|
|
//删除面板显示后任何点击行为都将触发隐藏面板
|
|
|
function docTouchEvt(e) {
|
|
|
var $tar = $(e.target);
|
|
|
|
|
|
if ($tar.closest('.opt-panel').length === 0) {
|
|
|
$('.opt-panel:not(.hide)').addClass('hide');
|
|
|
|
|
|
//
|
|
|
$(document).unbind('tap', docTouchEvt);
|
|
|
}
|
|
|
$(document).off('touchstart', docTouchEvt);
|
|
|
}
|
|
|
|
|
|
// function unbindDocTouchEvt(e) {
|
|
|
// $(document).unbind('tap', docTouchEvt);
|
|
|
// }
|
|
|
|
|
|
ellipsis.init();
|
|
|
|
|
|
lazyLoad($('.lazy'));
|
...
|
...
|
@@ -32,7 +25,7 @@ lazyLoad($('.lazy')); |
|
|
$('.name')[0].mlellipsis(2);
|
|
|
|
|
|
//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
|
|
|
$('.cart-goods').delegate('.checkbox', 'tap', function() {
|
|
|
$('.cart-goods').on('touchstart', '.checkbox', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
if ($this.hasClass('icon-cb-checked')) {
|
...
|
...
|
@@ -40,7 +33,7 @@ $('.cart-goods').delegate('.checkbox', 'tap', function() { |
|
|
} else {
|
|
|
$this.removeClass('icon-checkbox').addClass('icon-cb-checked');
|
|
|
}
|
|
|
}).delegate('.icon-edit', 'tap', function() {
|
|
|
}).on('touchstart', '.icon-edit', function() {
|
|
|
var id = $(this).closest('.shopping-cart-good').data('id');
|
|
|
|
|
|
$.ajax({
|
...
|
...
|
@@ -55,36 +48,33 @@ $('.cart-goods').delegate('.checkbox', 'tap', function() { |
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}).delegate('.icon-del', 'tap', function(e) {
|
|
|
}).on('touchstart', '.icon-del', function(e) {
|
|
|
e.stopPropagation();
|
|
|
|
|
|
$(this).closest('.shopping-cart-good').children('.opt-panel').removeClass('hide');
|
|
|
|
|
|
$(document).bind('tap', docTouchEvt);
|
|
|
}).delegate('.opt-panel', 'tap', function() {
|
|
|
$(document).on('touchstart', docTouchEvt);
|
|
|
}).on('touchstart', '.opt-panel', function() {
|
|
|
var $this = $(this),
|
|
|
id = $this.closest('.shopping-cart-good').data('id');
|
|
|
id = $this.closest('.shopping-cart-good').data('id'),
|
|
|
url;
|
|
|
|
|
|
if ($this.closest('.put-in-favorite')) {
|
|
|
|
|
|
//移入收藏夹
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/shoppingCart/col',
|
|
|
data: {
|
|
|
id: id
|
|
|
}
|
|
|
});
|
|
|
url = '/shoppingCart/col';
|
|
|
} else {
|
|
|
|
|
|
//删除
|
|
|
url = '/shoppingCart/del';
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/shoppingCart/del',
|
|
|
url: url,
|
|
|
data: {
|
|
|
id: id
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
...
|
...
|
|