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
郭成尧
7 years ago
Commit
cf06710688b380e0c80bc8e0b0e668e7eedd7e03
1 parent
e4d99f90
coupon-list
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
135 additions
and
9 deletions
apps/cart/controllers/order.js
apps/home/controllers/coupon-new.js
apps/home/models/coupon-new.js
apps/home/router.js
apps/home/views/action/coupons/page.hbs
public/hbs/home/coupon-valid.hbs
public/js/cart/select-coupons/controller.js
public/js/home/coupon-new/controller.js
public/scss/home/conpon-new.page.css
apps/cart/controllers/order.js
View file @
cf06710
...
...
@@ -436,11 +436,10 @@ exports.couponList = (req, res, next) => {
let
delivery_way
=
orderInfo
.
deliveryId
||
1
;
if
(
req
.
xhr
)
{
return
req
.
ctx
(
cartModel
).
getCouponList
({
return
req
.
ctx
(
shoppingModel
).
listCoupon
({
uid
:
req
.
user
.
uid
,
delivery_way
:
delivery_way
,
is_group_frees
:
'Y'
,
// 运费券是否分组
orderInfo
:
orderInfo
is_group_frees
:
'Y'
// 运费券是否分组
}).
then
(
data
=>
{
res
.
json
(
data
);
}).
catch
(
next
);
...
...
apps/home/controllers/coupon-new.js
View file @
cf06710
const
headerModel
=
require
(
'../../../doraemon/models/header'
);
// 头部model
//
const CouponNewModel = require('../models/coupon-new');
const
CouponNewModel
=
require
(
'../models/coupon-new'
);
class
CouponNew
{
page
(
req
,
res
)
{
...
...
@@ -15,6 +15,21 @@ class CouponNew {
})
});
}
/**
* 优惠券数据
*/
coupons
(
req
,
res
,
next
)
{
req
.
ctx
(
CouponNewModel
).
couponData
({
method
:
'app.coupons.li'
,
uid
:
req
.
user
.
uid
,
status
:
parseInt
(
req
.
body
.
status
||
0
,
10
),
page
:
parseInt
(
req
.
body
.
page
||
1
,
10
),
limit
:
10
,
}).
then
(
result
=>
{
res
.
json
(
result
);
}).
catch
(
next
);
}
}
module
.
exports
=
new
CouponNew
();
...
...
apps/home/models/coupon-new.js
View file @
cf06710
const
helpers
=
global
.
yoho
.
helpers
;
class
CouponNewModel
extends
global
.
yoho
.
BaseModel
{
constructor
(
ctx
)
{
super
(
ctx
);
}
couponData
(
params
)
{
return
this
.
get
({
data
:
params
}).
then
(
result
=>
{
if
(
result
&&
result
.
data
&&
result
.
data
.
couponList
)
{
let
status0
=
params
.
status
===
0
;
let
status1
=
params
.
status
===
1
;
return
result
.
data
.
couponList
.
map
(
function
(
elem
)
{
delete
elem
.
id
;
if
(
status0
)
{
elem
.
bestowLink
=
helpers
.
urlFormat
(
'/product/index/index'
,
{
coupon_id
:
elem
.
couponId
,
coupon_code
:
elem
.
couponCode
,
title
:
'优惠活动商品'
,
intro_text
:
`以下商品可使用【
$
{
elem
.
couponDetailInfomation
}
】优惠券`
}
);
}
else
if
(
status1
)
{
delete
elem
.
overState
;
elem
.
employbg
=
true
;
}
return
elem
;
});
}
return
[];
});
}
}
...
...
apps/home/router.js
View file @
cf06710
...
...
@@ -24,7 +24,8 @@ const favorite = require(`${cRoot}/favorite`);
const
orderController
=
require
(
`
$
{
cRoot
}
/order`
)
;
const
orderDetailController
=
require
(
`
$
{
cRoot
}
/orderDetail`
)
;
const
currencyController
=
require
(
`
$
{
cRoot
}
/myCurrency`
)
;
const
coupons
=
require
(
`
$
{
cRoot
}
/coupons`
)
;
// const coupons = require(`${cRoot}/coupons`);
const
couponNew
=
require
(
`
$
{
cRoot
}
/coupon-new`
)
;
const
suggest
=
require
(
`
$
{
cRoot
}
/suggest`
)
;
const
message
=
require
(
`
$
{
cRoot
}
/message`
)
;
...
...
@@ -94,8 +95,10 @@ router.post('/favoriteDel', auth, favorite.favoriteDelete);// 取消收藏
// 优惠券
// router.use('/coupons', auth, coupons.index);
// router.use('/couponsAjax', coupons.couponsAjax);
router
.
use
(
'/coupons'
,
auth
,
couponNew
.
page
);
router
.
use
(
'/coupons
Ajax'
,
coupons
.
couponsAjax
);
router
.
use
(
'/coupons
.json'
,
couponNew
.
coupons
);
// 意见反馈
router
.
get
(
'/suggest'
,
suggest
.
suggestData
);
...
...
apps/home/views/action/coupons/page.hbs
View file @
cf06710
...
...
@@ -21,7 +21,7 @@
<input
type=
"text"
placeholder=
"请输入优惠券码"
>
<button>
兑换
</button>
</div>
<div
class=
"coupon-list"
>
<div
class=
"coupon-list"
id=
"couponList"
>
<section
class=
"coupon-section"
>
<div
class=
"coupon"
>
<div
class=
"coupon-left"
>
...
...
public/hbs/home/coupon-valid.hbs
0 → 100644
View file @
cf06710
{{#
each
.
}}
<section
class=
"coupon-section"
>
<div
class=
"coupon"
>
<div
class=
"coupon-left"
>
<p
class=
"value"
>
¥
<span>
{{
couponValue
}}
</span>
</p>
<p
class=
"threshold"
>
满
{{
shopLimit
}}
可用
</p>
</div>
<div
class=
"coupon-right"
>
<p
class=
"title"
>
<span
class=
"type-shop"
>
[店铺券]
</span>
{{
couponDetailInfomation
}}
</p>
<p
class=
"time"
>
{{
couponValidity
}}
</p>
<p>
<span
class=
"show-intro-btn"
>
使用说明
</span>
<span
class=
"iconfont icon-down show-intro-btn show-intro-arrow"
></span>
</p>
<span
class=
"tip"
></span>
</div>
<button
class=
"use-now"
>
立即使用
</button>
<span
class=
"top-tip"
></span>
</div>
<ul
class=
"coupon-intro hide"
>
{{#
notes
}}
<li>
{{
.
}}
</li>
{{/
notes
}}
</ul>
</section>
{{/
each
}}
...
...
public/js/cart/select-coupons/controller.js
View file @
cf06710
...
...
@@ -19,6 +19,21 @@ class SelectCouponController extends Page {
this
.
view
.
coupon
.
on
(
'click'
,
'.checkbox'
,
this
.
check
.
bind
(
this
));
this
.
view
.
tipClose
.
on
(
'click'
,
this
.
closeTip
.
bind
(
this
));
this
.
view
.
showFilterBtn
.
on
(
'click'
,
this
.
showFilter
.
bind
(
this
));
this
.
getCouponsData
();
}
/**
* 获取优惠券数据
*/
getCouponsData
()
{
this
.
ajax
({
type
:
'GET'
,
url
:
'/cart/index/new/couponList'
,
dataType
:
'json'
}).
then
(
result
=>
{
console
.
log
(
result
);
});
}
/**
...
...
public/js/home/coupon-new/controller.js
View file @
cf06710
import
$
from
'yoho-jquery'
;
import
Page
from
'yoho-page'
;
import
couponValidHbs
from
'home/coupon-valid.hbs'
;
class
ConponController
extends
Page
{
constructor
()
{
super
();
...
...
@@ -8,12 +10,39 @@ class ConponController extends Page {
filterBtn
:
$
(
'.filter-btn'
),
filterItem
:
$
(
'.filter-item'
),
showFilterBtn
:
$
(
'.show-filter-btn'
),
coupon
Section
:
$
(
'.coupon-section
'
)
coupon
List
:
$
(
'#couponList
'
)
};
this
.
view
.
filterBtn
.
on
(
'click'
,
this
.
tapChange
.
bind
(
this
));
this
.
view
.
showFilterBtn
.
on
(
'click'
,
this
.
showFilter
.
bind
(
this
));
this
.
view
.
couponSection
.
on
(
'click'
,
'.show-intro-btn'
,
this
.
showIntro
.
bind
(
this
));
this
.
renderCoupons
();
}
/**
* 渲染优惠券列表
*/
renderCoupons
()
{
this
.
getCoupons
().
then
(
result
=>
{
let
couponValidHbsHtml
=
$
(
couponValidHbs
(
result
));
couponValidHbsHtml
.
on
(
'click'
,
'.show-intro-btn'
,
this
.
showIntro
.
bind
(
this
));
this
.
view
.
couponList
.
html
(
couponValidHbsHtml
);
});
}
/**
* 获取优惠券
*/
getCoupons
()
{
return
this
.
ajax
({
type
:
'POST'
,
url
:
'/home/coupons.json'
,
dataType
:
'json'
,
data
:
{
status
:
0
,
page
:
1
},
});
}
/**
...
...
public/scss/home/conpon-new.page.css
View file @
cf06710
...
...
@@ -133,6 +133,9 @@ body {
font-size
:
24px
;
color
:
#444
;
margin-bottom
:
40px
;
overflow
:
hidden
;
white-space
:
nowrap
;
text-overflow
:
ellipsis
;
}
.time
{
...
...
Please
register
or
login
to post a comment