Authored by 郭成尧

'shopid'

@@ -12,6 +12,43 @@ const _ = require('lodash'); @@ -12,6 +12,43 @@ const _ = require('lodash');
12 const helpers = global.yoho.helpers; 12 const helpers = global.yoho.helpers;
13 13
14 /** 14 /**
  15 + * 销售类目链接拼接 APP
  16 + * @param origin
  17 + * @param shopId
  18 + * @private
  19 + */
  20 +const _modifyWapUrl = (origin, shopId) => {
  21 + if (parseInt(_.get(origin, 'linkType', 0), 10) === 1) {
  22 + return helpers.urlFormat('', {filter_poolId: origin.categoryId, shop_id: shopId, title: origin.categoryName}, 'search'); //eslint-disable-line
  23 + } else {
  24 + if (_.has(origin, 'url')) {
  25 + return origin.url;
  26 + } else {
  27 + return '';
  28 + }
  29 + }
  30 +};
  31 +
  32 +/**
  33 + * 销售类目链接拼接 APP
  34 + * @param origin
  35 + * @param shopId
  36 + * @private
  37 + */
  38 +const _modifyAppUrl = (origin, shopId) => {
  39 + if (parseInt(_.get(origin, 'linkType', 0), 10) === 1) {
  40 + return helpers.urlFormat('/search/list', {filter_poolId: origin.categoryId}) +
  41 + `?openby:yohobuy={"action":"go.poollist","params":{"shop_id":"${shopId}","title":"${origin.categoryName}","productPool":"${origin.categoryId}"}}`; //eslint-disable-line
  42 + } else {
  43 + if (_.has(origin, 'url')) {
  44 + return origin.url;
  45 + } else {
  46 + return '';
  47 + }
  48 + }
  49 +};
  50 +
  51 +/**
15 * 组织店铺页面数据 52 * 组织店铺页面数据
16 * @param {array} data 接口返回的店铺页所需数据 53 * @param {array} data 接口返回的店铺页所需数据
17 * @param {int} shopId 店铺id 54 * @param {int} shopId 店铺id
@@ -45,7 +82,7 @@ const _formShopData = (data, shopId, isApp) => { @@ -45,7 +82,7 @@ const _formShopData = (data, shopId, isApp) => {
45 _.forEach(resData, (item) => { 82 _.forEach(resData, (item) => {
46 if (item.data) { 83 if (item.data) {
47 spring.push({ 84 spring.push({
48 - url: item.data[0].url, 85 + url: isApp ? _modifyAppUrl(item.data[0], shopId) : _modifyWapUrl(item.data[0], shopId),
49 springType: helpers.image(item.data[0].src) 86 springType: helpers.image(item.data[0].src)
50 }); 87 });
51 } 88 }
@@ -100,7 +137,7 @@ const _formShopData = (data, shopId, isApp) => { @@ -100,7 +137,7 @@ const _formShopData = (data, shopId, isApp) => {
100 _.forEach(resData, (item) => { 137 _.forEach(resData, (item) => {
101 if (item.data[0]) { 138 if (item.data[0]) {
102 bannerTop.data.push({ 139 bannerTop.data.push({
103 - url: item.data[0].url, 140 + url: isApp ? _modifyAppUrl(item.data[0], shopId) : _modifyWapUrl(item.data[0], shopId),
104 src: item.data[0].src 141 src: item.data[0].src
105 }); 142 });
106 } 143 }