Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
uedxwg
9 years ago
Commit
f82b3cb8e56d26cc0775a1bcd313cb2a9faf41e5
2 parents
586562d4
d1c3bdd4
Merge branch 'develop' of
http://git.dev.yoho.cn/web/yohobuy
into develop
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
59 additions
and
44 deletions
static/js/cart/cart.js
static/sass/cart/_chose-panel.scss
static/sass/cart/_good.scss
static/sass/cart/_index.scss
static/sass/cart/_order-ensure.scss
static/sass/cart/_select-coupon.scss
static/sass/product/_recommend-for-you.scss
template/m.yohobuy.com/partials/cart/cart-content.phtml
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
static/js/cart/cart.js
View file @
f82b3cb
...
...
@@ -5,6 +5,7 @@
*/
var
$
=
require
(
'jquery'
),
ellipsis
=
require
(
'mlellipsis'
),
Hammer
=
require
(
'yoho.hammer'
);
var
chosePanel
=
require
(
'./chose-panel'
),
...
...
@@ -13,23 +14,36 @@ var chosePanel = require('./chose-panel'),
var
$cartContent
=
$
(
'.cart-content'
),
cartType
=
$
(
'#cartType'
).
val
(),
$cartNav
=
$
(
'.cart-nav'
),
hasShowCartPresellTip
=
false
;
var
$cartContentShow
=
$cartContent
.
not
(
'.hide'
);
var
navHammer
,
advanceBuyHammer
,
freebieHammer
,
switchChose
=
false
;
require
(
'../product/recommend-for-you'
);
require
(
'./good'
);
ellipsis
.
init
();
function
cartContentShow
()
{
return
$cartContent
.
not
(
'.hide'
);
}
function
mlellipsisHiddenNames
()
{
cartContentShow
().
find
(
'.shopping-cart-good .name'
).
each
(
function
()
{
this
.
mlellipsis
(
2
);
});
switchChose
=
true
;
}
function
hasChecked
()
{
return
$cartContentShow
.
find
(
'
.icon-cb-checked'
).
length
>
0
?
true
:
false
;
return
cartContentShow
().
find
(
'.cart-goods
.icon-cb-checked'
).
length
>
0
?
true
:
false
;
}
function
shouldSelectGift
()
{
var
$freebie
=
$cartContentShow
.
find
(
'.freebie'
);
var
$freebie
=
cartContentShow
()
.
find
(
'.freebie'
);
if
(
$freebie
.
length
<=
0
)
{
return
false
;
...
...
@@ -70,16 +84,12 @@ function showChooseGifDialog() {
rightBtnText
:
'去选择'
}
},
function
()
{
window
.
location
.
href
=
$cartContentShow
.
find
(
'.freebie > a'
).
attr
(
'href'
);
window
.
location
.
href
=
cartContentShow
()
.
find
(
'.freebie > a'
).
attr
(
'href'
);
},
function
()
{
window
.
location
.
href
=
'/cart/index/orderEnsure?cartType='
+
cartType
;
});
}
require
(
'./good'
);
//lazyLoad($('img.lazy'));
if
(
typeof
window
.
cookie
===
'function'
&&
'y'
===
window
.
cookie
(
'_hasShowCartPresellTip'
))
{
$
(
'#presell-tip'
).
removeClass
(
'show'
).
addClass
(
'hide'
);
hasShowCartPresellTip
=
true
;
...
...
@@ -91,12 +101,12 @@ if ('advance' === cartType) {
$cartContent
.
toggleClass
(
'hide'
);
$
(
'#common-cart-nav'
).
removeClass
(
'active'
);
$
(
'#presell-cart-nav'
).
addClass
(
'active'
);
$
(
'.shopping-cart-good .name'
).
each
(
function
()
{
this
.
mlellipsis
(
2
);
});
mlellipsisHiddenNames
();
$
(
window
).
trigger
(
'scroll'
);
}
if
(
$
(
'.cart-nav'
)
.
length
>
0
)
{
if
(
$
cartNav
.
length
>
0
)
{
navHammer
=
new
Hammer
(
document
.
getElementsByClassName
(
'cart-nav'
)[
0
]);
navHammer
.
on
(
'tap'
,
function
(
e
)
{
var
$this
=
$
(
e
.
target
).
closest
(
'li'
);
...
...
@@ -119,13 +129,8 @@ if ($('.cart-nav').length > 0) {
//切换普通商品和预售商品购物车显示
$cartContent
.
toggleClass
(
'hide'
);
$cartContentShow
=
$cartContent
.
not
(
'.hide'
);
if
(
switchChose
===
false
)
{
$cartContentShow
.
find
(
'.shopping-cart-good .name'
).
each
(
function
()
{
this
.
mlellipsis
(
2
);
});
switchChose
=
true
;
mlellipsisHiddenNames
();
}
//trigger lazyload
...
...
@@ -176,16 +181,11 @@ $('.chose').on('touchend', function() {
chosePanel
.
show
();
});
function
notAllowScroll
()
{
var
docH
=
$
(
document
).
height
(),
winH
=
$
(
window
).
height
();
if
(
docH
-
winH
<=
10
)
{
$
(
'body'
).
css
(
'overflow'
,
'hidden'
);
}
}
notAllowScroll
();
$cartNav
.
on
(
'touchstart'
,
'li'
,
function
(
e
)
{
$
(
this
).
addClass
(
'bytouch'
);
}).
on
(
'touchend touchcancel'
,
function
()
{
$cartNav
.
find
(
'li'
).
removeClass
(
'bytouch'
);
});
//提前触发lazyload
$
(
window
).
scrollTop
(
1
).
scrollTop
(
0
);
...
...
static/sass/cart/_chose-panel.scss
View file @
f82b3cb
...
...
@@ -165,10 +165,12 @@
}
.btn-wrap
{
position
:
relative
;
height
:
120rem
/
$pxConvertRem
;
border-top
:
1px
solid
#e6e6e6
;
padding
:
20rem
/
$pxConvertRem
;
text-align
:
center
;
background
:
#fff
;
box-sizing
:
border-box
;
.btn-sure
{
...
...
static/sass/cart/_good.scss
View file @
f82b3cb
...
...
@@ -4,9 +4,9 @@
padding-left
:
16rem
/
$pxConvertRem
;
.prevent-img-click
{
position
:
absolute
;
width
:
20rem
/
$pxConvertRem
;
height
:
200rem
/
$pxConvertRem
;
position
:
absolute
;
background-color
:
transparent
;
z-index
:
99
;
}
...
...
static/sass/cart/_index.scss
View file @
f82b3cb
...
...
@@ -15,11 +15,17 @@
.cart-content
>
*
{
background
:
#fff
;
&
:first-child
{
border-top
:
none
;
margin-top
:
0
;
}
}
.cart-nav
{
color
:
#c6c6c6
;
border-bottom
:
1px
solid
#e0e0e0
;
background
:
#fff
;
li
{
float
:
left
;
...
...
static/sass/cart/_order-ensure.scss
View file @
f82b3cb
...
...
@@ -119,13 +119,13 @@
}
.coupon-use
{
box-sizing
:
border-box
;
@include
box-sizing
(
border-box
)
;
position
:
relative
;
float
:
right
;
padding-right
:
30rem
/
$pxConvertRem
;
color
:
#999
;
text-align
:
right
;
width
:
3
6
0rem
/
$pxConvertRem
;
width
:
3
2
0rem
/
$pxConvertRem
;
white-space
:
nowrap
;
text-overflow
:
ellipsis
;
overflow
:
hidden
;
...
...
@@ -137,7 +137,7 @@
color
:
#999
;
}
}
.checkbox
{
display
:
inline-block
;
width
:
80rem
/
$pxConvertRem
;
...
...
static/sass/cart/_select-coupon.scss
View file @
f82b3cb
...
...
@@ -6,6 +6,7 @@
margin-bottom
:
pxToRem
(
30px
);
padding-left
:
pxToRem
(
30px
);
padding-right
:
pxToRem
(
30px
);
font-size
:
pxToRem
(
24px
);
input
{
padding
:
0
pxToRem
(
12px
);
...
...
static/sass/product/_recommend-for-you.scss
View file @
f82b3cb
.recommend-for-you
{
padding
:
pxToRem
(
30px
)
0
pxToRem
(
1
0px
);
padding
:
pxToRem
(
30px
)
0
pxToRem
(
3
0px
);
border-top
:
1px
solid
#e0e0e0
;
border-bottom
:
1px
solid
#e0e0e0
;
background
:
#fff
;
...
...
@@ -16,7 +16,7 @@
padding
:
pxToRem
(
30px
)
0
pxToRem
(
20px
);
width
:
100%
;
height
:
pxToRem
(
252px
);
overflow
:
hidden
;
//
overflow: hidden;
.swiper-slide
{
padding
:
0
pxToRem
(
10px
);
...
...
@@ -45,11 +45,13 @@
line-height
:
1
;
.sale-price
{
display
:
block
;
color
:
#d9134f
;
margin-right
:
pxToRem
(
8px
);
}
.old-price
{
display
:
block
;
color
:
#b0b0b0
;
text-decoration
:
line-through
;
}
...
...
template/m.yohobuy.com/partials/cart/cart-content.phtml
View file @
f82b3cb
<div class="cart-goods">
{{# goods}}
{{> cart/good}}
{{/ goods}}
</div>
{
{#if
goods
}
}
<div
class=
"cart-goods"
>
{
{#
goods
}
}
{
{>
cart/good
}
}
{
{/
goods
}
}
</div>
{
{/if
}
}
{
{#if
notValidGoods
}
}
<div
class=
"invalid-goods"
>
...
...
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
View file @
f82b3cb
...
...
@@ -80,19 +80,21 @@ class CartModel
$ordinaryCount
=
strval
(
$cart
[
'ordinary_cart_data'
][
'shopping_cart_data'
][
'goods_count'
]);
$advanceCount
=
strval
(
$cart
[
'advance_cart_data'
][
'shopping_cart_data'
][
'goods_count'
]);
$ordinarySoldOut
=
empty
(
$cart
[
'ordinary_cart_data'
][
'sold_out_goods_list'
]);
$advanceSoldOut
=
empty
(
$cart
[
'advance_cart_data'
][
'sold_out_goods_list'
]);
// 普通购物车和预售购物车都为空
if
(
$ordinaryCount
===
'0'
&&
$advanceCount
===
'0'
)
{
if
(
$ordinaryCount
===
'0'
&&
$advanceCount
===
'0'
&&
$ordinarySoldOut
&&
$advanceSoldOut
)
{
$result
[
'isEmptyCart'
]
=
true
;
break
;
}
// 普通购物车空,则显示预售购物车
if
(
$ordinaryCount
===
'0'
)
{
if
(
$ordinaryCount
===
'0'
&&
$ordinaryCount
)
{
$result
[
'cartNav'
]
=
false
;
$result
[
'cartType'
]
=
'advance'
;
}
// 预售购物车空,则显示普通购物车
elseif
(
$advanceCount
===
'0'
)
{
elseif
(
$advanceCount
===
'0'
&&
$advanceSoldOut
)
{
$result
[
'cartNav'
]
=
false
;
$result
[
'cartType'
]
=
'ordinary'
;
}
...
...
@@ -734,7 +736,7 @@ class CartModel
do
{
// 数据为空时返回空的标志
if
(
empty
(
$data
[
'goods_list'
]))
{
if
(
empty
(
$data
[
'goods_list'
])
&&
empty
(
$data
[
'sold_out_goods_list'
])
)
{
break
;
}
...
...
Please
register
or
login
to post a comment