Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuywap-node
·
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
郭成尧
8 years ago
Commit
082247189edf5d12a729c4a656ba039e8e75d3f2
1 parent
63214309
useCouponCode-goback
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
55 deletions
apps/cart/controllers/order.js
apps/cart/models/cart.js
apps/cart/router.js
apps/cart/views/action/select-coupon.hbs
public/js/cart/select-coupon.page.js
apps/cart/controllers/order.js
View file @
0822471
...
...
@@ -301,13 +301,13 @@ exports.couponList = (req, res, next) => {
/**
* 购物车输入优惠券码使用优惠券
*/
exports
.
couponSearch
=
(
req
,
res
,
next
)
=>
{
exports
.
useCouponCode
=
(
req
,
res
,
next
)
=>
{
let
couponCode
=
req
.
body
.
couponCode
||
''
;
let
uid
=
req
.
user
.
uid
;
co
(
function
*
()
{
if
(
req
.
xhr
)
{
let
result
=
yield
cartModel
.
searchCoupon
(
uid
,
couponCode
);
let
result
=
yield
cartModel
.
useCouponCode
(
uid
,
couponCode
);
res
.
json
(
result
);
}
else
{
...
...
apps/cart/models/cart.js
View file @
0822471
...
...
@@ -276,7 +276,7 @@ exports.getCouponList = uid => {
);
};
exports
.
searchCoupon
=
(
uid
,
couponCode
)
=>
{
exports
.
useCouponCode
=
(
uid
,
couponCode
)
=>
{
let
result
=
{
code
:
400
,
message
:
'出错啦~'
};
if
(
!
couponCode
)
{
...
...
apps/cart/router.js
View file @
0822471
...
...
@@ -38,7 +38,7 @@ router.post('/index/new/orderCompute', authMW, order.orderCompute); // 结算页
router
.
post
(
'/index/new/orderSub'
,
authMW
,
order
.
orderSub
);
// 订单提交
router
.
get
(
'/index/new/selectCoupon'
,
authMW
,
order
.
selectCoupon
);
// 选择优惠券 页面
router
.
get
(
'/index/new/couponList'
,
order
.
couponList
);
// [ajax]获取优惠券列表
router
.
post
(
'/index/new/
couponSearch'
,
order
.
couponSearch
);
// [ajax]购物车输入优惠券码使用优惠券
router
.
post
(
'/index/new/
useCouponCode'
,
order
.
useCouponCode
);
// [ajax]购物车输入优惠券码使用优惠券
router
.
get
(
'/index/new/selectAddress'
,
authMW
,
order
.
selectAddress
);
// 选择地址
router
.
get
(
'/index/new/invoiceInfo'
,
authMW
,
order
.
invoiceInfo
);
// 发票信息
router
.
get
(
'/index/new/jitDetail'
,
authMW
,
order
.
jitDetail
);
// JIT 拆单配送信息
...
...
apps/cart/views/action/select-coupon.hbs
View file @
0822471
...
...
@@ -24,8 +24,8 @@
<div
id=
"couponUnavailable"
class=
"coupon-list"
></div>
</div>
<div
class=
"use-coupon-btn-group"
>
<button
class=
"pull-left use"
>
使用
</button>
<button
class=
"pull-right not-use"
>
不使用
</button>
<button
id=
"useCoupon"
class=
"pull-left use"
>
使用
</button>
<button
id=
"notUseCoupon"
class=
"pull-right not-use"
>
不使用
</button>
</div>
</div>
<script
id=
"tmpl-no-coupon"
type=
"text/tmpl"
>
...
...
public/js/cart/select-coupon.page.js
View file @
0822471
...
...
@@ -19,6 +19,8 @@ let isGetData;
let
$newCoupon
=
$
(
'#new-coupon'
),
linkUrl
=
document
.
referrer
,
$couponList
=
$
(
'#couponAvailable'
);
let
$useCoupon
=
$
(
'#useCoupon'
);
let
$notUseCoupon
=
$
(
'#notUseCoupon'
);
let
winH
=
$
(
window
).
height
();
...
...
@@ -49,6 +51,9 @@ function goToBack() {
}
}
/**
* 输入优惠券码兑换优惠券
*/
$newCoupon
.
on
(
'submit'
,
function
()
{
let
$this
=
$
(
this
);
...
...
@@ -58,7 +63,7 @@ $newCoupon.on('submit', function() {
}
$
.
ajax
({
method
:
'POST'
,
url
:
'/cart/index/new/
couponSearch
'
,
url
:
'/cart/index/new/
useCouponCode
'
,
data
:
$this
.
serialize
()
}).
then
(
function
(
res
)
{
if
(
res
.
message
)
{
...
...
@@ -66,12 +71,9 @@ $newCoupon.on('submit', function() {
}
if
(
res
.
code
===
200
)
{
tip
.
show
(
'优惠券可用'
);
// 实付金额发生变化,使用有货币为0
orderInfo
(
'yohoCoin'
,
0
);
orderInfo
(
'couponCode'
,
res
.
data
.
coupon_code
);
orderInfo
(
'couponName'
,
res
.
data
.
coupon_title
);
goToBack
();
setTimeout
(
function
()
{
location
.
reload
();
},
500
);
}
}).
fail
(
function
()
{
tip
.
show
(
'网络错误'
);
...
...
@@ -79,34 +81,20 @@ $newCoupon.on('submit', function() {
return
false
;
});
$couponList
.
on
(
'touchstart'
,
'.employ-main'
,
function
()
{
let
$this
=
$
(
this
);
$this
.
siblings
().
removeClass
(
'focus'
);
$this
.
addClass
(
'focus'
);
}).
on
(
'touchend touchcancel'
,
'.employ-main'
,
function
()
{
let
$this
=
$
(
this
);
$this
.
siblings
().
removeClass
(
'focus'
);
$this
.
removeClass
(
'focus'
);
});
$
(
'body'
).
on
(
'touchend'
,
'.not-use'
,
function
()
{
orderInfo
(
'couponCode'
,
null
);
orderInfo
(
'couponName'
,
null
);
// 实付金额发生变化,使用有货币为0
orderInfo
(
'yohoCoin'
,
0
);
/**
* 使用优惠券 TODO
*/
$useCoupon
.
on
(
'click'
,
function
()
{
orderInfo
(
'coupon_code'
);
goToBack
();
});
$newCoupon
.
find
(
'input'
).
on
(
'input'
,
function
()
{
if
(
$
(
this
).
val
()
!==
''
)
{
$newCoupon
.
find
(
'.submit'
).
css
(
'background'
,
'#444'
);
}
else
{
$newCoupon
.
find
(
'.submit'
).
css
(
'background'
,
'#b0b0b0'
);
}
/**
* 不使用优惠券 TODO
*/
$notUseCoupon
.
on
(
'click'
,
function
()
{
orderInfo
(
'coupon_code'
,
null
);
goToBack
();
});
function
getCouponHandle
(
allCoupons
)
{
...
...
@@ -141,20 +129,13 @@ function getCouponHandle(allCoupons) {
$
.
ajax
({
method
:
'POST'
,
url
:
'/cart/index/new/
couponSearch
'
,
url
:
'/cart/index/new/
useCouponCode
'
,
data
:
{
couponCode
:
couponCode
}
}).
then
(
function
(
res
)
{
if
(
res
.
code
===
200
)
{
// tip.show('优惠券可用');
orderInfo
(
'couponCode'
,
res
.
data
.
coupon_code
);
orderInfo
(
'couponName'
,
res
.
data
.
coupon_title
);
// 实付金额发生变化,使用有货币为0
orderInfo
(
'yohoCoin'
,
0
);
goToBack
();
tip
.
show
(
'这边逻辑要改!'
);
}
else
if
(
res
.
message
)
{
tip
.
show
(
res
.
message
);
}
...
...
@@ -169,8 +150,6 @@ function getCouponHandle(allCoupons) {
$
(
'#couponUnavailable'
).
append
(
conponNotAvaliableTmpl
({
notAvailableCoupons
:
notAvailableCoupons
}));
window
.
rePosFooter
();
}
function
getCouponDate
()
{
...
...
@@ -196,9 +175,3 @@ function getCouponDate() {
}
getCouponDate
();
// $(window).scroll(function() {
// if ($(window).scrollTop() + $(window).height() > $('body').height() * 0.9) {
// getCouponDate();
// }
// });
...
...
Please
register
or
login
to post a comment