Merge remote-tracking branch 'origin/feature/shareBuy3'
Showing
7 changed files
with
58 additions
and
64 deletions
@@ -7,13 +7,9 @@ const shareBuyModel = require('../models/share-buy'), | @@ -7,13 +7,9 @@ const shareBuyModel = require('../models/share-buy'), | ||
7 | exports.index = (req, res, next) => { | 7 | exports.index = (req, res, next) => { |
8 | let activityId = req.query.act_id || 2023, | 8 | let activityId = req.query.act_id || 2023, |
9 | isApp = req.yoho.isApp, | 9 | isApp = req.yoho.isApp, |
10 | - uid = req.user.uid, | ||
11 | - protocol = req.app.locals.isProduction ? 'https:' : 'http:'; | ||
12 | - | ||
13 | - co(function* () { | ||
14 | - let isStudent = yield req.ctx(shareBuyModel).checkStudent(uid); | ||
15 | - let indexData = yield req.ctx(shareBuyModel).shareIndex(activityId, isApp, uid, isStudent, protocol); | 10 | + uid = req.user.uid; |
16 | 11 | ||
12 | + req.ctx(shareBuyModel).shareIndex(activityId, isApp, uid).then(indexData => { | ||
17 | res.render('share-buy/share-buy', { | 13 | res.render('share-buy/share-buy', { |
18 | pageHeader: headerModel.setNav({ | 14 | pageHeader: headerModel.setNav({ |
19 | navTitle: '分享购' | 15 | navTitle: '分享购' |
@@ -29,7 +25,7 @@ exports.index = (req, res, next) => { | @@ -29,7 +25,7 @@ exports.index = (req, res, next) => { | ||
29 | banner: indexData.banner, | 25 | banner: indexData.banner, |
30 | isStudent: indexData.isStudent | 26 | isStudent: indexData.isStudent |
31 | }); | 27 | }); |
32 | - })().catch(next); | 28 | + }).catch(next); |
33 | }; | 29 | }; |
34 | 30 | ||
35 | exports.detail = (req, res, next) => { | 31 | exports.detail = (req, res, next) => { |
@@ -73,3 +69,13 @@ exports.myRebeat = (req, res, next) => { | @@ -73,3 +69,13 @@ exports.myRebeat = (req, res, next) => { | ||
73 | }); | 69 | }); |
74 | }).catch(next); | 70 | }).catch(next); |
75 | }; | 71 | }; |
72 | + | ||
73 | +exports.getCouponCode = (req, res, next) => { | ||
74 | + let uid = req.user.uid, | ||
75 | + couponId = req.query.couponId, | ||
76 | + protocol = req.app.locals.isProduction ? 'https:' : 'http:'; | ||
77 | + | ||
78 | + req.ctx(shareBuyModel).getCouponCode(uid, couponId, protocol).then(result => { | ||
79 | + res.json(result); | ||
80 | + }) | ||
81 | +}; |
@@ -11,9 +11,9 @@ module.exports = class extends global.yoho.BaseModel { | @@ -11,9 +11,9 @@ module.exports = class extends global.yoho.BaseModel { | ||
11 | /** | 11 | /** |
12 | * 首页数据 | 12 | * 首页数据 |
13 | */ | 13 | */ |
14 | - shareIndex(activityId, isApp, uid, isStudent, protocol) { | 14 | + shareIndex(activityId, isApp, uid) { |
15 | 15 | ||
16 | - return api.all([this._CouponInfo(activityId, uid, isStudent), this._redeatList(), | 16 | + return api.all([this._CouponInfo(activityId, uid), this._redeatList(), |
17 | this._banner()]).then(result => { | 17 | this._banner()]).then(result => { |
18 | 18 | ||
19 | const indexData = { | 19 | const indexData = { |
@@ -23,8 +23,6 @@ module.exports = class extends global.yoho.BaseModel { | @@ -23,8 +23,6 @@ module.exports = class extends global.yoho.BaseModel { | ||
23 | const rebeatUrl = '//m.yohobuy.com/activity/share-buy/my-rebeat', | 23 | const rebeatUrl = '//m.yohobuy.com/activity/share-buy/my-rebeat', |
24 | strategyUrl = 'http://activity.yoho.cn/feature/115.html?share_id=2023&title=分享购攻略'; | 24 | strategyUrl = 'http://activity.yoho.cn/feature/115.html?share_id=2023&title=分享购攻略'; |
25 | 25 | ||
26 | - indexData.isStudent = isStudent; | ||
27 | - | ||
28 | if (result[0] && result[0].data && result[0].data.userCouponBoList) { | 26 | if (result[0] && result[0].data && result[0].data.userCouponBoList) { |
29 | _.forEach(result[0].data.userCouponBoList, function(val) { | 27 | _.forEach(result[0].data.userCouponBoList, function(val) { |
30 | 28 | ||
@@ -39,22 +37,6 @@ module.exports = class extends global.yoho.BaseModel { | @@ -39,22 +37,6 @@ module.exports = class extends global.yoho.BaseModel { | ||
39 | } else if (val.shareCoupon === '商品券') { | 37 | } else if (val.shareCoupon === '商品券') { |
40 | val.couponDescribe = '指定商品可用'; | 38 | val.couponDescribe = '指定商品可用'; |
41 | } | 39 | } |
42 | - | ||
43 | - val.detailUrl = helpers.urlFormat('/activity/share-buy/detail', { | ||
44 | - couponId: val.couponId, | ||
45 | - couponCode: val.couponCode | ||
46 | - }); | ||
47 | - | ||
48 | - if (isApp) { | ||
49 | - val.detailUrl = protocol + val.detailUrl + | ||
50 | - '&openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"' + protocol + | ||
51 | - val.detailUrl + '","params":{"couponId":"' + val.couponId + '","couponCode":"' + | ||
52 | - val.couponCode + '"}}}'; | ||
53 | - } | ||
54 | - | ||
55 | - if (!indexData.isStudent) { | ||
56 | - val.detailUrl = ''; | ||
57 | - } | ||
58 | }); | 40 | }); |
59 | 41 | ||
60 | indexData.userCouponBoList = result[0].data.userCouponBoList; | 42 | indexData.userCouponBoList = result[0].data.userCouponBoList; |
@@ -104,12 +86,11 @@ module.exports = class extends global.yoho.BaseModel { | @@ -104,12 +86,11 @@ module.exports = class extends global.yoho.BaseModel { | ||
104 | /** | 86 | /** |
105 | * 首页获取优惠券信息 | 87 | * 首页获取优惠券信息 |
106 | */ | 88 | */ |
107 | - _CouponInfo(activityId, uid, isStudent) { | 89 | + _CouponInfo(activityId, uid) { |
108 | return api.get('', { | 90 | return api.get('', { |
109 | method: 'app.activity.getActivityCouponInfo', | 91 | method: 'app.activity.getActivityCouponInfo', |
110 | activity_id: activityId, | 92 | activity_id: activityId, |
111 | - uid: uid, | ||
112 | - isStudent: isStudent | 93 | + uid: uid |
113 | }, { | 94 | }, { |
114 | code: 200 | 95 | code: 200 |
115 | }).then((result) => { | 96 | }).then((result) => { |
@@ -197,23 +178,24 @@ module.exports = class extends global.yoho.BaseModel { | @@ -197,23 +178,24 @@ module.exports = class extends global.yoho.BaseModel { | ||
197 | }); | 178 | }); |
198 | } | 179 | } |
199 | 180 | ||
200 | - /** | ||
201 | - * 判断是不是学生 | 181 | + /** |
182 | + * 获取分享码 | ||
202 | */ | 183 | */ |
203 | - checkStudent(uid) { | 184 | + getCouponCode(uid, couponId, protocol) { |
204 | return api.get('', { | 185 | return api.get('', { |
205 | - method: 'app.student.checkIsStudent', | ||
206 | - uid: uid | 186 | + method: 'app.activity.getActivityCouponCode', |
187 | + uid: uid, | ||
188 | + coupon_id: couponId | ||
207 | }).then(result => { | 189 | }).then(result => { |
208 | - | ||
209 | - let isStudent; | ||
210 | - | ||
211 | - if (result && result.data && result.code === 200) { | ||
212 | - isStudent = parseInt(result.data.isStudent, 10) === 1 ? true : false; | 190 | + if (result && result.code === 200 && result.data) { |
191 | + result.data.detailUrl = helpers.urlFormat('/activity/share-buy/detail', { | ||
192 | + couponId: couponId, | ||
193 | + couponCode: result.data.couponCode | ||
194 | + }); | ||
195 | + result.data.protocol = protocol; | ||
213 | } | 196 | } |
214 | 197 | ||
215 | - return isStudent; | ||
216 | - | 198 | + return result; |
217 | }); | 199 | }); |
218 | } | 200 | } |
219 | 201 |
@@ -257,7 +257,7 @@ router.get('/getCoupon', birthday.getCoupon); // 获取生日卷状态 | @@ -257,7 +257,7 @@ router.get('/getCoupon', birthday.getCoupon); // 获取生日卷状态 | ||
257 | router.get('/share-buy', update('5.7.0'), auth, shareBuy.index); // 分享购首页 | 257 | router.get('/share-buy', update('5.7.0'), auth, shareBuy.index); // 分享购首页 |
258 | router.get('/share-buy/detail', update('5.7.0'), shareBuy.detail); // 分享购详情页 | 258 | router.get('/share-buy/detail', update('5.7.0'), shareBuy.detail); // 分享购详情页 |
259 | router.get('/share-buy/my-rebeat', update('5.7.0'), auth, shareBuy.myRebeat); // 我的返利 | 259 | router.get('/share-buy/my-rebeat', update('5.7.0'), auth, shareBuy.myRebeat); // 我的返利 |
260 | - | 260 | +router.get('/share-buy/get-coupon-code', auth, shareBuy.getCouponCode); // 获取分享购券码 |
261 | 261 | ||
262 | router.get('/user-recommend', userRecommend.index); // 广点通投放落地页 | 262 | router.get('/user-recommend', userRecommend.index); // 广点通投放落地页 |
263 | router.get('/user-recommend/moreGoods', userRecommend.moreGoods); // 获取商品分页 | 263 | router.get('/user-recommend/moreGoods', userRecommend.moreGoods); // 获取商品分页 |
@@ -16,11 +16,7 @@ | @@ -16,11 +16,7 @@ | ||
16 | <p class="coupon-type">{{shareCouponType}}</p> | 16 | <p class="coupon-type">{{shareCouponType}}</p> |
17 | </div> | 17 | </div> |
18 | <div class="coupon-right"> | 18 | <div class="coupon-right"> |
19 | - {{#if detailUrl}} | ||
20 | - <a href="{{detailUrl}}" class="join">立即参与</a> | ||
21 | - {{else}} | ||
22 | - <span class="join">立即参与</span> | ||
23 | - {{/if}} | 19 | + <span class="join" data-id="{{couponId}}">立即参与</span> |
24 | <p class="coupon-mold">{{shareCoupon}}</p> | 20 | <p class="coupon-mold">{{shareCoupon}}</p> |
25 | <p class="coupon-limit">{{couponDescribe}}</p> | 21 | <p class="coupon-limit">{{couponDescribe}}</p> |
26 | </div> | 22 | </div> |
@@ -45,9 +45,9 @@ router.get('/index/new/jitDetail', authMW, order.jitDetail); // JIT 拆单配送 | @@ -45,9 +45,9 @@ router.get('/index/new/jitDetail', authMW, order.jitDetail); // JIT 拆单配送 | ||
45 | 45 | ||
46 | router.post('/index/add', indexController.add); // 加入购物车 | 46 | router.post('/index/add', indexController.add); // 加入购物车 |
47 | 47 | ||
48 | -router.get('/index/index', authMW, indexController.index); // 购物车 TODO: 删除 | 48 | +router.get('/index/index', indexController.index); // 购物车 TODO: 删除 |
49 | 49 | ||
50 | -router.get('/index/new', authMW, indexController.index); // 购物车(新版接口) | 50 | +router.get('/index/new', indexController.index); // 购物车(新版接口) |
51 | router.post('/index/new/data', indexController.indexData); // 购物车 | 51 | router.post('/index/new/data', indexController.indexData); // 购物车 |
52 | router.post('/index/new/select', indexController.select); // 选择取消购物车商品 | 52 | router.post('/index/new/select', indexController.select); // 选择取消购物车商品 |
53 | router.post('/index/new/del', indexController.del); // 删除购物车商品 | 53 | router.post('/index/new/del', indexController.del); // 删除购物车商品 |
@@ -2,8 +2,8 @@ | @@ -2,8 +2,8 @@ | ||
2 | require('activity/share-buy.page.css'); | 2 | require('activity/share-buy.page.css'); |
3 | 3 | ||
4 | let $ = require('yoho-jquery'), | 4 | let $ = require('yoho-jquery'), |
5 | - dialog = require('plugin/dialog'), | ||
6 | - yoho = require('yoho-app'); | 5 | + yoho = require('yoho-app'), |
6 | + tip = require('plugin/tip'); | ||
7 | 7 | ||
8 | let $news = $('.news'), | 8 | let $news = $('.news'), |
9 | newsLiL = $news.find('li').length, | 9 | newsLiL = $news.find('li').length, |
@@ -58,17 +58,27 @@ if (newsLiL > 1) { | @@ -58,17 +58,27 @@ if (newsLiL > 1) { | ||
58 | } | 58 | } |
59 | 59 | ||
60 | $('.join').click(function() { | 60 | $('.join').click(function() { |
61 | - if ($('.coupon-list').data('student') === false) { | ||
62 | 61 | ||
63 | - dialog.showDialog({ | ||
64 | - dialogText: '完成学生认证即可参与活动哦~', | ||
65 | - fast: true, | ||
66 | - hasFooter: { | ||
67 | - rightBtnText: '去认证' | 62 | + $.ajax({ |
63 | + type: 'GET', | ||
64 | + url: '/activity/share-buy/get-coupon-code', | ||
65 | + data: { | ||
66 | + couponId: $(this).data('id') | ||
67 | + }, | ||
68 | + success: function(result) { | ||
69 | + | ||
70 | + if (result.code === 200) { | ||
71 | + let link = result.data.detailUrl; | ||
72 | + | ||
73 | + if (yoho.isApp) { | ||
74 | + link = result.data.protocol + link; | ||
75 | + yoho.goH5(link); | ||
76 | + } else { | ||
77 | + window.location.href = link; | ||
78 | + } | ||
79 | + } else { | ||
80 | + tip.show(result.message); | ||
68 | } | 81 | } |
69 | - }, function() { | ||
70 | - | ||
71 | - 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"}}'); | ||
72 | - }, null, true); | ||
73 | - } | 82 | + } |
83 | + }); | ||
74 | }); | 84 | }); |
-
Please register or login to post a comment