...
|
...
|
@@ -4,6 +4,7 @@ |
|
|
* @date: 2016/07/21
|
|
|
*/
|
|
|
'use strict';
|
|
|
const utils = '../../../utils';
|
|
|
const logger = global.yoho.logger;
|
|
|
const crypto = global.yoho.crypto;
|
|
|
const camelCase = global.yoho.camelCase;
|
...
|
...
|
@@ -11,6 +12,7 @@ const _ = require('lodash'); |
|
|
const helpers = global.yoho.helpers;
|
|
|
const api = global.yoho.API;
|
|
|
const searchModel = require('./search');
|
|
|
const productProcess = require(`${utils}/product-process`);
|
|
|
|
|
|
/**
|
|
|
* 频道
|
...
|
...
|
@@ -222,13 +224,28 @@ const getShopBrands = (shopId) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 通过 skn 搜索商品
|
|
|
* @param productSkn
|
|
|
* @returns {*|Promise.<TResult>}
|
|
|
* @private
|
|
|
*/
|
|
|
const searchProductBySkn = (productSkn) => {
|
|
|
return api.get('', {
|
|
|
method: 'h5.product.batch',
|
|
|
productSkn: productSkn,
|
|
|
}).then(result => {
|
|
|
return _.get(result, 'data.product_list', []);
|
|
|
});
|
|
|
};
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 组织店铺页面数据
|
|
|
* @param {array} data 接口返回的店铺页所需数据
|
|
|
* @param {int} shopId 店铺id
|
|
|
* @param {int} isApp app版本
|
|
|
* @return array
|
|
|
* @return {shopId: int, appVersion: int}
|
|
|
*/
|
|
|
const _formShopData = (data, shopId, isApp) => {
|
|
|
let formatData = {
|
...
|
...
|
@@ -350,25 +367,13 @@ const _formShopData = (data, shopId, isApp) => { |
|
|
|
|
|
// 人气单品
|
|
|
if (floor.hotProductsApp) {
|
|
|
let goods = [];
|
|
|
|
|
|
_.forEach(resData, (item) => {
|
|
|
let url = '//item.yohobuy.com/product/pro_';
|
|
|
let productSkn = '';
|
|
|
|
|
|
if (!item.cnAlphabet) {
|
|
|
item.cnAlphabet = 'goods.html';
|
|
|
}
|
|
|
url += item.productId + '_' + item.goodsId + '/' + item.cnAlphabet + '.html';
|
|
|
goods.push({
|
|
|
url: url + (isApp ? `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":${item.productSkn}}}` : ''),//eslint-disable-line
|
|
|
img: helpers.image(item.src, 235, 314),
|
|
|
productName: item.productName,
|
|
|
salesPrice: item.salesPrice,
|
|
|
presentPrice: item.salesPrice
|
|
|
});
|
|
|
_.forEach(resData, value => {
|
|
|
productSkn += value.productSkn + ',';
|
|
|
});
|
|
|
|
|
|
formatData.hotList = goods;
|
|
|
formatData.hotListproductSkn = productSkn;
|
|
|
}
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -527,12 +532,7 @@ const getShopData = (req, shopId, uid, isApp) => { |
|
|
|
|
|
return Promise.all([
|
|
|
_getShopDecorator(shopId),
|
|
|
searchModel.getFilterData({
|
|
|
shop_id: shopId,
|
|
|
gender: req.query.gender || '1,3',
|
|
|
channel: channel
|
|
|
}),
|
|
|
searchModel.getSearchData({
|
|
|
searchModel.getFilterSearchData({
|
|
|
shop_id: shopId,
|
|
|
gender: req.query.gender || '1,3',
|
|
|
channel: channel
|
...
|
...
|
@@ -544,8 +544,19 @@ const getShopData = (req, shopId, uid, isApp) => { |
|
|
shopInfo: shopInfoResult // 店铺信息
|
|
|
};
|
|
|
|
|
|
/* 获取一次分类和商品数据 */
|
|
|
let shopFilterSearchData = {
|
|
|
filter: [],
|
|
|
goods: []
|
|
|
};
|
|
|
|
|
|
if (result[1]) {
|
|
|
shopFilterSearchData.filter = productProcess.processFilter(result[1].filter || []);
|
|
|
shopFilterSearchData.goods = productProcess.processProductList(result[1].product_list || []);
|
|
|
}
|
|
|
|
|
|
/* 店鋪優惠券 */
|
|
|
let shopCoupons = result[3] || [];
|
|
|
let shopCoupons = result[2] || [];
|
|
|
|
|
|
// 店铺分类
|
|
|
return _getShopCategory(shopId, channel).then((shopCategory) => {
|
...
|
...
|
@@ -554,14 +565,16 @@ const getShopData = (req, shopId, uid, isApp) => { |
|
|
}, shopData);
|
|
|
|
|
|
// noinspection JSCheckFunctionSignatures
|
|
|
return Object.assign(_formShopData(shopData, shopId, isApp), {
|
|
|
filter: result[1],
|
|
|
goods: result[2],
|
|
|
return Object.assign(
|
|
|
_formShopData(shopData, shopId, isApp),
|
|
|
shopFilterSearchData,
|
|
|
{
|
|
|
shopId: shopId,
|
|
|
coverChannel: channel,
|
|
|
shopCoupons: shopCoupons,
|
|
|
shopCouponsOne: shopCoupons.length === 1
|
|
|
});
|
|
|
}
|
|
|
);
|
|
|
});
|
|
|
});
|
|
|
|
...
|
...
|
@@ -573,10 +586,9 @@ const getShopData = (req, shopId, uid, isApp) => { |
|
|
* @param req
|
|
|
* @param shopId
|
|
|
* @param uid
|
|
|
* @param isApp
|
|
|
* @returns {Promise.<TResult>|*}
|
|
|
*/
|
|
|
const getShopFav = (req, shopId, uid, isApp) => {
|
|
|
const getShopFav = (req, shopId, uid) => {
|
|
|
return _getShopInfo(shopId, uid).then(shopInfoResult => {
|
|
|
return shopInfoResult;
|
|
|
});
|
...
|
...
|
@@ -802,5 +814,6 @@ module.exports = { |
|
|
getShopBrands,
|
|
|
getShopCategory,
|
|
|
receiveCoupon,
|
|
|
getShopFav
|
|
|
getShopFav,
|
|
|
searchProductBySkn
|
|
|
}; |
...
|
...
|
|