Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHO-ACTIVITY-PHP
·
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
Lynnic
9 years ago
Commit
5f046a161ab08c779d41e4436a1edfe8ab4984cc
1 parent
4b72d481
购物车逻辑修改
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
12 deletions
static/js/shopping-cart/chose-panel.js
template/m.yohobuy.com/partials/shopping-cart/chose-panel.phtml
static/js/shopping-cart/chose-panel.js
View file @
5f046a1
...
...
@@ -12,7 +12,11 @@ var $ = require('jquery');
// var $page = $('.yoho-page');
var
$num
,
$chosed
;
$chosed
,
re
=
/
\d
+/
,
leftNum
;
// confirm;
// var tpl;
...
...
@@ -37,6 +41,7 @@ var $num,
function
show
()
{
$
(
'.chose-panel'
).
show
();
$
(
'body'
).
css
(
'overflow'
,
'hidden'
);
$num
=
$
(
'#good-num'
);
}
...
...
@@ -58,10 +63,44 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
remove
();
}).
on
(
'touchstart'
,
'#chose-btn-sure'
,
function
()
{
//确定
}).
on
(
'touchstart'
,
'.block'
,
function
(
e
)
{
// var
// // goodId,
// // skuId,
// skcId = $('.color-list li.chosed').data('skcid'),
// colorIndex = $('.color-list li.chosed').index(),
// skuArray = $('.size-list').data('skustr').split('/');
// //确定
// $chosed = $('.block-list>ul>li.chosed');
// if (2 === $chosed.length && 2 !== $chosed.closest('.zero-stock').length) {
// if (confirm) {
// return false;
// }
// confirm = true;
// loading.showLoadingMask();
// $.ajax({
// method: 'POST',
// url: '/product/detail/xxxx',
// data: {
// product_id: productId,
// content: content
// }
// }).done(function(res) {
// if (res.code === 200) {
// loading.hideLoadingMask();
// confirm = false;
// remove();
// }
// }).fail(function() {
// tip.show('网络出了点问题~');
// confirm = false;
// });
// }
//尺寸颜色点选
}).
on
(
'touchstart'
,
'.block'
,
function
(
e
)
{
var
$this
=
$
(
this
),
$that
=
$
(
e
.
target
).
closest
(
'.chose-items'
),
numArray
,
...
...
@@ -104,6 +143,9 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
}
}
}
else
if
(
$chosed
.
length
===
1
&&
!
$this
.
hasClass
(
'chosed'
))
{
$
(
'#chose-btn-sure'
).
css
(
'background-color'
,
'#eb0313'
);
$
(
'#chose-btn-sure'
).
html
(
'确定'
);
$siblingBlock
.
find
(
'ul>li'
).
each
(
function
()
{
$
(
this
).
removeClass
(
'zero-stock'
);
if
(
0
===
$
(
this
).
data
(
'num'
)
-
0
)
{
...
...
@@ -123,19 +165,23 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
if
(
2
===
$chosed
.
closest
(
'.zero-stock'
).
length
)
{
$
(
'#chose-btn-sure'
).
css
(
'background-color'
,
'#c0c0c0'
);
$
(
'#chose-btn-sure'
).
html
(
'已售罄'
);
}
else
{
$
(
'#chose-btn-sure'
).
css
(
'background-color'
,
'#eb0313'
);
$
(
'#chose-btn-sure'
).
html
(
'确定'
);
}
}
}).
on
(
'touchstart'
,
'.btn-minus'
,
function
()
{
var
num
=
+
$num
.
val
(),
$chosed
=
$
(
'.block-list>ul>li.chosed'
);
$chosed
=
$
(
'.block-list>ul>li.chosed'
),
leftNum
=
re
.
exec
(
$
(
'.num .left-num'
).
html
());
//若颜色和尺码没有被同时选中,则不能点击
if
(
$chosed
.
length
<
2
)
{
return
;
}
if
(
num
===
0
)
{
if
(
num
===
1
||
0
===
leftNum
-
0
)
{
return
;
}
...
...
@@ -147,6 +193,10 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
if
(
$
(
'.block-list>ul>li.chosed'
).
length
<
2
)
{
return
;
}
leftNum
=
re
.
exec
(
$
(
'.num .left-num'
).
html
());
if
(
num
-
0
===
leftNum
-
0
||
0
===
leftNum
-
0
)
{
return
;
}
//TODO:库存数验证
$num
.
val
(
num
+
1
);
...
...
template/m.yohobuy.com/partials/shopping-cart/chose-panel.phtml
View file @
5f046a1
...
...
@@ -2,7 +2,7 @@
<div
class=
"chose-panel"
>
<div
class=
"main"
>
<div
class=
"infos"
>
<div
class=
"basic-info"
>
<div
class=
"basic-info"
>
{
{#thumbs
}
}
{
{#if
@first
}
}
<img
class=
"thumb"
src=
{
{img
}
}>
...
...
@@ -25,17 +25,18 @@
<span>颜色</span>
<ul
class=
"clearfix"
data-type=
"color"
>
{
{#
colors
}
}
<li
class=
"block {{#if chosed}}chosed{{/if}} {{#unless colorNum}}zero-stock{{/unless}}"
data-num=
"{{colorNum}}"
data-numstr=
"{{sizeNumStr}}"
data-skcid=
"{{skcId}}"
>
<li
class=
"block {{#if chosed}}chosed{{/if}} {{#unless colorNum}}zero-stock{{/unless}}"
data-num=
"{{colorNum}}"
data-
id=
"{{id}}"
data-
numstr=
"{{sizeNumStr}}"
data-skcid=
"{{skcId}}"
>
{
{name
}
}
</li>
{
{/
colors
}
}
</ul>
</div>
<div
class=
"size-list block-list"
>
<span>尺码</span>
<span>尺码</span>
<ul
class=
"clearfix"
data-type=
"size"
>
{
{#
sizes
}
}
<li
class=
"block {{#if chosed}}chosed{{/if}} {{#unless sizeNum}}zero-stock{{/unless}}"
data-id=
{
{id
}
}
data-
num=
"{{sizeNum}}"
data-numstr=
"{{colorNumStr}}"
data-skuid=
"{{skuId}}"
data-goodid=
"{{good
Id}}"
>
<li
class=
"block {{#if chosed}}chosed{{/if}} {{#unless sizeNum}}zero-stock{{/unless}}"
data-id=
{
{id
}
}
data-
colorid=
"{{colorId}}"
data-num=
"{{sizeNum}}"
data-numstr=
"{{colorNumStr}}"
data-skuid=
"{{skuId}}"
data-goodid=
"{{goods
Id}}"
>
{
{name
}
}
</li>
{
{/
sizes
}
}
...
...
@@ -47,7 +48,7 @@
<a
class=
"btn btn-minus"
href=
"javascript:void(0);"
>
<span
class=
"iconfont"
>
625
;</span>
</a>
<input
id=
"good-num"
class=
"good-num"
type=
"text"
value=
{
{num
}
}
>
<input
id=
"good-num"
class=
"good-num"
type=
"text"
value=
"1"
>
<a
class=
"btn btn-plus"
href=
"javascript:void(0);"
>
<span
class=
"iconfont"
>
624
;</span>
</a>
...
...
@@ -57,7 +58,7 @@
</div>
</div>
<div
class=
"btn-wrap"
>
<button
id=
"chose-btn-sure"
class=
"btn btn-sure"
>
加入购物车
</button>
<button
id=
"chose-btn-sure"
class=
"btn btn-sure"
>
确定
</button>
</div>
</div>
</div>
...
...
Please
register
or
login
to post a comment