Authored by ccbikai(👎🏻🍜)

Merge remote-tracking branch 'origin/hotfix/unionType' into gray

'use strict';
const model = require('../models/individuation');
exports.productLst = function(req, res, next) {
let params = {
uid: req.query.uid,
udid: req.query.udid,
pid: req.query.pid
};
if (req.query.sort) {
params.sort = req.query.sort;
} else if (req.query.brand) {
params.brand = req.query.brand;
}
if (req.query.enum) {
params.specified_sort = req.query.enum;
}
if (req.query.limit) {
params.limit = req.query.limit;
}
model.productLst(params).then((result) => {
res.jsonp(result);
}).catch(next);
};
\ No newline at end of file
... ...
... ... @@ -39,18 +39,29 @@ exports.wechatShare = (req, res, next) => {
// 活动页保存相应cookie的值
exports.feature = (req, res) => {
let mktCode = req.query.mkt_code || false;
// 下载浮层,下载按钮会用到该参数
let mktCode = req.query.mkt_code || req.query.union_type || false;
let expires = req.query.expires;
if (mktCode) {
res.cookie('mkt_code', mktCode, {
domain: '.yohobuy.com',
res.cookie('unionTypeYas', mktCode, { // 下载浮层
path: '/'
});
res.cookie('unionTypeYas', mktCode, {
// 下单使用
let options = {
domain: '.yohobuy.com',
path: '/'
});
}
};
expires && (options.expires = new Date(Date.now() + Number(expires)));
if (req.yoho.isWechat) {
// 微信中,不管是否已经种入cookie,直接覆盖
res.cookie('mkt_code', mktCode, options);
} else if (!req.cookies.mkt_code) {
// 如果没有种入mtk_code则种入
res.cookie('mkt_code', mktCode, options);
}
}
res.json({mktCode: mktCode});
};
... ...
const api = global.yoho.API;
module.exports = {
productLst: function(params) {
return api.get('', Object.assign({
method: 'app.search.newPromotion'
}, params)).then(res => {
var data = [],
lst = (res.data && res.data.product_list) || [];
lst.forEach(function(o) {
data.push({
brand_domain: o.brand_domain,
brand_name: o.brand_name,
product_id: o.product_id,
product_name: o.product_name,
product_skn: o.product_skn,
market_price: o.market_price,
sales_price: o.sales_price,
cn_alphabet: o.cn_alphabet,
default_images: o.default_images,
goods_id: Array.isArray(o.goods_list) && o.goods_list.length ? o.goods_list[0].goods_id : ''
});
});
return data;
});
}
};
\ No newline at end of file
... ...
... ... @@ -28,6 +28,7 @@ const singleDay = require(`${cRoot}/single-day`);
const share = require(`${cRoot}/share`);
const aliCloud = require(`${cRoot}/ali-cloud`);
const studentMarket = require(`${cRoot}/student-market`);
const individuation = require(`${cRoot}/individuation`);
const redbag = require(`${cRoot}/redbag`);
... ... @@ -132,4 +133,7 @@ router.get('/student-market', student.getUser, studentMarket.index);
router.get('/redbag/2017', redbag.index);
// 获取活动页面个性化推荐商品数据
router.get('/individuation', individuation.productLst);
module.exports = router;
... ...
... ... @@ -12,7 +12,7 @@
a.async = 1;
a.src = j;
m.parentNode.insertBefore(a, m);
}(window, document, 'script', (document.location.protocol === 'https:' ? 'https' : 'http') + '://cdn.yoho.cn/yas-jssdk/2.0.0/yas.js', '_yas'));
}(window, document, 'script', (document.location.protocol === 'https:' ? 'https:' : 'http:') + '//cdn.yoho.cn/yas-jssdk/2.1.0/yas.js', '_yas'));
(function() {
function getUid() {
... ... @@ -37,14 +37,13 @@
}
function queryString() {
var vars = [],
var vars = {},
hash,
i;
var hashes = window.location.search.slice(1).split('&');
for (i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
... ... @@ -55,7 +54,7 @@
uid = uid === 0 ? '' : uid;
window._ozuid = uid; // 暴露ozuid
if (window._yas) {
window._yas(1 * new Date(), '2.0.0', 'yohobuy_m', uid, '', '');
window._yas(1 * new Date(), '2.1.0', 'yohobuy_m', uid, '', '');
}
}());
</script>
... ...