Authored by 郭成尧

'shopid'

... ... @@ -12,6 +12,43 @@ const _ = require('lodash');
const helpers = global.yoho.helpers;
/**
* 销售类目链接拼接 APP
* @param origin
* @param shopId
* @private
*/
const _modifyWapUrl = (origin, shopId) => {
if (parseInt(_.get(origin, 'linkType', 0), 10) === 1) {
return helpers.urlFormat('', {filter_poolId: origin.categoryId, shop_id: shopId, title: origin.categoryName}, 'search'); //eslint-disable-line
} else {
if (_.has(origin, 'url')) {
return origin.url;
} else {
return '';
}
}
};
/**
* 销售类目链接拼接 APP
* @param origin
* @param shopId
* @private
*/
const _modifyAppUrl = (origin, shopId) => {
if (parseInt(_.get(origin, 'linkType', 0), 10) === 1) {
return helpers.urlFormat('/search/list', {filter_poolId: origin.categoryId}) +
`?openby:yohobuy={"action":"go.poollist","params":{"shop_id":"${shopId}","title":"${origin.categoryName}","productPool":"${origin.categoryId}"}}`; //eslint-disable-line
} else {
if (_.has(origin, 'url')) {
return origin.url;
} else {
return '';
}
}
};
/**
* 组织店铺页面数据
* @param {array} data 接口返回的店铺页所需数据
* @param {int} shopId 店铺id
... ... @@ -45,7 +82,7 @@ const _formShopData = (data, shopId, isApp) => {
_.forEach(resData, (item) => {
if (item.data) {
spring.push({
url: item.data[0].url,
url: isApp ? _modifyAppUrl(item.data[0], shopId) : _modifyWapUrl(item.data[0], shopId),
springType: helpers.image(item.data[0].src)
});
}
... ... @@ -100,7 +137,7 @@ const _formShopData = (data, shopId, isApp) => {
_.forEach(resData, (item) => {
if (item.data[0]) {
bannerTop.data.push({
url: item.data[0].url,
url: isApp ? _modifyAppUrl(item.data[0], shopId) : _modifyWapUrl(item.data[0], shopId),
src: item.data[0].src
});
}
... ...