Authored by 毕凯

个性化店铺接口调用

... ... @@ -109,3 +109,36 @@ exports.coupon = function(req, res, next) {
res.jsonp(result);
}).catch(next);
};
exports.shop = function(req, res, next) {
// let activity_template_id = req.query.activity_id;
let uid = req.user.uid || req.query.uid;
let app = req.query.app;
if (app && app.app_version && app.client_type && app.session_key && app.uid) {
uid = {
toString: () => {
return _.parseInt(app.uid);
},
sessionKey: app.session_key,
appVersion: app.app_version,
appSessionType: app.client_type
};
}
const params = Object.assign({
limit: 12,
yh_channel: (req.yoho.channel && channels[req.yoho.channel]) || '1',
imageType: req.query.displayStyle === '1' ? '1' : '2',
season: req.query.season || '1',
port: '1'
}, req.query.searchCondition);
if (uid && uid.toString()) {
params.uid = uid;
}
req.ctx(model).getShop(params).then((result) => {
res.jsonp(result);
}).catch(next);
};
... ...
... ... @@ -79,6 +79,14 @@ class individuationModel extends global.yoho.BaseModel {
param: {cache: true}
});
}
getShop(params) {
return this.get({
data: Object.assign({
method: 'app.search.shopRecommend.template'
}, params),
param: {cache: true}
});
}
}
... ...
... ... @@ -264,6 +264,7 @@ router.get('/redbag/2017', redbag.index);
// 获取活动页面个性化推荐商品数据
router.get('/individuation', individuation.productLst);
router.get('/individuation/coupon', individuation.coupon);
router.get('/individuation/shop', individuation.shop);
// 活动页模版
router.get('/feature/:code.html', feature.index);
... ...
... ... @@ -260,6 +260,36 @@ function persenalCouponInit() {
});
}
function shopGroupInit() {
$('.shop-individuation').each(function() {
const $this = $(this);
const config = $this.data('config');
config.activity_id = $('.feature-page').data('id');
if (yoho.isApp) {
config.app = {
uid: cookie.get('app_uid') || qs.uid,
app_version: cookie.get('app_version') || qs.app_version,
client_type: cookie.get('app_client_type') || qs.client_type,
session_key: cookie.get('app_session_key') || qs.session_key
};
}
$.ajax({
url: '//m.yohobuy.com/activity/individuation/shop',
data: config,
dataType: 'jsonp'
}).then(res => {
if (res && res.html) {
$this.replaceWith(res.html);
} else {
// $this.remove();
}
});
});
}
$(function() {
if ($('.over').length) {
// 过期/删除 状态的 活动
... ... @@ -309,6 +339,9 @@ $(function() {
// 个性化券查询
persenalCouponInit();
// 个性化店铺组
shopGroupInit();
// 小程序相关处理
if (window.__wxjs_environment === 'miniprogram') {
require('./miniprogram');
... ...