Showing
7 changed files
with
222 additions
and
0 deletions
@@ -165,6 +165,47 @@ class HaveGain { | @@ -165,6 +165,47 @@ class HaveGain { | ||
165 | return res.json(result); | 165 | return res.json(result); |
166 | }).catch(next); | 166 | }).catch(next); |
167 | } | 167 | } |
168 | + | ||
169 | + | ||
170 | + promoDetail(req, res, next) { | ||
171 | + let uid = req.user.uid; | ||
172 | + let pid = req.params.id; | ||
173 | + | ||
174 | + if (!pid) { | ||
175 | + return next(Error('promo detail pid is empty')); | ||
176 | + } | ||
177 | + | ||
178 | + return req.ctx(haveGainModel).promoDetail(pid, uid).then(result => { | ||
179 | + if (result.error) { | ||
180 | + return next(result.error); | ||
181 | + } | ||
182 | + | ||
183 | + return res.render('have-gain/promoDetail', Object.assign({ | ||
184 | + page: 'have-gain-promodetail', | ||
185 | + title: '活动说明' | ||
186 | + }, result)); | ||
187 | + }).catch(next); | ||
188 | + } | ||
189 | + | ||
190 | + promoSubmit(req, res, next) { | ||
191 | + let uid = req.user.uid; | ||
192 | + let pid = req.params.id; | ||
193 | + | ||
194 | + return req.ctx(haveGainModel).promoSubmit(pid, uid).then(result => { | ||
195 | + if (result.error) { | ||
196 | + return res.json({ | ||
197 | + code: 401, | ||
198 | + message: result.error.message | ||
199 | + }); | ||
200 | + } | ||
201 | + | ||
202 | + return res.json({ | ||
203 | + code: 200, | ||
204 | + ...result | ||
205 | + }); | ||
206 | + }).catch(next); | ||
207 | + } | ||
208 | + | ||
168 | } | 209 | } |
169 | 210 | ||
170 | module.exports = new HaveGain(); | 211 | module.exports = new HaveGain(); |
@@ -112,4 +112,52 @@ module.exports = class extends global.yoho.BaseModel { | @@ -112,4 +112,52 @@ module.exports = class extends global.yoho.BaseModel { | ||
112 | } | 112 | } |
113 | }); | 113 | }); |
114 | } | 114 | } |
115 | + | ||
116 | + | ||
117 | + async promoDetail(pid, uid) { | ||
118 | + return this.get({ | ||
119 | + data: { | ||
120 | + method: 'app.union.shareOrder.queryActivityPage', | ||
121 | + uid, | ||
122 | + id: pid | ||
123 | + } | ||
124 | + }).then(result => { | ||
125 | + | ||
126 | + if (result.code !== 200) { | ||
127 | + return { | ||
128 | + error: Error('出错了') | ||
129 | + }; | ||
130 | + } | ||
131 | + | ||
132 | + return { | ||
133 | + status: uid ? result.data.status : 0, | ||
134 | + imageUrl: result.data.image, | ||
135 | + content: result.data.content, | ||
136 | + contentTitle: result.data.title, | ||
137 | + url: result.data.url | ||
138 | + }; | ||
139 | + }); | ||
140 | + } | ||
141 | + | ||
142 | + async promoSubmit(pid, uid) { | ||
143 | + return this.get({ | ||
144 | + data: { | ||
145 | + method: 'app.union.shareOrder.preJoinActivity', | ||
146 | + uid: uid, | ||
147 | + id: pid | ||
148 | + } | ||
149 | + }).then(result => { | ||
150 | + if (result.code !== 200) { | ||
151 | + return { | ||
152 | + error: Error('出错了') | ||
153 | + }; | ||
154 | + } | ||
155 | + | ||
156 | + return { | ||
157 | + data: { | ||
158 | + ...result.data | ||
159 | + }, | ||
160 | + }; | ||
161 | + }); | ||
162 | + } | ||
115 | }; | 163 | }; |
@@ -337,4 +337,8 @@ router.get('/have-gain/fail', auth, haveGain.fail); // 有货有赚审核不通 | @@ -337,4 +337,8 @@ router.get('/have-gain/fail', auth, haveGain.fail); // 有货有赚审核不通 | ||
337 | router.post('/have-gain/resetApply', auth, haveGain.resetApply); // 有货有赚审核不通过,重新申请API | 337 | router.post('/have-gain/resetApply', auth, haveGain.resetApply); // 有货有赚审核不通过,重新申请API |
338 | router.post('/have-gain/submitApply', auth, haveGain.submitApply); // 有货有赚-申请开通 | 338 | router.post('/have-gain/submitApply', auth, haveGain.submitApply); // 有货有赚-申请开通 |
339 | 339 | ||
340 | +// 有货有赚推广活动 | ||
341 | +router.get('/have-gain/promo/:id.html', haveGain.promoDetail); | ||
342 | +router.post('/have-gain/promo/:id', auth, haveGain.promoSubmit); | ||
343 | + | ||
340 | module.exports = router; | 344 | module.exports = router; |
1 | +<div class="promo-page"> | ||
2 | + <div class="promo-banner"> | ||
3 | + <img src="{{imageUrl}}"> | ||
4 | + </div> | ||
5 | + | ||
6 | + <div class="promo-desc"> | ||
7 | + <div class="promo-desc__title">{{{contentTitle}}}</div> | ||
8 | + <div class="promo-desc__content">{{{content}}}</div> | ||
9 | + </div> | ||
10 | + | ||
11 | + <div class="promo-status {{#isEqualOr status 0 1}} promo-status_submit {{else}} promo-status_over {{/isEqualOr}}js-submit" data-url="{{url}}" data-pid="{{id}}" data-status="{{status}}"> | ||
12 | + {{#isEqualOr status 0 1}} | ||
13 | + 点击确认参加活动 | ||
14 | + {{/isEqualOr}} | ||
15 | + | ||
16 | + {{#isEqualOr status 2}} | ||
17 | + 报名成功,去分享活动商品 | ||
18 | + {{/isEqualOr}} | ||
19 | + | ||
20 | + {{#isEqualOr status 3}} | ||
21 | + 不满足参加活动条件 | ||
22 | + {{/isEqualOr}} | ||
23 | + | ||
24 | + {{#isEqualOr status 4}} | ||
25 | + 活动未开始 | ||
26 | + {{/isEqualOr}} | ||
27 | + | ||
28 | + {{#isEqualOr status 5}} | ||
29 | + 活动已结束,请关注其他活动 | ||
30 | + {{/isEqualOr}} | ||
31 | + </div> | ||
32 | +</div> |
public/hbs/activity/have-gain/status.hbs
0 → 100644
1 | +{{#isEqualOr status 0 1}} | ||
2 | + 点击确认参加活动 | ||
3 | +{{/isEqualOr}} | ||
4 | + | ||
5 | +{{#isEqualOr status 2}} | ||
6 | + 报名成功,去分享活动商品 | ||
7 | +{{/isEqualOr}} | ||
8 | + | ||
9 | +{{#isEqualOr status 3}} | ||
10 | + 不满足参加活动条件 | ||
11 | +{{/isEqualOr}} | ||
12 | + | ||
13 | +{{#isEqualOr status 4}} | ||
14 | + 活动未开始 | ||
15 | +{{/isEqualOr}} | ||
16 | + | ||
17 | +{{#isEqualOr status 5}} | ||
18 | + 活动已结束,请关注其他活动 | ||
19 | +{{/isEqualOr}} |
1 | + | ||
2 | +import 'scss/activity/have-gain-promodetail.page.scss'; | ||
3 | +import $ from 'yoho-jquery'; | ||
4 | +import statusTpl from 'hbs/activity/have-gain/status.hbs'; | ||
5 | +require('js/plugin/modal.alert'); | ||
6 | + | ||
7 | +const $promoStatus = $('.promo-status.js-submit'); | ||
8 | + | ||
9 | +function joinActivity(id) { | ||
10 | + return $.post(`/activity/have-gain/promo/${id}`); | ||
11 | +} | ||
12 | + | ||
13 | +function changeStatus(status) { | ||
14 | + $promoStatus.removeClass('promo-status_over').addClass('promo-status_submit') | ||
15 | + .html(statusTpl({status})); | ||
16 | +} | ||
17 | + | ||
18 | +$promoStatus.on('click', function() { | ||
19 | + const $this = $(this); | ||
20 | + const url = $this.data('url'); | ||
21 | + const pid = $this.data('pid'); | ||
22 | + | ||
23 | + if ($this.hasClass('promo-status_over')) { | ||
24 | + return; | ||
25 | + } | ||
26 | + | ||
27 | + if (url) { | ||
28 | + window.location.href = url; | ||
29 | + return; | ||
30 | + } | ||
31 | + | ||
32 | + if (pid) { | ||
33 | + joinActivity(pid).then(result => { | ||
34 | + if (result.code !== 200) { | ||
35 | + $.yAlert(result.data.message); | ||
36 | + return; | ||
37 | + } | ||
38 | + | ||
39 | + $.yAlert(result.data.message); | ||
40 | + changeStatus(result.data.result); | ||
41 | + }); | ||
42 | + } | ||
43 | +}); | ||
44 | + | ||
45 | + |
1 | +/* stylelint-disable */ | ||
2 | + | ||
3 | +.promo-status { | ||
4 | + position: fixed; | ||
5 | + bottom: 0; | ||
6 | + width: 100%; | ||
7 | + height: 110px; | ||
8 | + color: white; | ||
9 | + font-size: 32px; | ||
10 | + text-align: center; | ||
11 | + line-height: 110px; | ||
12 | +} | ||
13 | + | ||
14 | +.promo-status_submit { | ||
15 | + background: #d0021b; | ||
16 | +} | ||
17 | + | ||
18 | +.promo-status_over { | ||
19 | + background: #444; | ||
20 | +} | ||
21 | + | ||
22 | +.promo-desc__title { | ||
23 | + font-size: 32px; | ||
24 | + color: #444; | ||
25 | + margin-top: 40px; | ||
26 | + margin-bottom: 20px; | ||
27 | +} | ||
28 | + | ||
29 | +.promo-desc__content { | ||
30 | + font-size: 28px; | ||
31 | + color: #444; | ||
32 | + line-height: 60px; | ||
33 | +} |
-
Please register or login to post a comment