Merge branch 'gray'
Showing
8 changed files
with
110 additions
and
19 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: 'app.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; |
@@ -20,7 +20,7 @@ const list = (req, res, next) => { | @@ -20,7 +20,7 @@ const list = (req, res, next) => { | ||
20 | cartUrl: helpers.urlFormat('/cart/index/index') | 20 | cartUrl: helpers.urlFormat('/cart/index/index') |
21 | }, req.query); | 21 | }, req.query); |
22 | let title = ''; | 22 | let title = ''; |
23 | - let query = req.query.query; | 23 | + let query = decodeURIComponent(req.query.query); |
24 | let isQueryFirstClass = false; // 标识用户搜的是不是一级品类 | 24 | let isQueryFirstClass = false; // 标识用户搜的是不是一级品类 |
25 | let isQuerySecondClass = false; // 标识用户搜的是不是二级品类 | 25 | let isQuerySecondClass = false; // 标识用户搜的是不是二级品类 |
26 | let domain = null; | 26 | let domain = null; |
@@ -12,7 +12,9 @@ | @@ -12,7 +12,9 @@ | ||
12 | a.async = 1; | 12 | a.async = 1; |
13 | a.src = j; | 13 | a.src = j; |
14 | m.parentNode.insertBefore(a, m); | 14 | m.parentNode.insertBefore(a, m); |
15 | - }(window, document, 'script', (document.location.protocol === 'https:' ? 'https' : 'http') + '://cdn.yoho.cn/yas-jssdk/2.0.0/yas.js', '_yas')); | 15 | + }(window, document, 'script', (document.location.protocol === 'https:' ? 'https:' : 'http:') + '//cdn.yoho.cn/yas-jssdk/2.1.0/yas.js', '_yas')); |
16 | + | ||
17 | + var _hmt = _hmt || []; | ||
16 | 18 | ||
17 | (function() { | 19 | (function() { |
18 | function getUid() { | 20 | function getUid() { |
@@ -37,14 +39,13 @@ | @@ -37,14 +39,13 @@ | ||
37 | } | 39 | } |
38 | 40 | ||
39 | function queryString() { | 41 | function queryString() { |
40 | - var vars = [], | 42 | + var vars = {}, |
41 | hash, | 43 | hash, |
42 | i; | 44 | i; |
43 | var hashes = window.location.search.slice(1).split('&'); | 45 | var hashes = window.location.search.slice(1).split('&'); |
44 | 46 | ||
45 | for (i = 0; i < hashes.length; i++) { | 47 | for (i = 0; i < hashes.length; i++) { |
46 | hash = hashes[i].split('='); | 48 | hash = hashes[i].split('='); |
47 | - vars.push(hash[0]); | ||
48 | vars[hash[0]] = hash[1]; | 49 | vars[hash[0]] = hash[1]; |
49 | } | 50 | } |
50 | return vars; | 51 | return vars; |
@@ -55,7 +56,23 @@ | @@ -55,7 +56,23 @@ | ||
55 | uid = uid === 0 ? '' : uid; | 56 | uid = uid === 0 ? '' : uid; |
56 | window._ozuid = uid; // 暴露ozuid | 57 | window._ozuid = uid; // 暴露ozuid |
57 | if (window._yas) { | 58 | if (window._yas) { |
58 | - window._yas(1 * new Date(), '2.0.0', 'yohobuy_m', uid, '', ''); | 59 | + window._yas(1 * new Date(), '2.1.0', 'yohobuy_m', uid, '', ''); |
60 | + } | ||
61 | + | ||
62 | + // 非登录状态,加载百度统计 | ||
63 | + if (!uid) { | ||
64 | + (function() { | ||
65 | + var hm = document.createElement("script"); | ||
66 | + hm.src = "https://hm.baidu.com/hm.js?65dd99e0435a55177ffda862198ce841"; | ||
67 | + var s = document.getElementsByTagName("script")[0]; | ||
68 | + s.parentNode.insertBefore(hm, s); | ||
69 | + })(); | ||
70 | + (function() { | ||
71 | + var hm = document.createElement("script"); | ||
72 | + hm.src = "https://hm.baidu.com/hm.js?e5b83a487a4458aa5abca43f5779b764"; | ||
73 | + var s = document.getElementsByTagName("script")[0]; | ||
74 | + s.parentNode.insertBefore(hm, s); | ||
75 | + })(); | ||
59 | } | 76 | } |
60 | }()); | 77 | }()); |
61 | </script> | 78 | </script> |
@@ -71,8 +71,9 @@ chHammer.on('tap', function() { | @@ -71,8 +71,9 @@ chHammer.on('tap', function() { | ||
71 | // 跳到搜索页 | 71 | // 跳到搜索页 |
72 | function goSearch(query) { | 72 | function goSearch(query) { |
73 | // 保存搜索的内容 | 73 | // 保存搜索的内容 |
74 | + | ||
74 | writeSearch.setHistoryValFun(query); | 75 | writeSearch.setHistoryValFun(query); |
75 | - document.location.href = searchUrl + '?query=' + query; | 76 | + document.location.href = searchUrl + '?query=' + encodeURIComponent(query); |
76 | } | 77 | } |
77 | 78 | ||
78 | // 搜索输入联动 | 79 | // 搜索输入联动 |
@@ -175,11 +176,11 @@ $('.search-items .search-group').on('click', 'li', function(event) { | @@ -175,11 +176,11 @@ $('.search-items .search-group').on('click', 'li', function(event) { | ||
175 | var query = ''; | 176 | var query = ''; |
176 | 177 | ||
177 | if (event.target.nodeName === 'A') { | 178 | if (event.target.nodeName === 'A') { |
178 | - query = $(event.target).html(); | 179 | + query = $(event.target).text(); |
179 | } | 180 | } |
180 | 181 | ||
181 | if (event.target.nodeName === 'LI') { | 182 | if (event.target.nodeName === 'LI') { |
182 | - query = $(event.target).find('a').html(); | 183 | + query = $(event.target).find('a').text(); |
183 | } | 184 | } |
184 | 185 | ||
185 | if ($(this).parents('.search-group').hasClass('history-search')) { | 186 | if ($(this).parents('.search-group').hasClass('history-search')) { |
@@ -210,8 +211,8 @@ $('.search-items .search-group').on('click', 'li', function(event) { | @@ -210,8 +211,8 @@ $('.search-items .search-group').on('click', 'li', function(event) { | ||
210 | }); | 211 | }); |
211 | 212 | ||
212 | $('.hot-term').on('click', function(event) { | 213 | $('.hot-term').on('click', function(event) { |
213 | - var Hotquery = '', | ||
214 | - POS_ID = 2, | 214 | + var Hotquery = ''; |
215 | + POS_ID = 2; | ||
215 | FLR_INDEX = 2; | 216 | FLR_INDEX = 2; |
216 | 217 | ||
217 | if (event.target.nodeName === 'A') { | 218 | if (event.target.nodeName === 'A') { |
-
Please register or login to post a comment