Showing
4 changed files
with
75 additions
and
0 deletions
@@ -109,3 +109,36 @@ exports.coupon = function(req, res, next) { | @@ -109,3 +109,36 @@ exports.coupon = function(req, res, next) { | ||
109 | res.jsonp(result); | 109 | res.jsonp(result); |
110 | }).catch(next); | 110 | }).catch(next); |
111 | }; | 111 | }; |
112 | + | ||
113 | +exports.shop = function(req, res, next) { | ||
114 | + // let activity_template_id = req.query.activity_id; | ||
115 | + let uid = req.user.uid || req.query.uid; | ||
116 | + let app = req.query.app; | ||
117 | + | ||
118 | + if (app && app.app_version && app.client_type && app.session_key && app.uid) { | ||
119 | + uid = { | ||
120 | + toString: () => { | ||
121 | + return _.parseInt(app.uid); | ||
122 | + }, | ||
123 | + sessionKey: app.session_key, | ||
124 | + appVersion: app.app_version, | ||
125 | + appSessionType: app.client_type | ||
126 | + }; | ||
127 | + } | ||
128 | + | ||
129 | + const params = Object.assign({ | ||
130 | + limit: 12, | ||
131 | + yh_channel: (req.yoho.channel && channels[req.yoho.channel]) || '1', | ||
132 | + imageType: req.query.displayStyle === '1' ? '1' : '2', | ||
133 | + season: req.query.season || '1', | ||
134 | + port: '1' | ||
135 | + }, req.query.searchCondition); | ||
136 | + | ||
137 | + if (uid && uid.toString()) { | ||
138 | + params.uid = uid; | ||
139 | + } | ||
140 | + | ||
141 | + req.ctx(model).getShop(params).then((result) => { | ||
142 | + res.jsonp(result); | ||
143 | + }).catch(next); | ||
144 | +}; |
@@ -79,6 +79,14 @@ class individuationModel extends global.yoho.BaseModel { | @@ -79,6 +79,14 @@ class individuationModel extends global.yoho.BaseModel { | ||
79 | param: {cache: true} | 79 | param: {cache: true} |
80 | }); | 80 | }); |
81 | } | 81 | } |
82 | + getShop(params) { | ||
83 | + return this.get({ | ||
84 | + data: Object.assign({ | ||
85 | + method: 'app.search.shopRecommend.template' | ||
86 | + }, params), | ||
87 | + param: {cache: true} | ||
88 | + }); | ||
89 | + } | ||
82 | 90 | ||
83 | } | 91 | } |
84 | 92 |
@@ -264,6 +264,7 @@ router.get('/redbag/2017', redbag.index); | @@ -264,6 +264,7 @@ router.get('/redbag/2017', redbag.index); | ||
264 | // 获取活动页面个性化推荐商品数据 | 264 | // 获取活动页面个性化推荐商品数据 |
265 | router.get('/individuation', individuation.productLst); | 265 | router.get('/individuation', individuation.productLst); |
266 | router.get('/individuation/coupon', individuation.coupon); | 266 | router.get('/individuation/coupon', individuation.coupon); |
267 | +router.get('/individuation/shop', individuation.shop); | ||
267 | 268 | ||
268 | // 活动页模版 | 269 | // 活动页模版 |
269 | router.get('/feature/:code.html', feature.index); | 270 | router.get('/feature/:code.html', feature.index); |
@@ -260,6 +260,36 @@ function persenalCouponInit() { | @@ -260,6 +260,36 @@ function persenalCouponInit() { | ||
260 | }); | 260 | }); |
261 | } | 261 | } |
262 | 262 | ||
263 | +function shopGroupInit() { | ||
264 | + $('.shop-individuation').each(function() { | ||
265 | + const $this = $(this); | ||
266 | + const config = $this.data('config'); | ||
267 | + | ||
268 | + config.activity_id = $('.feature-page').data('id'); | ||
269 | + | ||
270 | + if (yoho.isApp) { | ||
271 | + config.app = { | ||
272 | + uid: cookie.get('app_uid') || qs.uid, | ||
273 | + app_version: cookie.get('app_version') || qs.app_version, | ||
274 | + client_type: cookie.get('app_client_type') || qs.client_type, | ||
275 | + session_key: cookie.get('app_session_key') || qs.session_key | ||
276 | + }; | ||
277 | + } | ||
278 | + | ||
279 | + $.ajax({ | ||
280 | + url: '//m.yohobuy.com/activity/individuation/shop', | ||
281 | + data: config, | ||
282 | + dataType: 'jsonp' | ||
283 | + }).then(res => { | ||
284 | + if (res && res.html) { | ||
285 | + $this.replaceWith(res.html); | ||
286 | + } else { | ||
287 | + // $this.remove(); | ||
288 | + } | ||
289 | + }); | ||
290 | + }); | ||
291 | +} | ||
292 | + | ||
263 | $(function() { | 293 | $(function() { |
264 | if ($('.over').length) { | 294 | if ($('.over').length) { |
265 | // 过期/删除 状态的 活动 | 295 | // 过期/删除 状态的 活动 |
@@ -309,6 +339,9 @@ $(function() { | @@ -309,6 +339,9 @@ $(function() { | ||
309 | // 个性化券查询 | 339 | // 个性化券查询 |
310 | persenalCouponInit(); | 340 | persenalCouponInit(); |
311 | 341 | ||
342 | + // 个性化店铺组 | ||
343 | + shopGroupInit(); | ||
344 | + | ||
312 | // 小程序相关处理 | 345 | // 小程序相关处理 |
313 | if (window.__wxjs_environment === 'miniprogram') { | 346 | if (window.__wxjs_environment === 'miniprogram') { |
314 | require('./miniprogram'); | 347 | require('./miniprogram'); |
-
Please register or login to post a comment