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
Zhang
8 years ago
Commit
9a764d53311be3390b7fdfbe77005b5fc9c5ec02
1 parent
0319bae6
ajax获取code
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
90 additions
and
76 deletions
apps/activity/controllers/share-buy.js
apps/activity/models/share-buy.js
apps/activity/router.js
apps/activity/views/action/share-buy/share-buy.hbs
public/js/activity/share-buy.page.js
apps/activity/controllers/share-buy.js
View file @
9a764d5
...
...
@@ -7,47 +7,25 @@ const shareBuyModel = require('../models/share-buy'),
exports
.
index
=
(
req
,
res
,
next
)
=>
{
let
activityId
=
req
.
query
.
act_id
||
2023
,
isApp
=
req
.
yoho
.
isApp
,
uid
=
req
.
user
.
uid
,
protocol
=
req
.
app
.
locals
.
isProduction
?
'https:'
:
'http:'
;
req
.
ctx
(
shareBuyModel
).
shareIndex
(
activityId
,
isApp
,
uid
,
protocol
).
then
(
indexData
=>
{
res
.
render
(
'share-buy/share-buy'
,
{
pageHeader
:
headerModel
.
setNav
({
navTitle
:
'分享购'
}),
isApp
:
isApp
,
localCss
:
true
,
width750
:
true
,
title
:
'分享购'
,
userCouponBoList
:
indexData
.
userCouponBoList
,
newsFlash
:
indexData
.
newsFlash
,
rebeatUrl
:
indexData
.
rebeatUrl
,
strategyUrl
:
indexData
.
strategyUrl
,
banner
:
indexData
.
banner
,
isStudent
:
indexData
.
isStudent
});
}).
catch
(
next
);
// co(function* () {
// let isStudent = yield req.ctx(shareBuyModel).checkStudent(uid);
// let indexData = yield req.ctx(shareBuyModel).shareIndex(activityId, isApp, uid, isStudent, protocol);
uid
=
req
.
user
.
uid
;
// res.render('share-buy/share-buy', {
// pageHeader: headerModel.setNav({
// navTitle: '分享购'
// }),
// isApp: isApp,
// localCss: true,
// width750: true,
// title: '分享购',
// userCouponBoList: indexData.userCouponBoList,
// newsFlash: indexData.newsFlash,
// rebeatUrl: indexData.rebeatUrl,
// strategyUrl: indexData.strategyUrl,
// banner: indexData.banner,
// isStudent: indexData.isStudent
// });
// })().catch(next);
req
.
ctx
(
shareBuyModel
).
shareIndex
(
activityId
,
isApp
,
uid
).
then
(
indexData
=>
{
res
.
render
(
'share-buy/share-buy'
,
{
pageHeader
:
headerModel
.
setNav
({
navTitle
:
'分享购'
}),
isApp
:
isApp
,
localCss
:
true
,
width750
:
true
,
title
:
'分享购'
,
userCouponBoList
:
indexData
.
userCouponBoList
,
newsFlash
:
indexData
.
newsFlash
,
rebeatUrl
:
indexData
.
rebeatUrl
,
strategyUrl
:
indexData
.
strategyUrl
,
banner
:
indexData
.
banner
,
isStudent
:
indexData
.
isStudent
});
}).
catch
(
next
);
};
exports
.
detail
=
(
req
,
res
,
next
)
=>
{
...
...
@@ -91,3 +69,13 @@ exports.myRebeat = (req, res, next) => {
});
}).
catch
(
next
);
};
exports
.
getCouponCode
=
(
req
,
res
,
next
)
=>
{
let
uid
=
req
.
user
.
uid
,
couponId
=
req
.
query
.
couponId
,
protocol
=
req
.
app
.
locals
.
isProduction
?
'https:'
:
'http:'
;
req
.
ctx
(
shareBuyModel
).
getCouponCode
(
uid
,
couponId
,
protocol
).
then
(
result
=>
{
res
.
json
(
result
);
})
};
...
...
apps/activity/models/share-buy.js
View file @
9a764d5
...
...
@@ -38,17 +38,17 @@ module.exports = class extends global.yoho.BaseModel {
val
.
couponDescribe
=
'指定商品可用'
;
}
val
.
detailUrl
=
helpers
.
urlFormat
(
'/activity/share-buy/detail'
,
{
couponId
:
val
.
couponId
,
couponCode
:
val
.
couponCode
});
if
(
isApp
)
{
val
.
detailUrl
=
protocol
+
val
.
detailUrl
+
'&openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"'
+
protocol
+
val
.
detailUrl
+
'","params":{"couponId":"'
+
val
.
couponId
+
'","couponCode":"'
+
val
.
couponCode
+
'"}}}'
;
}
// val.detailUrl = helpers.urlFormat('/activity/share-buy/detail', {
// couponId: val.couponId,
// couponCode: val.couponCode
// });
// if (isApp) {
// val.detailUrl = protocol + val.detailUrl +
// '&openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"' + protocol +
// val.detailUrl + '","params":{"couponId":"' + val.couponId + '","couponCode":"' +
// val.couponCode + '"}}}';
// }
});
indexData
.
userCouponBoList
=
result
[
0
].
data
.
userCouponBoList
;
...
...
@@ -102,8 +102,7 @@ module.exports = class extends global.yoho.BaseModel {
return
api
.
get
(
''
,
{
method
:
'app.activity.getActivityCouponInfo'
,
activity_id
:
activityId
,
uid
:
uid
,
isStudent
:
1
uid
:
uid
},
{
code
:
200
}).
then
((
result
)
=>
{
...
...
@@ -211,6 +210,27 @@ module.exports = class extends global.yoho.BaseModel {
// });
// }
/**
* 获取分享码
*/
getCouponCode
(
uid
,
couponId
,
protocol
)
{
return
api
.
get
(
''
,
{
method
:
'app.activity.getActivityCouponCode'
,
uid
:
uid
,
coupon_id
:
couponId
}).
then
(
result
=>
{
if
(
result
&&
result
.
code
===
200
&&
result
.
data
)
{
result
.
data
.
detailUrl
=
helpers
.
urlFormat
(
'/activity/share-buy/detail'
,
{
couponId
:
couponId
,
couponCode
:
result
.
data
.
couponCode
});
result
.
data
.
protocol
=
protocol
;
}
return
result
;
});
}
/**
* 我的返利页数据
*/
...
...
apps/activity/router.js
View file @
9a764d5
...
...
@@ -257,7 +257,7 @@ router.get('/getCoupon', birthday.getCoupon); // 获取生日卷状态
router
.
get
(
'/share-buy'
,
update
(
'5.7.0'
),
auth
,
shareBuy
.
index
);
// 分享购首页
router
.
get
(
'/share-buy/detail'
,
update
(
'5.7.0'
),
shareBuy
.
detail
);
// 分享购详情页
router
.
get
(
'/share-buy/my-rebeat'
,
update
(
'5.7.0'
),
auth
,
shareBuy
.
myRebeat
);
// 我的返利
router
.
get
(
'/share-buy/get-coupon-code'
,
auth
,
shareBuy
.
getCouponCode
);
// 获取分享购券码
router
.
get
(
'/user-recommend'
,
userRecommend
.
index
);
// 广点通投放落地页
router
.
get
(
'/user-recommend/moreGoods'
,
userRecommend
.
moreGoods
);
// 获取商品分页
...
...
apps/activity/views/action/share-buy/share-buy.hbs
View file @
9a764d5
...
...
@@ -16,12 +16,7 @@
<p
class=
"coupon-type"
>
{{
shareCouponType
}}
</p>
</div>
<div
class=
"coupon-right"
>
<a
href=
"
{{
detailUrl
}}
"
class=
"join"
>
立即参与
</a>
<!--
{{#if
detailUrl
}}
<a href="
{{
detailUrl
}}
" class="join">立即参与</a> -->
<!--
{{else}}
<span class="join">立即参与</span>
{{/if}}
-->
<span
class=
"join"
data-id=
"
{{
couponId
}}
"
>
立即参与
</span>
<p
class=
"coupon-mold"
>
{{
shareCoupon
}}
</p>
<p
class=
"coupon-limit"
>
{{
couponDescribe
}}
</p>
</div>
...
...
public/js/activity/share-buy.page.js
View file @
9a764d5
...
...
@@ -2,7 +2,8 @@
require
(
'activity/share-buy.page.css'
);
let
$
=
require
(
'yoho-jquery'
),
yoho
=
require
(
'yoho-app'
);
yoho
=
require
(
'yoho-app'
),
tip
=
require
(
'plugin/tip'
);
let
$news
=
$
(
'.news'
),
newsLiL
=
$news
.
find
(
'li'
).
length
,
...
...
@@ -56,18 +57,28 @@ if (newsLiL > 1) {
setInterval
(
Marquee
,
100
);
}
// $('.join').click(function() {
// if ($('.coupon-list').data('student') === false) {
// dialog.showDialog({
// dialogText: '完成学生认证即可参与活动哦~',
// fast: true,
// hasFooter: {
// rightBtnText: '去认证'
// }
// }, function() {
// yoho.goH5('http://m.yohobuy.com/activity/student/register', '{"action":"go.h5","params":{"islogin":"N","type":"13","url":"http://m.yohobuy.com/activity/student/register"}}');
// }, null, true);
// }
// });
$
(
'.join'
).
click
(
function
()
{
$
.
ajax
({
type
:
'GET'
,
url
:
'/activity/share-buy/get-coupon-code'
,
data
:
{
couponId
:
$
(
this
).
data
(
'id'
)
},
success
:
function
(
result
)
{
if
(
result
.
code
===
200
)
{
let
link
=
result
.
data
.
detailUrl
;
if
(
yoho
.
isApp
)
{
link
=
result
.
data
.
protocol
+
link
;
yoho
.
goH5
(
link
);
}
else
{
window
.
location
.
href
=
link
;
}
}
else
{
tip
.
show
(
result
.
message
);
}
}
});
});
...
...
Please
register
or
login
to post a comment