...
|
...
|
@@ -2,70 +2,73 @@ |
|
|
const _ = require('lodash');
|
|
|
const helpers = global.yoho.helpers;
|
|
|
|
|
|
const _getProductBySkns = function(productObj, extraParams) {
|
|
|
return this.get({
|
|
|
data: {
|
|
|
productSkn: productObj.defaultSkns,
|
|
|
method: 'h5.product.batch'
|
|
|
},
|
|
|
param: {
|
|
|
cache: true
|
|
|
}
|
|
|
}).then((result) => {
|
|
|
productObj.defaultPros = [];
|
|
|
if (result && result.data && result.data.product_list && result.code === 200) {
|
|
|
result.data.product_list.forEach(function(val) {
|
|
|
var obj = {
|
|
|
producturl: `//m.yohobuy.com/product/${val.product_skn}.html?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"${val.product_skn}","from_page_name":"${extraParams.from_page_name}","from_page_param":"${extraParams.from_page_param}"}}`, // eslint-disable-line
|
|
|
productimg: helpers.image(val.default_images, 213, 284, 2, 60).replace('quality/80', 'quality/60'),
|
|
|
productname: val.product_name,
|
|
|
vipprice: val.vip_price,
|
|
|
saleprice: val.sales_price,
|
|
|
marketprice: val.sales_price === val.market_price ? '' : val.market_price,
|
|
|
brandname: val.brand_name,
|
|
|
product_skn: val.product_skn
|
|
|
};
|
|
|
|
|
|
if (val.shop_id) {
|
|
|
obj.brandurl = `//m.yohobuy.com/product/shop?domain=${val.brand_domain}&openby:yohobuy={"action":"go.shop","params":{"shop_id":${val.shop_id},"shop_template_type":${val.shop_template_type || "1"},"is_red_shop":${val.is_red_shop || 1}}}`; // eslint-disable-line
|
|
|
} else {
|
|
|
obj.brandurl = `//m.yohobuy.com/product/shop?domain=${val.brand_domain}&openby:yohobuy={"action":"go.brand","params":{"brand_id":${val.brand_id}}}`; // eslint-disable-line
|
|
|
}
|
|
|
|
|
|
productObj.defaultPros.push(obj);
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取店铺组店铺数据
|
|
|
*/
|
|
|
const _getShopGroup = (shopRawData) => {
|
|
|
return this.get({
|
|
|
data: {
|
|
|
method: 'app.shops.batchGetShops',
|
|
|
shop_ids: shopRawData.defaultShopIds
|
|
|
}
|
|
|
}).then(result => {
|
|
|
let renderData = _.get(result, 'data', []);
|
|
|
class featureModel extends global.yoho.BaseModel {
|
|
|
constructor(ctx) {
|
|
|
super(ctx);
|
|
|
}
|
|
|
|
|
|
_.forEach(renderData, shop => {
|
|
|
let displayStyle = _.get(shopRawData, 'displayStyle', '0');
|
|
|
_getProductBySkns(productObj, extraParams) {
|
|
|
return this.get({
|
|
|
data: {
|
|
|
productSkn: productObj.defaultSkns,
|
|
|
method: 'h5.product.batch'
|
|
|
},
|
|
|
param: {
|
|
|
cache: true
|
|
|
}
|
|
|
}).then((result) => {
|
|
|
productObj.defaultPros = [];
|
|
|
if (result && result.data && result.data.product_list && result.code === 200) {
|
|
|
result.data.product_list.forEach(function(val) {
|
|
|
var obj = {
|
|
|
producturl: `//m.yohobuy.com/product/${val.product_skn}.html?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"${val.product_skn}","from_page_name":"${extraParams.from_page_name}","from_page_param":"${extraParams.from_page_param}"}}`, // eslint-disable-line
|
|
|
productimg: helpers.image(val.default_images, 213, 284, 2, 60).replace('quality/80', 'quality/60'), // eslint-disable-line
|
|
|
productname: val.product_name,
|
|
|
vipprice: val.vip_price,
|
|
|
saleprice: val.sales_price,
|
|
|
marketprice: val.sales_price === val.market_price ? '' : val.market_price,
|
|
|
brandname: val.brand_name,
|
|
|
product_skn: val.product_skn
|
|
|
};
|
|
|
|
|
|
if (val.shop_id) {
|
|
|
obj.brandurl = `//m.yohobuy.com/product/shop?domain=${val.brand_domain}&openby:yohobuy={"action":"go.shop","params":{"shop_id":${val.shop_id},"shop_template_type":${val.shop_template_type || "1"},"is_red_shop":${val.is_red_shop || 1}}}`; // eslint-disable-line
|
|
|
} else {
|
|
|
obj.brandurl = `//m.yohobuy.com/product/shop?domain=${val.brand_domain}&openby:yohobuy={"action":"go.brand","params":{"brand_id":${val.brand_id}}}`; // eslint-disable-line
|
|
|
}
|
|
|
|
|
|
shop.picture = displayStyle === '0' ? shop.pic_popular : shop.shop_logo;
|
|
|
shop.href = `//m.yohobuy.com/product/shop?domain=${shop.shop_domain}&openby:yohobuy={"action":"go.shop","params":{"shop_id":${shop.shops_id},"shop_template_type":${shop.shop_template_type || "1"},"is_red_shop":${shop.is_red_shop || 1}}}`; // eslint-disable-line
|
|
|
productObj.defaultPros.push(obj);
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
shopRawData.renderData = renderData;
|
|
|
});
|
|
|
};
|
|
|
/**
|
|
|
* 获取店铺组店铺数据
|
|
|
*/
|
|
|
_getShopGroup(shopRawData) {
|
|
|
return this.get({
|
|
|
data: {
|
|
|
method: 'app.shops.batchGetShops',
|
|
|
shop_ids: shopRawData.defaultShopIds
|
|
|
}
|
|
|
}).then(result => {
|
|
|
let renderData = _.get(result, 'data', []);
|
|
|
|
|
|
class featureModel extends global.yoho.BaseModel {
|
|
|
constructor(ctx) {
|
|
|
super(ctx);
|
|
|
_.forEach(renderData, shop => {
|
|
|
let displayStyle = _.get(shopRawData, 'displayStyle', '0');
|
|
|
|
|
|
shop.picture = displayStyle === '0' ? shop.pic_popular : shop.shop_logo;
|
|
|
shop.href = `//m.yohobuy.com/product/shop?domain=${shop.shop_domain}&openby:yohobuy={"action":"go.shop","params":{"shop_id":${shop.shops_id},"shop_template_type":${shop.shop_template_type || "1"},"is_red_shop":${shop.is_red_shop || 1}}}`; // eslint-disable-line
|
|
|
});
|
|
|
|
|
|
shopRawData.renderData = renderData;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
index(params) {
|
|
|
let that = this;
|
|
|
|
|
|
return Promise.coroutine(function*() {
|
|
|
if (!params.code) {
|
|
|
return Promise.resolve({});
|
...
|
...
|
@@ -76,7 +79,7 @@ class featureModel extends global.yoho.BaseModel { |
|
|
let shopGroups = [];
|
|
|
|
|
|
if (params.type === 'preview') { // 开发/预览模式
|
|
|
data = yield this.get({
|
|
|
data = yield that.get({
|
|
|
data: {
|
|
|
method: 'app.activity.template.ignoreCache',
|
|
|
activity_id: params.code
|
...
|
...
|
@@ -87,7 +90,7 @@ class featureModel extends global.yoho.BaseModel { |
|
|
});
|
|
|
} else {
|
|
|
// 生产模式
|
|
|
data = yield this.get({
|
|
|
data = yield that.get({
|
|
|
data: {
|
|
|
method: 'app.activity.template',
|
|
|
activity_id: params.code
|
...
|
...
|
@@ -105,7 +108,7 @@ class featureModel extends global.yoho.BaseModel { |
|
|
data.floors.forEach(function(f) {
|
|
|
if (f.component && f.component[0] &&
|
|
|
f.component[0].type === 'productGroup' && f.component[0].defaultSkns) {
|
|
|
sknsArr.push(_getProductBySkns(f.component[0], {
|
|
|
sknsArr.push(that._getProductBySkns(f.component[0], {
|
|
|
from_page_name: params.from_page_name,
|
|
|
from_page_param: params.from_page_param
|
|
|
}));
|
...
|
...
|
@@ -125,7 +128,7 @@ class featureModel extends global.yoho.BaseModel { |
|
|
|
|
|
// 新增店铺组
|
|
|
if (_.get(f, 'component[0].type') === 'shopGroup') {
|
|
|
shopGroups.push(_getShopGroup(f.component[0]));
|
|
|
shopGroups.push(that._getShopGroup(f.component[0]));
|
|
|
}
|
|
|
|
|
|
if (_.get(f, 'type') === 'bottombar') {
|
...
|
...
|
|