...
|
...
|
@@ -2,7 +2,6 @@ |
|
|
const _ = require('lodash');
|
|
|
const api = global.yoho.API;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const logger = global.yoho.logger;
|
|
|
const yasProcess = require('../../../utils/yas-process');
|
|
|
|
|
|
const _getProductBySkns = function(productObj, ctx) {
|
...
|
...
|
@@ -39,67 +38,6 @@ const _getProductBySkns = function(productObj, ctx) { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* openbyStr 处理
|
|
|
*/
|
|
|
const _handleOpenbyParams = (openbyStr, ctx) => {
|
|
|
const paramsKeyStr = 'openby:yohobuy=';
|
|
|
|
|
|
let openByStrNew = '';
|
|
|
let openByParamObj = {};
|
|
|
|
|
|
if (_.isString(openbyStr)) {
|
|
|
openByStrNew = _.replace(openbyStr, paramsKeyStr, '');
|
|
|
} else {
|
|
|
return openbyStr;
|
|
|
}
|
|
|
|
|
|
if (_.isString(openByStrNew)) {
|
|
|
try {
|
|
|
openByParamObj = JSON.parse(openByStrNew);
|
|
|
} catch (error) {
|
|
|
logger.info(`openbyStr json parse err, raw string is ${openByStrNew}`);
|
|
|
}
|
|
|
} else {
|
|
|
return openbyStr;
|
|
|
}
|
|
|
|
|
|
if (!_.isEmpty(openByParamObj)) {
|
|
|
_.assign(openByParamObj, {
|
|
|
from_page_name: yasProcess.getPname(ctx.req),
|
|
|
from_page_param: _.get(ctx, 'req.url', '')
|
|
|
});
|
|
|
|
|
|
openByStrNew = `${paramsKeyStr}${JSON.stringify(openByParamObj)}`;
|
|
|
}
|
|
|
|
|
|
return openByStrNew;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 配置的商品添加参数
|
|
|
*/
|
|
|
const _imageGoodsAddParams = (href, ctx) => {
|
|
|
let finalHref = '';
|
|
|
let paramsSplitArr = href.split('?') || [];
|
|
|
let paramsArr = paramsSplitArr[1].split('&');
|
|
|
let paramsArrNew = [];
|
|
|
let paramsStrNew = '';
|
|
|
|
|
|
paramsArrNew = _.map(paramsArr, param => {
|
|
|
if (_.isString(param) && param.indexOf('openby:yohobuy=') !== -1) {
|
|
|
param = _handleOpenbyParams(param, ctx);
|
|
|
}
|
|
|
|
|
|
return param;
|
|
|
});
|
|
|
|
|
|
paramsStrNew = paramsArrNew.join('&');
|
|
|
finalHref = `${paramsSplitArr[0]}?${paramsStrNew}`;
|
|
|
|
|
|
return finalHref;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取店铺组店铺数据
|
|
|
*/
|
|
|
const _getShopGroup = (shopRawData) => {
|
...
|
...
|
@@ -183,7 +121,12 @@ class featureModel extends global.yoho.BaseModel { |
|
|
|
|
|
_.forEach(f.component, component => {
|
|
|
if (component.url && component.url.indexOf('go.productDetail') !== -1) {
|
|
|
component.url = _imageGoodsAddParams(component.url, self.ctx);
|
|
|
|
|
|
component.url = yasProcess.addParamsToGoodsHref({
|
|
|
href: component.url,
|
|
|
fromPageName: yasProcess.getPname(_.get(self, 'ctx.req', {})),
|
|
|
fromPageParam: _.get(self, 'ctx.req.path', '')
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (component.persenal_enable === '1') {
|
...
|
...
|
|