Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYWAP
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
xuqi
9 years ago
Commit
2a0eba5cbae0a3e19c1da513148789283fb513ab
1 parent
68d454e9
event rebuild
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
38 deletions
static/js/shopping-cart/chose-panel.js
static/js/shopping-cart/good.js
static/js/shopping-cart/chose-panel.js
View file @
2a0eba5
...
...
@@ -5,8 +5,8 @@
* @date: 2015/10/21
*/
var
$
=
require
(
'jquery'
);
var
Handlebars
=
require
(
'yoho.handlebars'
);
var
$
=
require
(
'jquery'
),
Handlebars
=
require
(
'yoho.handlebars'
);
var
$page
=
$
(
'.yoho-page'
);
...
...
@@ -37,7 +37,7 @@ function remove() {
$
(
'.chose-panel'
).
remove
();
}
$
(
'.yoho-page'
).
delegate
(
'.chose-panel'
,
'tap
'
,
function
(
e
)
{
$
(
'.yoho-page'
).
on
(
'touchstart'
,
'.chose-panel
'
,
function
(
e
)
{
var
$cur
=
$
(
e
.
target
);
if
(
$cur
.
closest
(
'.main'
).
length
>
0
)
{
...
...
@@ -46,10 +46,10 @@ $('.yoho-page').delegate('.chose-panel', 'tap', function(e) {
//点击蒙版消失
remove
();
}).
delegate
(
'#chose-btn-sure'
,
'tap
'
,
function
()
{
}).
on
(
'touchstart'
,
'#chose-btn-sure
'
,
function
()
{
//确定
}).
delegate
(
'.block'
,
'tap
'
,
function
()
{
}).
on
(
'touchstart'
,
'.block
'
,
function
()
{
//尺寸颜色点选
var
$this
=
$
(
this
);
...
...
@@ -60,7 +60,7 @@ $('.yoho-page').delegate('.chose-panel', 'tap', function(e) {
$this
.
siblings
(
'.chosed'
).
removeClass
(
'chosed'
);
$this
.
addClass
(
'chosed'
);
}).
delegate
(
'.btn-minus'
,
'tap
'
,
function
()
{
}).
on
(
'touchstart'
,
'.btn-minus
'
,
function
()
{
var
num
=
+
$num
.
val
();
if
(
num
===
1
)
{
...
...
@@ -68,7 +68,7 @@ $('.yoho-page').delegate('.chose-panel', 'tap', function(e) {
}
$num
.
val
(
num
-
1
);
}).
delegate
(
'.btn-plus'
,
'tap
'
,
function
()
{
}).
on
(
'touchstart'
,
'.btn-plus
'
,
function
()
{
var
num
=
+
$num
.
val
();
//TODO:库存数验证
...
...
static/js/shopping-cart/good.js
View file @
2a0eba5
...
...
@@ -10,21 +10,14 @@ var $ = require('jquery'),
var
chosePanel
=
require
(
'./chose-panel'
);
//删除面板显示后任何点击行为都将触发隐藏面板
function
docTouchEvt
(
e
)
{
var
$tar
=
$
(
e
.
target
);
$
(
'.opt-panel:not(.hide)'
).
addClass
(
'hide'
);
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
{
//删除
$
.
ajax
({
type
:
'POST'
,
url
:
'/shoppingCart/del'
,
data
:
{
id
:
id
}
});
url
=
'/shoppingCart/del'
;
}
$
.
ajax
({
type
:
'POST'
,
url
:
url
,
data
:
{
id
:
id
}
});
});
...
...
Please
register
or
login
to post a comment