Toggle navigation
Toggle navigation
This project
Loading...
Sign in
chenchao
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to dashboard
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
a167de6943355cbaebd36256ca47492b07d63253
1 parent
a207ac2c
cart style/logic
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
81 deletions
static/js/cart/cart.js
static/js/cart/good.js
static/sass/cart/_good.scss
template/m.yohobuy.com/actions/cart/index/index.phtml
template/m.yohobuy.com/partials/cart/good.phtml
static/js/cart/cart.js
View file @
a167de6
...
...
@@ -16,6 +16,8 @@ var $cartContent = $('.cart-content');
var
navHammer
,
cartType
=
$
(
'#cartType'
).
val
();
var
hasChecked
=
$
(
'.cart-goods .icon-cb-checked'
).
length
>
0
?
true
:
false
;
//是否有选中商品
require
(
'./good'
);
lazyLoad
(
$
(
'img.lazy'
));
...
...
@@ -47,11 +49,11 @@ if ($('.cart-nav').length > 0) {
}
$
(
'.btn-balance'
).
on
(
'touchend'
,
function
()
{
if
(
$
(
'.balance span'
).
hasClass
(
'icon-cb-checked'
)){
window
.
location
.
href
=
'/cart/index/orderEnsure?cartType='
+
cartType
;
}
else
{
tip
.
show
(
'请先勾选商品~'
);
}
if
(
hasChecked
)
{
window
.
location
.
href
=
'/cart/index/orderEnsure?cartType='
+
cartType
;
}
else
{
tip
.
show
(
'请先勾选商品'
);
}
});
$
(
'.chose'
).
on
(
'touchend'
,
function
()
{
...
...
@@ -59,3 +61,6 @@ $('.chose').on('touchend', function() {
//var id = $(this).closest('.gift-advance-good').data('id');
chosePanel
.
show
();
});
//提前触发lazyload
$
(
window
).
scrollTop
(
1
).
scrollTop
(
0
);
\ No newline at end of file
...
...
static/js/cart/good.js
View file @
a167de6
...
...
@@ -12,8 +12,7 @@ var $ = require('jquery'),
var
dialog
=
require
(
'../me/dialog'
),
tip
=
require
(
'../plugin/tip'
);
var
$names
,
$selectAllBtn
=
$
(
'.balance .iconfont'
),
var
$selectAllBtn
=
$
(
'.balance .checkbox'
),
cartType
=
$
(
'#cartType'
).
val
(),
requesting
=
false
;
...
...
@@ -23,11 +22,9 @@ lazyLoad({
try_again_css
:
'good-failure'
});
$names
=
$
(
'.name'
);
if
(
$names
.
length
>
0
)
{
$names
[
0
].
mlellipsis
(
2
);
}
$
(
'.shopping-cart-good .name'
).
each
(
function
()
{
this
.
mlellipsis
(
2
);
});
//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
$
(
'.cart-goods'
).
on
(
'touchstart'
,
'.checkbox'
,
function
()
{
...
...
@@ -73,44 +70,12 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
}
else
{
$this
.
removeClass
(
'icon-checkbox'
).
addClass
(
'icon-cb-checked'
);
}
$
.
ajax
({
type
:
'GET'
,
url
:
'getCartData'
,
data
:
{
id
:
id
},
success
:
function
(
data
)
{
if
(
data
)
{
if
(
cartType
===
'ordinary'
)
{
$
(
'#good-totalprice'
).
html
(
'¥'
+
data
.
commonCart
.
price
);
$
(
'#good-activityPrice'
).
html
(
'¥'
+
data
.
commonCart
.
activityPrice
);
$
(
'#good-total'
).
html
(
'总计:¥'
+
data
.
commonCart
.
sumPrice
+
' ('
+
data
.
commonCart
.
count
+
'件)'
);
if
(
data
.
commonCart
.
isAllSelected
)
{
$
(
'.balance span'
).
removeClass
(
'icon-checkbox'
).
addClass
(
'icon-cb-checked'
);
}
else
{
$
(
'.balance span'
).
removeClass
(
'icon-cb-checked'
).
addClass
(
'icon-checkbox'
);
}
}
else
{
$
(
'#good-totalprice'
).
html
(
'¥'
+
data
.
preSellCart
.
price
);
$
(
'#good-activityPrice'
).
html
(
'¥'
+
data
.
preSellCart
.
activityPrice
);
$
(
'#good-total'
).
html
(
'总计:¥'
+
data
.
preSellCart
.
sumPrice
+
' ('
+
data
.
preSellCart
.
count
+
'件)'
);
if
(
data
.
preSellCart
.
isAllSelected
)
{
$
(
'.balance span'
).
removeClass
(
'icon-checkbox'
).
addClass
(
'icon-cb-checked'
);
}
else
{
$
(
'.balance span'
).
removeClass
(
'icon-cb-checked'
).
addClass
(
'icon-checkbox'
);
}
}
}
},
error
:
function
()
{
tip
.
show
(
'网络错误'
);
}
});
window
.
history
.
go
(
0
);
}
else
if
(
data
.
code
===
400
)
{
tip
.
show
(
'网络
错误
'
);
tip
.
show
(
'网络
异常
'
);
}
}).
fail
(
function
()
{
tip
.
show
(
'网络错误'
);
},
function
()
{
tip
.
show
(
'网络异常'
);
});
}).
on
(
'touchstart'
,
'.icon-del'
,
function
(
e
)
{
var
$this
=
$
(
this
);
...
...
@@ -143,10 +108,10 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
});
history
.
go
(
0
);
}
}
).
fail
(
function
()
{
}
,
function
()
{
dialog
.
showDialog
({
autoHide
:
true
,
dialogText
:
'网络
错误~
'
dialogText
:
'网络
异常
'
});
});
});
...
...
@@ -203,6 +168,7 @@ function didUpdateAllGoodsCheckStatus() {
$
(
checkedBox
).
removeClass
(
'icon-cb-checked'
).
addClass
(
'icon-checkbox'
);
});
}
window
.
history
.
go
(
0
);
}
function
bottomCheckBoxHandeler
(
isSelected
,
type
,
handlerAfterTouch
)
{
...
...
@@ -251,6 +217,7 @@ function willBeSelected($this) {
//全选按钮点击事件
$selectAllBtn
.
on
(
'touchend'
,
function
()
{
var
$this
=
$
(
this
);
bottomCheckBoxHandeler
(
willBeSelected
(
$this
),
cartType
,
didUpdateAllGoodsCheckStatus
);
});
...
...
static/sass/cart/_good.scss
View file @
a167de6
...
...
@@ -63,36 +63,31 @@
}
.deps
{
margin-left
:
173rem
/
$pxConvertRem
;
padding-bottom
:
72rem
/
$pxConvertRem
;
border-bottom
:
1px
solid
#e0e0e0
;
width
:
380rem
/
$pxConvertRem
;
position
:
relative
;
min-height
:
140rem
/
$pxConvertRem
;
width
:
380rem
/
$pxConvertRem
;
height
:
5
.3rem
;
margin-left
:
4
.7rem
;
border-bottom
:
1px
solid
#e0e0e0
;
padding-top
:
0
.5rem
;
}
.name
{
font-size
:
28rem
/
$pxConvertRem
;
font-size
:
18px
;
color
:
#5a5a5a
;
width
:
80%
;
display
:
inline-block
;
}
.row
:nth-child
(
2
)
{
font-size
:
22rem
/
$pxConvertRem
;
height
:
45rem
/
$pxConvertRem
;
line-height
:
45rem
/
$pxConvertRem
;
.color-size-row
{
margin
:
0
.2rem
0
;
>
span
{
margin-right
:
15rem
/
$pxConvertRem
;
}
}
.row
:nth-child
(
3
)
{
position
:
relative
;
}
.color
,
.size
{
font-size
:
16px
;
color
:
#b6b6b6
;
}
...
...
@@ -103,7 +98,7 @@
}
.price
{
font-size
:
24rem
/
$pxConvertRem
;
font-size
:
16px
;
color
:
$cartRed
;
}
...
...
template/m.yohobuy.com/actions/cart/index/index.phtml
View file @
a167de6
...
...
@@ -25,14 +25,14 @@
{
{#if
cartNav
}
}
<ul
class=
"cart-nav clearfix"
>
<li
class=
"active"
>
<span>
普通商品(
{
{commonGoodsCount
}
})
</span>
<span>
普通商品(
{
{commonGoodsCount
}
})
</span>
</li>
<li>
<span>
预售商品(
{
{presellGoodsCount
}
})
</span>
<span>
预售商品(
{
{presellGoodsCount
}
})
</span>
</li>
</ul>
{
{/if
}
}
...
...
template/m.yohobuy.com/partials/cart/good.phtml
View file @
a167de6
...
...
@@ -25,7 +25,7 @@
<span class="count">
×{{count}}
</span>
<p class="row">
<p class="row
color-size-row
">
{{#if color}}
<span class="color">
颜色:{{color}}
...
...
@@ -50,23 +50,22 @@
</span>
{{/if}}
<span class="iconfont icon-del" data-count="{{count}}"></span>
</p>
<p class="row">
{{#if lowStocks}}
{{#if lowStocks}}
<p class="row">
<span class="low-stocks">
库存不足
</span>
{{/if}}
</p>
<p class="row">
{{#if appearDate}}
</p>
{{/if}}
{{#if appearDate}}
<p class="row">
<span class="appear-date">
上市期:{{appearDate}}
</span>
{{/if}}
</p>
</p>
{{/if}}
</div>
<div class="calculate-num hide">
<div class="calculate">
...
...
Please
register
or
login
to post a comment