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
毕凯
9 years ago
Commit
e6652be8f6a382925cd048179ce75a54604cb6a1
1 parent
91f6a398
使用优惠券列表 优化选择
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
34 deletions
static/js/cart/select-coupon.js
static/js/cart/select-coupon.js
View file @
e6652be
...
...
@@ -6,6 +6,7 @@
var
$
=
require
(
'jquery'
),
Handlebars
=
require
(
'yoho.handlebars'
),
Hammer
=
require
(
'yoho.hammer'
),
ellipsis
=
require
(
'mlellipsis'
),
loading
=
require
(
'../plugin/loading'
),
tip
=
require
(
'../plugin/tip'
),
...
...
@@ -17,14 +18,13 @@ var page = 1,
var
conponTmpl
=
Handlebars
.
compile
(
$
(
'#tmpl-coupon'
).
html
()),
conponNotAvaliableTmpl
=
Handlebars
.
compile
(
$
(
'#tmpl-coupon-not-avaliable'
).
html
()),
$newCoupon
=
$
(
'#new-coupon'
);
$newCoupon
=
$
(
'#new-coupon'
),
$couponList
=
$
(
'#coupon-list'
);
var
winH
=
$
(
window
).
height
();
require
(
'../common'
);
// conponNotAvaliableTmpl = Handlebars.compile($('#tmpl-coupon-not-avaliable').html()),
function
fixedLayOut
()
{
var
$null
=
$
(
'.null'
),
navH
=
$
(
'.nav-title'
).
height
(),
...
...
@@ -53,13 +53,14 @@ $newCoupon.on('submit', function() {
url
:
'/cart/index/couponSearch'
,
data
:
$this
.
serialize
()
}).
then
(
function
(
res
)
{
if
(
res
.
message
)
{
tip
.
show
(
res
.
message
);
}
if
(
res
.
code
===
200
)
{
tip
.
show
(
'优惠券可用'
);
orderInfo
(
'couponCode'
,
res
.
data
.
coupon_code
);
orderInfo
(
'couponName'
,
res
.
data
.
coupon_title
);
window
.
location
.
href
=
'/cart/index/orderEnsure'
;
}
else
{
tip
.
show
(
res
.
message
||
'网络错误'
);
}
}).
fail
(
function
()
{
tip
.
show
(
'网络错误'
);
...
...
@@ -67,30 +68,7 @@ $newCoupon.on('submit', function() {
return
false
;
});
$
(
'#coupon-list'
).
on
(
'click'
,
'.employ-main'
,
function
()
{
var
$this
=
$
(
this
);
var
couponCode
=
$this
.
data
(
'coupon-code'
);
$
.
ajax
({
method
:
'POST'
,
url
:
'/cart/index/couponSearch'
,
data
:
{
couponCode
:
couponCode
}
}).
then
(
function
(
res
)
{
if
(
res
.
code
===
200
)
{
//tip.show('优惠券可用');
orderInfo
(
'couponCode'
,
res
.
data
.
coupon_code
);
orderInfo
(
'couponName'
,
res
.
data
.
coupon_title
);
window
.
location
.
href
=
'/cart/index/orderEnsure'
;
}
else
{
tip
.
show
(
res
.
message
||
'网络错误'
);
}
}).
fail
(
function
()
{
tip
.
show
(
'网络错误'
);
});
}).
on
(
'touchstart'
,
'.employ-main'
,
function
()
{
$couponList
.
on
(
'touchstart'
,
'.employ-main'
,
function
()
{
var
$this
=
$
(
this
);
$this
.
siblings
().
removeClass
(
'focus'
);
...
...
@@ -164,10 +142,37 @@ function getCouponHandle(coupons) {
}
});
$
(
'#coupon-list'
)
.
append
(
conponTmpl
({
$
couponList
.
append
(
conponTmpl
({
coupons
:
coupons
}));
})).
find
(
'.employ-main'
).
each
(
function
(
i
,
elem
)
{
var
employHammer
=
new
Hammer
(
elem
);
employHammer
.
on
(
'tap'
,
function
(
e
)
{
var
$this
=
$
(
e
.
srcEvent
.
currentTarget
);
var
couponCode
=
$this
.
data
(
'coupon-code'
);
$
.
ajax
({
method
:
'POST'
,
url
:
'/cart/index/couponSearch'
,
data
:
{
couponCode
:
couponCode
}
}).
then
(
function
(
res
)
{
if
(
res
.
message
)
{
tip
.
show
(
res
.
message
);
}
if
(
res
.
code
===
200
)
{
//tip.show('优惠券可用');
orderInfo
(
'couponCode'
,
res
.
data
.
coupon_code
);
orderInfo
(
'couponName'
,
res
.
data
.
coupon_title
);
window
.
location
.
href
=
'/cart/index/orderEnsure'
;
}
}).
fail
(
function
()
{
tip
.
show
(
'网络错误'
);
});
});
});
if
(
notAvailableCoupons
.
length
)
{
$
(
'.not-avaliable-coupon-line'
).
show
();
...
...
@@ -201,14 +206,14 @@ function getCouponDate() {
}
}).
then
(
getCouponHandle
).
fail
(
function
()
{
page
-=
1
;
tip
.
show
(
'加载优惠券失败'
);
// tip.show('加载优惠券失败');
}).
always
(
function
()
{
isGetData
=
false
;
loading
.
hideLoadingMask
();
});
}
getCouponDate
();
// $(window).scroll(function() {
...
...
Please
register
or
login
to post a comment