Showing
4 changed files
with
81 additions
and
8 deletions
apps/activity/controllers/individuation.js
0 → 100644
1 | +'use strict'; | ||
2 | +const model = require('../models/individuation'); | ||
3 | + | ||
4 | +exports.productLst = function(req, res, next) { | ||
5 | + let params = { | ||
6 | + uid: req.query.uid, | ||
7 | + udid: req.query.udid, | ||
8 | + pid: req.query.pid | ||
9 | + }; | ||
10 | + | ||
11 | + if (req.query.sort) { | ||
12 | + params.sort = req.query.sort; | ||
13 | + } else if (req.query.brand) { | ||
14 | + params.brand = req.query.brand; | ||
15 | + } | ||
16 | + | ||
17 | + if (req.query.enum) { | ||
18 | + params.specified_sort = req.query.enum; | ||
19 | + } | ||
20 | + | ||
21 | + if (req.query.limit) { | ||
22 | + params.limit = req.query.limit; | ||
23 | + } | ||
24 | + | ||
25 | + | ||
26 | + model.productLst(params).then((result) => { | ||
27 | + res.jsonp(result); | ||
28 | + }).catch(next); | ||
29 | +}; |
@@ -39,18 +39,29 @@ exports.wechatShare = (req, res, next) => { | @@ -39,18 +39,29 @@ exports.wechatShare = (req, res, next) => { | ||
39 | 39 | ||
40 | // 活动页保存相应cookie的值 | 40 | // 活动页保存相应cookie的值 |
41 | exports.feature = (req, res) => { | 41 | exports.feature = (req, res) => { |
42 | - let mktCode = req.query.mkt_code || false; | ||
43 | - | ||
44 | - // 下载浮层,下载按钮会用到该参数 | 42 | + let mktCode = req.query.mkt_code || req.query.union_type || false; |
43 | + let expires = req.query.expires; | ||
44 | + | ||
45 | if (mktCode) { | 45 | if (mktCode) { |
46 | - res.cookie('mkt_code', mktCode, { | ||
47 | - domain: '.yohobuy.com', | 46 | + res.cookie('unionTypeYas', mktCode, { // 下载浮层 |
48 | path: '/' | 47 | path: '/' |
49 | }); | 48 | }); |
50 | - res.cookie('unionTypeYas', mktCode, { | 49 | + |
50 | + // 下单使用 | ||
51 | + let options = { | ||
52 | + domain: '.yohobuy.com', | ||
51 | path: '/' | 53 | path: '/' |
52 | - }); | ||
53 | - } | 54 | + }; |
54 | 55 | ||
56 | + expires && (options.expires = new Date(Date.now() + Number(expires))); | ||
57 | + | ||
58 | + if (req.yoho.isWechat) { | ||
59 | + // 微信中,不管是否已经种入cookie,直接覆盖 | ||
60 | + res.cookie('mkt_code', mktCode, options); | ||
61 | + } else if (!req.cookies.mkt_code) { | ||
62 | + // 如果没有种入mtk_code则种入 | ||
63 | + res.cookie('mkt_code', mktCode, options); | ||
64 | + } | ||
65 | + } | ||
55 | res.json({mktCode: mktCode}); | 66 | res.json({mktCode: mktCode}); |
56 | }; | 67 | }; |
apps/activity/models/individuation.js
0 → 100644
1 | +const api = global.yoho.API; | ||
2 | + | ||
3 | +module.exports = { | ||
4 | + productLst: function(params) { | ||
5 | + return api.get('', Object.assign({ | ||
6 | + method: 'web.search.newPromotion' | ||
7 | + }, params)).then(res => { | ||
8 | + var data = [], | ||
9 | + lst = (res.data && res.data.product_list) || []; | ||
10 | + | ||
11 | + lst.forEach(function(o) { | ||
12 | + data.push({ | ||
13 | + brand_domain: o.brand_domain, | ||
14 | + brand_name: o.brand_name, | ||
15 | + product_id: o.product_id, | ||
16 | + product_name: o.product_name, | ||
17 | + product_skn: o.product_skn, | ||
18 | + market_price: o.market_price, | ||
19 | + sales_price: o.sales_price, | ||
20 | + cn_alphabet: o.cn_alphabet, | ||
21 | + default_images: o.default_images, | ||
22 | + goods_id: Array.isArray(o.goods_list) && o.goods_list.length ? o.goods_list[0].goods_id : '' | ||
23 | + }); | ||
24 | + }); | ||
25 | + | ||
26 | + return data; | ||
27 | + }); | ||
28 | + } | ||
29 | +}; |
@@ -28,6 +28,7 @@ const singleDay = require(`${cRoot}/single-day`); | @@ -28,6 +28,7 @@ const singleDay = require(`${cRoot}/single-day`); | ||
28 | const share = require(`${cRoot}/share`); | 28 | const share = require(`${cRoot}/share`); |
29 | const aliCloud = require(`${cRoot}/ali-cloud`); | 29 | const aliCloud = require(`${cRoot}/ali-cloud`); |
30 | const studentMarket = require(`${cRoot}/student-market`); | 30 | const studentMarket = require(`${cRoot}/student-market`); |
31 | +const individuation = require(`${cRoot}/individuation`); | ||
31 | 32 | ||
32 | const redbag = require(`${cRoot}/redbag`); | 33 | const redbag = require(`${cRoot}/redbag`); |
33 | 34 | ||
@@ -132,4 +133,7 @@ router.get('/student-market', student.getUser, studentMarket.index); | @@ -132,4 +133,7 @@ router.get('/student-market', student.getUser, studentMarket.index); | ||
132 | 133 | ||
133 | router.get('/redbag/2017', redbag.index); | 134 | router.get('/redbag/2017', redbag.index); |
134 | 135 | ||
136 | +// 获取活动页面个性化推荐商品数据 | ||
137 | +router.get('/individuation', individuation.productLst); | ||
138 | + | ||
135 | module.exports = router; | 139 | module.exports = router; |
-
Please register or login to post a comment