Authored by 沈志敏

增加union_type

'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: 'web.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;
... ...