Showing
4 changed files
with
34 additions
and
16 deletions
@@ -4,8 +4,7 @@ const model = require('../models/feature'); | @@ -4,8 +4,7 @@ const model = require('../models/feature'); | ||
4 | exports.index = function(req, res, next) { | 4 | exports.index = function(req, res, next) { |
5 | model.index({ | 5 | model.index({ |
6 | code: req.params.code, | 6 | code: req.params.code, |
7 | - type: req.query.type, | ||
8 | - user_id: req.user.uid || 0 | 7 | + type: req.query.type |
9 | }).then((result) => { | 8 | }).then((result) => { |
10 | if (!result) { | 9 | if (!result) { |
11 | return next(); | 10 | return next(); |
@@ -15,6 +14,7 @@ exports.index = function(req, res, next) { | @@ -15,6 +14,7 @@ exports.index = function(req, res, next) { | ||
15 | page: 'feature', | 14 | page: 'feature', |
16 | title: result.name || 'Yoho!Buy有货', | 15 | title: result.name || 'Yoho!Buy有货', |
17 | content: result, | 16 | content: result, |
17 | + activity_id: req.params.code, | ||
18 | isFeature: true | 18 | isFeature: true |
19 | }); | 19 | }); |
20 | }).catch(next); | 20 | }).catch(next); |
@@ -45,14 +45,12 @@ module.exports = { | @@ -45,14 +45,12 @@ module.exports = { | ||
45 | if (params.type === 'preview') { // 开发/预览模式 | 45 | if (params.type === 'preview') { // 开发/预览模式 |
46 | data = yield api.get('', { | 46 | data = yield api.get('', { |
47 | method: 'app.activity.template.ignoreCache', | 47 | method: 'app.activity.template.ignoreCache', |
48 | - activity_id: params.code, | ||
49 | - user_id: params.user_id | 48 | + activity_id: params.code |
50 | }); | 49 | }); |
51 | } else { | 50 | } else { |
52 | data = yield api.get('', { // 生产模式 | 51 | data = yield api.get('', { // 生产模式 |
53 | method: 'app.activity.template', | 52 | method: 'app.activity.template', |
54 | - activity_id: params.code, | ||
55 | - user_id: params.user_id | 53 | + activity_id: params.code |
56 | }, { | 54 | }, { |
57 | cache: true | 55 | cache: true |
58 | }); | 56 | }); |
1 | -<div class="feature-page yoho-page"> | 1 | +<div class="feature-page yoho-page" data-id="{{activity_id}}"> |
2 | {{#unless content.visiable}} | 2 | {{#unless content.visiable}} |
3 | <div class="over"> | 3 | <div class="over"> |
4 | <p>此活动已结束</p> | 4 | <p>此活动已结束</p> |
@@ -41,14 +41,8 @@ | @@ -41,14 +41,8 @@ | ||
41 | 41 | ||
42 | {{#isEqualOr type 'coupon'}} | 42 | {{#isEqualOr type 'coupon'}} |
43 | {{! 优惠券}} | 43 | {{! 优惠券}} |
44 | - {{#if personCoupon}} | ||
45 | - {{! 个性化优惠券,使用:分割}} | ||
46 | - <a class="anchor yoho-conpon" style="{{styleFormat this percent=1}}" data-token="{{personCoupon.couponId}}:{{personCoupon.personCouponId}}" | ||
47 | - href="{{#if url}}{{url}}{{else}}javascript:void(0);{{/if}}" fp="{{getAnalysis ../this @index}}"></a> | ||
48 | - {{else}} | ||
49 | - <a class="anchor yoho-conpon" style="{{styleFormat this percent=1}}" data-token="{{token}}" | ||
50 | - href="{{#if url}}{{url}}{{else}}javascript:void(0);{{/if}}" fp="{{getAnalysis ../this @index}}"></a> | ||
51 | - {{/if}} | 44 | + <a class="anchor yoho-conpon" style="{{styleFormat this percent=1}}" data-persenal-enable="{{persenal_enable}}" data-token="{{token}}" href="{{#if url}}{{url}}{{else}}javascript:void(0);{{/if}}" |
45 | + fp="{{getAnalysis ../this @index}}"></a> | ||
52 | {{/isEqualOr}} | 46 | {{/isEqualOr}} |
53 | 47 | ||
54 | {{#isEqualOr type 'yohoCoin'}} | 48 | {{#isEqualOr type 'yohoCoin'}} |
1 | var $ = require('yoho-jquery'); | 1 | var $ = require('yoho-jquery'); |
2 | var lazyLoad = require('yoho-jquery-lazyload'); | 2 | var lazyLoad = require('yoho-jquery-lazyload'); |
3 | var Swiper = require('yoho-swiper'); | 3 | var Swiper = require('yoho-swiper'); |
4 | +var qs = require('yoho-qs'); | ||
4 | var yoho = require('../yoho-app'); | 5 | var yoho = require('../yoho-app'); |
5 | 6 | ||
6 | global.jQuery = $; | 7 | global.jQuery = $; |
@@ -156,7 +157,29 @@ function modalInit() { | @@ -156,7 +157,29 @@ function modalInit() { | ||
156 | }); | 157 | }); |
157 | } | 158 | } |
158 | 159 | ||
159 | - | 160 | +function persenalCouponInit() { |
161 | + let activityId = $('.feature-page').data('id'); | ||
162 | + | ||
163 | + $('.yoho-conpon').each(function() { | ||
164 | + let $this = $(this); | ||
165 | + | ||
166 | + if ($this.data('persenal-enable')) { | ||
167 | + $.ajax({ | ||
168 | + url: '//m.yohobuy.com/activity/individuation/coupon', | ||
169 | + dataType: 'jsonp', | ||
170 | + data: { | ||
171 | + uid: qs.uid || 0, | ||
172 | + activity_id: activityId | ||
173 | + }, | ||
174 | + success: function(res) { | ||
175 | + if (res.code === 200 && res.data && res.data.couponId && res.data.personCouponId) { | ||
176 | + $this.attr('data-token', `${res.data.couponId}:${res.data.personCouponId}`); | ||
177 | + } | ||
178 | + } | ||
179 | + }); | ||
180 | + } | ||
181 | + }); | ||
182 | +} | ||
160 | 183 | ||
161 | $(function() { | 184 | $(function() { |
162 | if ($('.over').length) { | 185 | if ($('.over').length) { |
@@ -197,4 +220,7 @@ $(function() { | @@ -197,4 +220,7 @@ $(function() { | ||
197 | 220 | ||
198 | // 模态框 | 221 | // 模态框 |
199 | modalInit(); | 222 | modalInit(); |
223 | + | ||
224 | + // 个性化券查询 | ||
225 | + persenalCouponInit(); | ||
200 | }); | 226 | }); |
-
Please register or login to post a comment