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
354e889f72d753f3fc757a1ec4e3c3be19b1350e
2 parents
c2de345f
8d6278f0
Merge branch 'develop' of
http://git.dev.yoho.cn/web/yohobuy
into develop
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
82 additions
and
22 deletions
static/js/cart/cart.js
static/js/cart/good.js
static/js/cart/order-ensure.js
static/js/common.js
static/js/index/footer.js
static/js/me/dialog.js
template/m.yohobuy.com/actions/cart/index/index.phtml
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
static/js/cart/cart.js
View file @
354e889
...
...
@@ -9,6 +9,7 @@ var $ = require('jquery'),
Hammer
=
require
(
'yoho.hammer'
);
var
chosePanel
=
require
(
'./chose-panel'
),
dialog
=
require
(
'../me/dialog'
),
tip
=
require
(
'../plugin/tip'
);
var
$cartContent
=
$
(
'.cart-content'
);
...
...
@@ -20,12 +21,56 @@ var navHammer,
var
hasChecked
=
$
(
'.cart-content:not(.hide) .icon-cb-checked'
).
length
>
0
?
true
:
false
;
//是否有选中商品
function
shouldSelectGift
()
{
var
$freebie
=
$
(
'.freebie'
);
if
(
$freebie
.
length
<=
0
)
{
return
false
;
}
return
true
;
}
function
shouldLowStocks
()
{
var
$lowStocks
=
$
(
'.low-stocks'
),
result
=
false
;
if
(
$lowStocks
.
length
<=
0
)
{
return
result
;
}
$lowStocks
.
each
(
function
(
idx
,
item
)
{
if
(
$
(
item
).
parent
().
parent
().
parent
().
siblings
(
'.checkbox'
).
hasClass
(
'icon-cb-checked'
))
{
result
=
true
;
return
false
;
}
});
return
result
;
}
function
showChooseGifDialog
()
{
dialog
.
showDialog
({
dialogText
:
'您还未选择赠品,是否去选择赠品'
,
hasFooter
:
{
leftBtnText
:
'我不要赠品'
,
rightBtnText
:
'去选择'
}
},
function
()
{
window
.
location
.
href
=
$
(
'.freebie'
).
find
(
'a'
).
attr
(
'href'
);
},
function
()
{
window
.
location
.
href
=
'/cart/index/orderEnsure?cartType='
+
cartType
;
});
}
require
(
'./good'
);
lazyLoad
(
$
(
'img.lazy'
));
if
(
'advance'
===
cartType
)
{
$cartContent
.
toggleClass
(
'hide'
);
$
(
'presell-cart-nav'
).
addClass
(
'active'
);
$
(
'common-cart-nav'
).
removeClass
(
'active'
);
}
if
(
$
(
'.cart-nav'
).
length
>
0
)
{
...
...
@@ -39,8 +84,10 @@ if ($('.cart-nav').length > 0) {
if
(
cartType
===
'ordinary'
)
{
cartType
=
'advance'
;
$
(
'#cartType'
).
val
(
'advance'
);
}
else
{
cartType
=
'ordinary'
;
$
(
'#cartType'
).
val
(
'ordinary'
);
}
$this
.
siblings
(
'.active'
).
removeClass
(
'active'
);
...
...
@@ -83,7 +130,11 @@ if ($('.freebie').length > 0) {
//});
$
(
'.btn-balance'
).
on
(
'touchend'
,
function
()
{
if
(
$
(
'.low-stocks'
).
length
>
0
)
{
if
(
shouldSelectGift
())
{
showChooseGifDialog
();
return
false
;
}
if
(
shouldLowStocks
())
{
tip
.
show
(
'库存不足无法结算'
);
return
false
;
}
...
...
@@ -99,7 +150,7 @@ $('.chose').on('touchend', function() {
chosePanel
.
show
();
});
if
(
$
(
'.
cart-zero'
).
length
>
0
)
{
if
(
$
(
'.
shopping-cart-good'
).
length
<=
0
)
{
require
(
'../product/recommend-for-you'
);
}
...
...
static/js/cart/good.js
View file @
354e889
...
...
@@ -14,7 +14,6 @@ var dialog = require('../me/dialog'),
orderInfo
=
require
(
'./order-info'
).
orderInfo
;
var
$selectAllBtn
=
$
(
'.balance .checkbox'
),
cartType
=
$
(
'#cartType'
).
val
(),
requesting
=
false
;
ellipsis
.
init
();
...
...
@@ -43,7 +42,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
var
goodsList
=
[],
goodInfo
=
{};
goodInfo
.
goods_type
=
cartType
;
goodInfo
.
goods_type
=
$
(
'#cartType'
).
val
()
;
goodInfo
.
selected
=
$this
.
hasClass
(
'icon-cb-checked'
)
?
'N'
:
'Y'
;
goodInfo
.
product_sku
=
id
;
goodInfo
.
buy_number
=
$good
.
find
(
'.count'
).
eq
(
0
).
text
().
trim
().
replace
(
'×'
,
''
);
...
...
@@ -62,7 +61,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
}
else
{
$this
.
removeClass
(
'icon-checkbox'
).
addClass
(
'icon-cb-checked'
);
}
window
.
history
.
go
(
0
);
window
.
location
.
href
=
'/cart/index/index?cartType='
+
$
(
'#cartType'
).
val
(
);
}
else
if
(
data
.
code
===
400
)
{
tip
.
show
(
'网络异常'
);
}
...
...
@@ -186,7 +185,7 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) {
//全选按钮点击事件
$selectAllBtn
.
on
(
'touchend'
,
function
()
{
bottomCheckBoxHandeler
(
$
(
this
).
hasClass
(
'icon-cb-checked'
),
cartType
,
didUpdateAllGoodsCheckStatus
);
bottomCheckBoxHandeler
(
$
(
this
).
hasClass
(
'icon-cb-checked'
),
$
(
'#cartType'
).
val
()
,
didUpdateAllGoodsCheckStatus
);
});
$
(
'.down'
).
on
(
'touchend'
,
function
()
{
...
...
static/js/cart/order-ensure.js
View file @
354e889
...
...
@@ -97,12 +97,6 @@ function orderCompute() {
if
(
$
.
type
(
res
)
!==
'object'
)
{
window
.
location
.
reload
();
}
else
{
/*if (res.order_amount) {
res.order_amount = (+res.order_amount).toFixed(2);
}
if (res.discount_amount) {
res.discount_amount = (+res.discount_amount).toFixed(2);
}*/
if
(
res
.
last_order_amount
)
{
res
.
last_order_amount
=
(
+
res
.
last_order_amount
).
toFixed
(
2
);
}
...
...
@@ -128,6 +122,10 @@ function submitOrder() {
var
invoiceText
=
$invoice
.
find
(
'[name="invoice-title"]'
).
val
()
||
orderInfo
(
'invoiceText'
),
msg
=
$
(
'#msg'
).
find
(
'input'
).
val
()
||
orderInfo
(
'msg'
);
if
(
orderInfo
(
'deliveryId'
)
===
2
&&
!
$addressWrap
.
data
(
'support'
))
{
tip
.
show
(
'当前地址不支持顺丰快递'
);
return
;
}
if
(
isSubmiting
)
{
return
false
;
}
...
...
static/js/common.js
View file @
354e889
...
...
@@ -3,7 +3,8 @@
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/21
*/
var
$
=
require
(
'jquery'
);
var
$
=
require
(
'jquery'
),
Hammer
=
require
(
'yoho.hammer'
);
var
$footer
=
$
(
'#yoho-footer'
),
$yohoPage
=
$
(
'.yoho-page'
),
...
...
@@ -131,6 +132,8 @@ function reMarginFooter(fixedElement) {
var
user
=
getUser
();
var
backToTopHammer
;
rePosFooter
();
//计算底部位置
if
(
user
===
0
)
{
...
...
@@ -151,10 +154,15 @@ function reMarginFooter(fixedElement) {
);
}
$op
.
find
(
'.back-to-top'
).
on
(
'touchend'
,
function
()
{
$
(
window
).
scrollTop
(
0
);
return
false
;
});
if
(
$op
.
find
(
'.back-to-top'
).
length
>
0
)
{
backToTopHammer
=
new
Hammer
(
$op
.
find
(
'.back-to-top'
)[
0
]);
backToTopHammer
.
on
(
'tap'
,
function
(
e
)
{
$
(
window
).
scrollTop
(
0
);
e
.
srcEvent
.
preventDefault
();
return
false
;
});
}
$footer
.
removeClass
(
'hide'
);
}());
...
...
static/js/index/footer.js
View file @
354e889
...
...
@@ -15,7 +15,7 @@ function downLoadApp() {
var
appUrl
=
'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445'
;
var
clickedAt
=
new
Date
();
setTimeout
(
function
()
{
setTimeout
(
function
()
{
if
((
new
Date
())
-
clickedAt
<
2000
)
{
window
.
location
=
appUrl
;
}
...
...
static/js/me/dialog.js
View file @
354e889
...
...
@@ -33,7 +33,7 @@ dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' +
dialogTemplate
=
Handlebars
.
compile
(
dialogTpl
);
exports
.
showDialog
=
function
(
data
,
callback
)
{
exports
.
showDialog
=
function
(
data
,
callback
,
callbackForLeft
)
{
var
dialogStr
=
dialogTemplate
(
data
),
$dialogBox
,
...
...
@@ -76,6 +76,9 @@ exports.showDialog = function(data, callback) {
dialogWrapperHammer
.
on
(
'tap'
,
function
(
event
)
{
if
(
$
(
event
.
target
).
hasClass
(
'dialog-left-btn'
))
{
if
(
typeof
callbackForLeft
===
'function'
)
{
callbackForLeft
();
}
$dialogWrapper
.
fadeOut
();
}
else
if
(
$
(
event
.
target
).
hasClass
(
'dialog-right-btn'
))
{
callback
();
...
...
template/m.yohobuy.com/actions/cart/index/index.phtml
View file @
354e889
...
...
@@ -20,12 +20,12 @@
{
{#if
cartNav
}
}
<ul
class=
"cart-nav clearfix"
>
<li
class=
"active"
>
<span>
<span
id=
"common-cart-nav"
>
普通商品(
{
{commonGoodsCount
}
})
</span>
</li>
<li>
<span>
<span
id=
"presell-cart-nav"
>
预售商品(
{
{presellGoodsCount
}
})
</span>
<div
id=
"presell-tip"
class=
"presell-tip"
>
...
...
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
View file @
354e889
...
...
@@ -346,7 +346,8 @@ class CartModel
$result
[
'phoneNum'
]
=
isset
(
$address
[
'mobile'
])
?
$address
[
'mobile'
]
:
$payReturn
[
'delivery_address'
][
'mobile'
];
$result
[
'area'
]
=
isset
(
$address
[
'area'
])
?
$address
[
'area'
]
:
$payReturn
[
'delivery_address'
][
'area'
];
$result
[
'address'
]
=
isset
(
$address
[
'address'
])
?
$address
[
'address'
]
:
$payReturn
[
'delivery_address'
][
'address'
];
$result
[
'isSupport'
]
=
(
$payReturn
[
'delivery_address'
][
'is_support'
]
===
'Y'
);
$isSupport
=
isset
(
$address
[
'is_support'
])
?
$address
[
'is_support'
]
:
$payReturn
[
'delivery_address'
][
'is_support'
];
$result
[
'isSupport'
]
=
$isSupport
===
'Y'
;
}
// 配送方式
...
...
Please
register
or
login
to post a comment