Showing
10 changed files
with
180 additions
and
40 deletions
@@ -17,24 +17,37 @@ exports.index = (req, res, next) => { | @@ -17,24 +17,37 @@ exports.index = (req, res, next) => { | ||
17 | }).catch(next); | 17 | }).catch(next); |
18 | }; | 18 | }; |
19 | 19 | ||
20 | -exports.detail = (req, res) => { | ||
21 | - // let uid = req.user.uid; | ||
22 | - | ||
23 | - res.render('share-buy/share-detail', { | ||
24 | - localCss: true, | ||
25 | - width750: true, | ||
26 | - title: '分享购', | ||
27 | - page: 'share-detail' | ||
28 | - }); | 20 | +exports.detail = (req, res, next) => { |
21 | + let uid = req.user.uid, | ||
22 | + param = { | ||
23 | + counum: req.query.counum, | ||
24 | + couponType: req.query.couponType, | ||
25 | + detailDes: req.query.detailDes, | ||
26 | + couponId: 12301 // req.query.couponId; | ||
27 | + }; | ||
28 | + | ||
29 | + req.ctx(shareBuyModel).shareDetail(uid, param).then(data => { | ||
30 | + | ||
31 | + res.render('share-buy/share-detail', { | ||
32 | + localCss: true, | ||
33 | + width750: true, | ||
34 | + title: '分享购', | ||
35 | + page: 'share-detail', | ||
36 | + detailData: data | ||
37 | + }); | ||
38 | + }).catch(next); | ||
29 | }; | 39 | }; |
30 | 40 | ||
31 | exports.myRebeat = (req, res) => { | 41 | exports.myRebeat = (req, res) => { |
32 | // let uid = req.user.uid; | 42 | // let uid = req.user.uid; |
33 | 43 | ||
44 | + // req.ctx(shareBuyModel).myRebeat(uid).then(data => { | ||
34 | res.render('share-buy/my-rebeat', { | 45 | res.render('share-buy/my-rebeat', { |
35 | localCss: true, | 46 | localCss: true, |
36 | width750: true, | 47 | width750: true, |
37 | title: '我的返利收益', | 48 | title: '我的返利收益', |
38 | page: 'my-rebeat' | 49 | page: 'my-rebeat' |
39 | }); | 50 | }); |
51 | + | ||
52 | + // }).catch(next); | ||
40 | }; | 53 | }; |
1 | const api = global.yoho.API; | 1 | const api = global.yoho.API; |
2 | const _ = require('lodash'); | 2 | const _ = require('lodash'); |
3 | +const helpers = global.yoho.helpers; | ||
3 | 4 | ||
4 | module.exports = class extends global.yoho.BaseModel { | 5 | module.exports = class extends global.yoho.BaseModel { |
5 | constructor(ctx) { | 6 | constructor(ctx) { |
6 | super(ctx); | 7 | super(ctx); |
7 | } | 8 | } |
8 | 9 | ||
10 | + /** | ||
11 | + * 首页数据 | ||
12 | + */ | ||
9 | shareIndex(activityId) { | 13 | shareIndex(activityId) { |
10 | 14 | ||
11 | return api.all([this._CouponInfo(activityId), this._redeatList()]).then(result => { | 15 | return api.all([this._CouponInfo(activityId), this._redeatList()]).then(result => { |
@@ -15,13 +19,27 @@ module.exports = class extends global.yoho.BaseModel { | @@ -15,13 +19,27 @@ module.exports = class extends global.yoho.BaseModel { | ||
15 | 19 | ||
16 | if (result[0] && result[0].data && result[0].data.userCouponBoList) { | 20 | if (result[0] && result[0].data && result[0].data.userCouponBoList) { |
17 | _.forEach(result[0].data.userCouponBoList, function(val) { | 21 | _.forEach(result[0].data.userCouponBoList, function(val) { |
22 | + | ||
18 | if (val.sortNames) { | 23 | if (val.sortNames) { |
19 | val.couponDescribe = '限' + val.sortNames + '使用'; | 24 | val.couponDescribe = '限' + val.sortNames + '使用'; |
25 | + val.detailDes = '限品类: ' + val.sortNames; | ||
20 | } else if (val.brandNames) { | 26 | } else if (val.brandNames) { |
21 | val.couponDescribe = '限' + val.brandNames + '使用'; | 27 | val.couponDescribe = '限' + val.brandNames + '使用'; |
28 | + val.detailDes = '限品牌: ' + val.brandNames; | ||
22 | } else if (val.shareCoupon === '全场通用') { | 29 | } else if (val.shareCoupon === '全场通用') { |
23 | val.couponDescribe = '任意商品使用'; | 30 | val.couponDescribe = '任意商品使用'; |
31 | + val.detailDes = val.shareCoupon; | ||
32 | + } else if (val.shopNames) { | ||
33 | + val.couponDescribe = '限' + val.shopNames + '使用'; | ||
34 | + val.detailDes = val.shareCoupon; | ||
24 | } | 35 | } |
36 | + | ||
37 | + val.detailUrl = helpers.urlFormat('/activity/share-buy/detail', { | ||
38 | + counum: val.couponValue, | ||
39 | + couponType: val.shareCouponType, | ||
40 | + detailDes: val.detailDes, | ||
41 | + couponId: val.couponId | ||
42 | + }); | ||
25 | }); | 43 | }); |
26 | 44 | ||
27 | indexData.userCouponBoList = result[0].data.userCouponBoList; | 45 | indexData.userCouponBoList = result[0].data.userCouponBoList; |
@@ -49,7 +67,9 @@ module.exports = class extends global.yoho.BaseModel { | @@ -49,7 +67,9 @@ module.exports = class extends global.yoho.BaseModel { | ||
49 | }, { | 67 | }, { |
50 | code: 200 | 68 | code: 200 |
51 | }).then((result) => { | 69 | }).then((result) => { |
52 | - return result; | 70 | + if (result && result.code === 200 && result.data) { |
71 | + return result; | ||
72 | + } | ||
53 | }); | 73 | }); |
54 | } | 74 | } |
55 | 75 | ||
@@ -60,9 +80,62 @@ module.exports = class extends global.yoho.BaseModel { | @@ -60,9 +80,62 @@ module.exports = class extends global.yoho.BaseModel { | ||
60 | return api.get('', { | 80 | return api.get('', { |
61 | method: 'app.yohocoinrebeat.lastedlist' | 81 | method: 'app.yohocoinrebeat.lastedlist' |
62 | }, { | 82 | }, { |
83 | + code: 200, | ||
84 | + cache: true | ||
85 | + }).then((result) => { | ||
86 | + if (result && result.code === 200 && result.data) { | ||
87 | + return result; | ||
88 | + } | ||
89 | + }); | ||
90 | + } | ||
91 | + | ||
92 | + /** | ||
93 | + * 优惠详情页数据 | ||
94 | + */ | ||
95 | + shareDetail(uid, param) { | ||
96 | + return api.get('', { | ||
97 | + method: 'app.activity.getActivityCouponCode', | ||
98 | + uid: uid, | ||
99 | + coupon_id: param.couponId | ||
100 | + }, { | ||
63 | code: 200 | 101 | code: 200 |
64 | }).then((result) => { | 102 | }).then((result) => { |
65 | - return result; | 103 | + |
104 | + if (result && result.code === 200 && result.data) { | ||
105 | + result.data = _.assign(result.data, param); | ||
106 | + | ||
107 | + result.data.moreUrl = helpers.urlFormat('', { | ||
108 | + coupon_code: result.data.couponCode, | ||
109 | + coupon_id: param.couponId, | ||
110 | + title: '优惠活动商品' | ||
111 | + }, 'list'); | ||
112 | + | ||
113 | + return result.data; | ||
114 | + } else { | ||
115 | + return {}; | ||
116 | + } | ||
117 | + | ||
66 | }); | 118 | }); |
67 | } | 119 | } |
120 | + | ||
121 | + /** | ||
122 | + * 我的返利页数据 | ||
123 | + */ | ||
124 | + // myRebeat(uid) { | ||
125 | + // return api.get('', { | ||
126 | + // method: 'app.yohocoinrebeat.detail', | ||
127 | + // uid: uid | ||
128 | + // }, { | ||
129 | + // code: 200 | ||
130 | + // }).then((result) => { | ||
131 | + | ||
132 | + // if (result && result.code === 200 && result.data) { | ||
133 | + | ||
134 | + // return result.data; | ||
135 | + // } else { | ||
136 | + // return {}; | ||
137 | + // } | ||
138 | + | ||
139 | + // }); | ||
140 | + // } | ||
68 | }; | 141 | }; |
@@ -241,7 +241,7 @@ router.get('/app-downloads', appDownloads.index); | @@ -241,7 +241,7 @@ router.get('/app-downloads', appDownloads.index); | ||
241 | router.get('/couponSend', couponFloor.couponSend); // 获取优惠券 | 241 | router.get('/couponSend', couponFloor.couponSend); // 获取优惠券 |
242 | 242 | ||
243 | router.get('/share-buy', shareBuy.index); // 分享购首页 | 243 | router.get('/share-buy', shareBuy.index); // 分享购首页 |
244 | -router.get('/share-buy/detail', shareBuy.detail); // 分享购详情页 | ||
245 | -router.get('/share-buy/my-rebeat', shareBuy.myRebeat); // 我的返利 | 244 | +router.get('/share-buy/detail', auth, shareBuy.detail); // 分享购详情页 |
245 | +router.get('/share-buy/my-rebeat', auth, shareBuy.myRebeat); // 我的返利 | ||
246 | 246 | ||
247 | module.exports = router; | 247 | module.exports = router; |
@@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
12 | <p class="coupon-type">{{shareCouponType}}</p> | 12 | <p class="coupon-type">{{shareCouponType}}</p> |
13 | </div> | 13 | </div> |
14 | <div class="coupon-right"> | 14 | <div class="coupon-right"> |
15 | - <span>立即参与</span> | 15 | + <a href="{{detailUrl}}">立即参与</a> |
16 | <p class="coupon-mold">{{shareCoupon}}</p> | 16 | <p class="coupon-mold">{{shareCoupon}}</p> |
17 | <p class="coupon-limit">{{couponDescribe}}</p> | 17 | <p class="coupon-limit">{{couponDescribe}}</p> |
18 | </div> | 18 | </div> |
1 | <div class="share-detail-page"> | 1 | <div class="share-detail-page"> |
2 | + {{# detailData}} | ||
2 | <div class="coupon-detail"> | 3 | <div class="coupon-detail"> |
3 | <div class="countdown"> | 4 | <div class="countdown"> |
4 | <div class="title">距离活动时间还剩:</div> | 5 | <div class="title">距离活动时间还剩:</div> |
5 | - <div class="activity-time"> | 6 | + <div class="activity-time" data-id="{{expiredTime}}"> |
6 | <span></span> | 7 | <span></span> |
7 | <span></span>天 | 8 | <span></span>天 |
8 | <span></span> | 9 | <span></span> |
@@ -14,22 +15,22 @@ | @@ -14,22 +15,22 @@ | ||
14 | </div> | 15 | </div> |
15 | </div> | 16 | </div> |
16 | 17 | ||
17 | - <div class="coupon-info"> | 18 | + <div class="coupon-info" data-id="{{couponId}}"> |
18 | <div class="info-top"> | 19 | <div class="info-top"> |
19 | <div class="coupon-money"> | 20 | <div class="coupon-money"> |
20 | <i class="iconfont">¥</i> | 21 | <i class="iconfont">¥</i> |
21 | - <span>50</span> | 22 | + <span>{{counum}}</span> |
22 | </div> | 23 | </div> |
23 | - <span class="coupon-code">fhewlfhwefh</span> | 24 | + <span class="coupon-code">{{couponCode}}</span> |
24 | <span class="copy">复制</span> | 25 | <span class="copy">复制</span> |
25 | <p class="share-way">(券码可直接分享给好友) | 26 | <p class="share-way">(券码可直接分享给好友) |
26 | - <span class="coupon-type">现金券<span> | 27 | + <span class="coupon-type">{{couponType}}<span> |
27 | </p> | 28 | </p> |
28 | </div> | 29 | </div> |
29 | <div class="info-bottom"> | 30 | <div class="info-bottom"> |
30 | - <span class="share-coupon">全场通用</span> | 31 | + <span class="share-coupon">{{detailDes}}</span> |
31 | <span class="coupon-tip">特列商品(秒杀、限定、境外、预售等)暂不支持使用优惠券。</span> | 32 | <span class="coupon-tip">特列商品(秒杀、限定、境外、预售等)暂不支持使用优惠券。</span> |
32 | - <span class="validity">有效期</span> | 33 | + <span class="validity">有效期: {{couponValidity}}</span> |
33 | </div> | 34 | </div> |
34 | 35 | ||
35 | <p class="use-way"> | 36 | <p class="use-way"> |
@@ -43,7 +44,10 @@ | @@ -43,7 +44,10 @@ | ||
43 | <div class="commodity"> | 44 | <div class="commodity"> |
44 | <p class="title"> | 45 | <p class="title"> |
45 | <span>优惠券可适用于以下产品</span> | 46 | <span>优惠券可适用于以下产品</span> |
46 | - <span class="more">更多商品<i class="iconfont"></i></span> | 47 | + <a class="more" href="{{moreUrl}}">更多商品<i class="iconfont"></i></a> |
47 | </p> | 48 | </p> |
49 | + | ||
50 | + <div class="goods-container"></div> | ||
48 | </div> | 51 | </div> |
52 | + {{/ detailData}} | ||
49 | </div> | 53 | </div> |
@@ -3,7 +3,12 @@ | @@ -3,7 +3,12 @@ | ||
3 | let $ = require('yoho-jquery'); | 3 | let $ = require('yoho-jquery'); |
4 | 4 | ||
5 | let $activityTime = $('.activity-time'), | 5 | let $activityTime = $('.activity-time'), |
6 | - endTime = $activityTime ? $activityTime.data('time-s') : ''; | 6 | + endTime = $activityTime ? $activityTime.data('time-s') : '', |
7 | + $container = $('.goods-container'); | ||
8 | + | ||
9 | +let winH = $(window).height(), | ||
10 | + page = 1, | ||
11 | + onloading = false; // 是否正在加载商品数据 | ||
7 | 12 | ||
8 | let params = { | 13 | let params = { |
9 | anHour: 3600, // 1小时=?秒 | 14 | anHour: 3600, // 1小时=?秒 |
@@ -13,6 +18,8 @@ let params = { | @@ -13,6 +18,8 @@ let params = { | ||
13 | endTime: [endTime] // 时间差数组 | 18 | endTime: [endTime] // 时间差数组 |
14 | }; | 19 | }; |
15 | 20 | ||
21 | +let noResultHbs = require('product/search/no-result-new.hbs'); | ||
22 | + | ||
16 | require('activity/share-detail.page.css'); | 23 | require('activity/share-detail.page.css'); |
17 | 24 | ||
18 | function division(time) { | 25 | function division(time) { |
@@ -73,18 +80,59 @@ function startCountDown(p) { | @@ -73,18 +80,59 @@ function startCountDown(p) { | ||
73 | }, 1000); | 80 | }, 1000); |
74 | } | 81 | } |
75 | 82 | ||
76 | -$.ajax({ | ||
77 | - type: 'GET', | ||
78 | - url: '/product/sale/discount/getTime', | ||
79 | - data: { | ||
80 | - id: 3919 | ||
81 | - }, | ||
82 | - success: function(data) { | ||
83 | - if (data) { | ||
84 | - | ||
85 | - startCountDown({ | ||
86 | - endTime: [data] | ||
87 | - }); | ||
88 | - } | 83 | +if ($activityTime.data('id')) { |
84 | + startCountDown({ | ||
85 | + endTime: [$activityTime.data('id')] | ||
86 | + }); | ||
87 | +} | ||
88 | + | ||
89 | +function productData() { | ||
90 | + | ||
91 | + if (!onloading) { | ||
92 | + onloading = true; | ||
93 | + | ||
94 | + $.ajax({ | ||
95 | + type: 'GET', | ||
96 | + url: location.protocol + '//m.yohobuy.com/product/search/search', | ||
97 | + data: { | ||
98 | + coupon_id: $('.coupon-info').data('id'), | ||
99 | + type: 'default', | ||
100 | + order: 0, | ||
101 | + page: page, | ||
102 | + noLazy: true | ||
103 | + }, | ||
104 | + xhrFields: { | ||
105 | + withCredentials: true | ||
106 | + }, | ||
107 | + success: function(data) { | ||
108 | + | ||
109 | + if (data === '' || (data.list && data.list.length <= 0)) { | ||
110 | + $container.html(noResultHbs()); | ||
111 | + } else { | ||
112 | + $container.append(data); | ||
113 | + } | ||
114 | + | ||
115 | + onloading = false; | ||
116 | + } | ||
117 | + }); | ||
89 | } | 118 | } |
119 | + | ||
120 | + page = page + 1; | ||
121 | +} | ||
122 | + | ||
123 | +function scrollHandler() { | ||
124 | + | ||
125 | + // 当scroll到1/2$goodsContainer高度后继续请求下一页数据 | ||
126 | + if ($(window).scrollTop() + winH > | ||
127 | + $(document).height() - 0.5 * $container.height()) { | ||
128 | + productData(); | ||
129 | + } | ||
130 | +} | ||
131 | + | ||
132 | +$(window).scroll(function() { | ||
133 | + window.requestAnimationFrame(scrollHandler); | ||
134 | +}); | ||
135 | + | ||
136 | +$(function() { | ||
137 | + productData(); | ||
90 | }); | 138 | }); |
@@ -60,12 +60,12 @@ | @@ -60,12 +60,12 @@ | ||
60 | i { | 60 | i { |
61 | display: inline-block; | 61 | display: inline-block; |
62 | width: 90px; | 62 | width: 90px; |
63 | - height: 27px; | 63 | + height: 29px; |
64 | background-color: #b0b0b0; | 64 | background-color: #b0b0b0; |
65 | color: #fff; | 65 | color: #fff; |
66 | - font-size: 22px; | 66 | + font-size: 18px; |
67 | border-radius: 10px; | 67 | border-radius: 10px; |
68 | - line-height: 27px; | 68 | + line-height: 29px; |
69 | text-align: center; | 69 | text-align: center; |
70 | } | 70 | } |
71 | 71 |
-
Please register or login to post a comment