|
@@ -10,21 +10,14 @@ var $ = require('jquery'), |
|
@@ -10,21 +10,14 @@ var $ = require('jquery'), |
10
|
|
10
|
|
11
|
var chosePanel = require('./chose-panel');
|
11
|
var chosePanel = require('./chose-panel');
|
12
|
|
12
|
|
|
|
13
|
+//删除面板显示后任何点击行为都将触发隐藏面板
|
13
|
function docTouchEvt(e) {
|
14
|
function docTouchEvt(e) {
|
14
|
- var $tar = $(e.target);
|
|
|
15
|
-
|
|
|
16
|
- if ($tar.closest('.opt-panel').length === 0) {
|
|
|
17
|
$('.opt-panel:not(.hide)').addClass('hide');
|
15
|
$('.opt-panel:not(.hide)').addClass('hide');
|
18
|
|
16
|
|
19
|
//
|
17
|
//
|
20
|
- $(document).unbind('tap', docTouchEvt);
|
|
|
21
|
- }
|
18
|
+ $(document).off('touchstart', docTouchEvt);
|
22
|
}
|
19
|
}
|
23
|
|
20
|
|
24
|
-// function unbindDocTouchEvt(e) {
|
|
|
25
|
-// $(document).unbind('tap', docTouchEvt);
|
|
|
26
|
-// }
|
|
|
27
|
-
|
|
|
28
|
ellipsis.init();
|
21
|
ellipsis.init();
|
29
|
|
22
|
|
30
|
lazyLoad($('.lazy'));
|
23
|
lazyLoad($('.lazy'));
|
|
@@ -32,7 +25,7 @@ lazyLoad($('.lazy')); |
|
@@ -32,7 +25,7 @@ lazyLoad($('.lazy')); |
32
|
$('.name')[0].mlellipsis(2);
|
25
|
$('.name')[0].mlellipsis(2);
|
33
|
|
26
|
|
34
|
//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
|
27
|
//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
|
35
|
-$('.cart-goods').delegate('.checkbox', 'tap', function() {
|
28
|
+$('.cart-goods').on('touchstart', '.checkbox', function() {
|
36
|
var $this = $(this);
|
29
|
var $this = $(this);
|
37
|
|
30
|
|
38
|
if ($this.hasClass('icon-cb-checked')) {
|
31
|
if ($this.hasClass('icon-cb-checked')) {
|
|
@@ -40,7 +33,7 @@ $('.cart-goods').delegate('.checkbox', 'tap', function() { |
|
@@ -40,7 +33,7 @@ $('.cart-goods').delegate('.checkbox', 'tap', function() { |
40
|
} else {
|
33
|
} else {
|
41
|
$this.removeClass('icon-checkbox').addClass('icon-cb-checked');
|
34
|
$this.removeClass('icon-checkbox').addClass('icon-cb-checked');
|
42
|
}
|
35
|
}
|
43
|
-}).delegate('.icon-edit', 'tap', function() {
|
36
|
+}).on('touchstart', '.icon-edit', function() {
|
44
|
var id = $(this).closest('.shopping-cart-good').data('id');
|
37
|
var id = $(this).closest('.shopping-cart-good').data('id');
|
45
|
|
38
|
|
46
|
$.ajax({
|
39
|
$.ajax({
|
|
@@ -55,36 +48,33 @@ $('.cart-goods').delegate('.checkbox', 'tap', function() { |
|
@@ -55,36 +48,33 @@ $('.cart-goods').delegate('.checkbox', 'tap', function() { |
55
|
}
|
48
|
}
|
56
|
}
|
49
|
}
|
57
|
});
|
50
|
});
|
58
|
-}).delegate('.icon-del', 'tap', function(e) {
|
51
|
+}).on('touchstart', '.icon-del', function(e) {
|
59
|
e.stopPropagation();
|
52
|
e.stopPropagation();
|
60
|
|
53
|
|
61
|
$(this).closest('.shopping-cart-good').children('.opt-panel').removeClass('hide');
|
54
|
$(this).closest('.shopping-cart-good').children('.opt-panel').removeClass('hide');
|
62
|
|
55
|
|
63
|
- $(document).bind('tap', docTouchEvt);
|
|
|
64
|
-}).delegate('.opt-panel', 'tap', function() {
|
56
|
+ $(document).on('touchstart', docTouchEvt);
|
|
|
57
|
+}).on('touchstart', '.opt-panel', function() {
|
65
|
var $this = $(this),
|
58
|
var $this = $(this),
|
66
|
- id = $this.closest('.shopping-cart-good').data('id');
|
59
|
+ id = $this.closest('.shopping-cart-good').data('id'),
|
|
|
60
|
+ url;
|
67
|
|
61
|
|
68
|
if ($this.closest('.put-in-favorite')) {
|
62
|
if ($this.closest('.put-in-favorite')) {
|
69
|
|
63
|
|
70
|
//移入收藏夹
|
64
|
//移入收藏夹
|
71
|
- $.ajax({
|
|
|
72
|
- type: 'POST',
|
|
|
73
|
- url: '/shoppingCart/col',
|
|
|
74
|
- data: {
|
|
|
75
|
- id: id
|
|
|
76
|
- }
|
|
|
77
|
- });
|
65
|
+ url = '/shoppingCart/col';
|
78
|
} else {
|
66
|
} else {
|
79
|
|
67
|
|
80
|
//删除
|
68
|
//删除
|
|
|
69
|
+ url = '/shoppingCart/del';
|
|
|
70
|
+ }
|
|
|
71
|
+
|
81
|
$.ajax({
|
72
|
$.ajax({
|
82
|
type: 'POST',
|
73
|
type: 'POST',
|
83
|
- url: '/shoppingCart/del',
|
74
|
+ url: url,
|
84
|
data: {
|
75
|
data: {
|
85
|
id: id
|
76
|
id: id
|
86
|
}
|
77
|
}
|
87
|
});
|
78
|
});
|
88
|
- }
|
|
|
89
|
});
|
79
|
});
|
90
|
|
80
|
|