...
|
...
|
@@ -7,32 +7,159 @@ |
|
|
'use strict';
|
|
|
const mRoot = '../models';
|
|
|
const headerModel = require('../../../doraemon/models/header');
|
|
|
//const resourcesProcess = require(`${utils}/resources-process`);
|
|
|
const searchModel = require(`${mRoot}/search`);
|
|
|
const _ = require('lodash');
|
|
|
const helpers = global.yoho.helpers;
|
|
|
|
|
|
//const _processShopInfo = (list) => {
|
|
|
// let formatData = {
|
|
|
// logoImg: helpers.image(list.shopLogo, 500, 500),
|
|
|
// storeName: (list.isShowShopName === 'Y') ? list.shopName : '',
|
|
|
// collect: (list.isFavorite === 'Y') ? true : false
|
|
|
// };
|
|
|
//
|
|
|
// let allGoodsParam = {
|
|
|
// title: '全部商品'
|
|
|
// }
|
|
|
//
|
|
|
// return {};
|
|
|
//};
|
|
|
|
|
|
/**
|
|
|
* 组织店铺页面数据
|
|
|
* @param {array} data 接口返回的店铺页所需数据
|
|
|
* @param {int} shopId 店铺id
|
|
|
* @param {int} isApp app版本
|
|
|
* @return array
|
|
|
*/
|
|
|
const _formShopData = (data, shopId, isApp) => {
|
|
|
let formatData = {},
|
|
|
single = false,
|
|
|
shopIdObj = {
|
|
|
shop_id: shopId
|
|
|
};
|
|
|
let brandId;
|
|
|
|
|
|
//signboard
|
|
|
//oneRowTwoColImages
|
|
|
//allHotProducts
|
|
|
//shopTopBanner
|
|
|
//brandBrowse
|
|
|
//recommend
|
|
|
//shopTopBannerApp
|
|
|
//hotRecommend
|
|
|
//oneRowTwoColImagesApp
|
|
|
//recommendApp
|
|
|
//navigationBar
|
|
|
//newProducts
|
|
|
//goodsTabBar
|
|
|
//hotProductsApp
|
|
|
//largeSlideImg
|
|
|
//shopTopBannerBase
|
|
|
//hotProducts
|
|
|
//largeSlideImgApp
|
|
|
//allNewProducts
|
|
|
//allHotProductsApp
|
|
|
|
|
|
|
|
|
// 组织店铺装修
|
|
|
if (data.decorator) {
|
|
|
_.forEach(data.decorator.list, (floor) => {
|
|
|
floor[_.camelCase(floor.resourceName)] = true;
|
|
|
|
|
|
// 店铺banner
|
|
|
if (floor.shopTopBannerApp) {
|
|
|
formatData.branerImg = helpers.image(JSON.parse(floor.resourceData)[0].shopSrc, 640, 200, 1);
|
|
|
}
|
|
|
|
|
|
// 资源位小图 接口返回两组,取每组第一张
|
|
|
if (floor.oneRowTwoColImagesApp) {
|
|
|
let jsonData = JSON.parse(floor.resourceData);
|
|
|
_.forEach(jsonData, (key, item) => {
|
|
|
if (key === 0 && item.data) {
|
|
|
formatData.spring = {
|
|
|
url: item.data.url,
|
|
|
springType: helpers.image(item.data.src)
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 店铺品牌一览
|
|
|
if (floor.brandBrowse) {
|
|
|
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 店铺基本信息
|
|
|
if (data.shopInfo) {
|
|
|
let allGoodsParam = {
|
|
|
title: '全部商品'
|
|
|
};
|
|
|
|
|
|
formatData = {
|
|
|
logoImg: helpers.image(data.shopInfo.shopLogo, 500, 500),
|
|
|
storeName: (data.shopInfo.isShowShopName === 'Y') ? list.shopName : '',
|
|
|
collect: (data.shopInfo.isFavorite === 'Y') ? true : false,
|
|
|
url: helpers.urlFormat('', shopIdObj, 'search'), // 搜索链接
|
|
|
more_url: helpers.urlFormat('', {
|
|
|
shop_id: shopId,
|
|
|
order: 's_n_d',
|
|
|
title: '人气单品'
|
|
|
}, 'search') // 人气单品的链接
|
|
|
};
|
|
|
|
|
|
if (single) { // 单品点
|
|
|
allGoodsParam.brand = brandId;
|
|
|
} else { // 店铺id
|
|
|
formatData.shopId = shopId;
|
|
|
allGoodsParam.shopId = shopId;
|
|
|
}
|
|
|
|
|
|
if (!isApp) {
|
|
|
_.assign({
|
|
|
allGoods: helpers.urlFormat('', allGoodsParam, 'search'),
|
|
|
shopIntroHref: helpers.urlFormat('/product/index/intro', shopIdObj) // 店铺简介页地址
|
|
|
}, formatData);
|
|
|
} else {
|
|
|
_.assign({
|
|
|
allGoods: `${helpers.urlFormat('', allGoodsParam, 'search')}&openby:yohobuy={"action":"go.list","params":{"title":"全部商品", "actiontype":"0","shop_id":"' . self::$shopId . '","page":"1"}}`,
|
|
|
shopIntroHref: helpers.urlFormat('/product/index/intro', {
|
|
|
shop_id: shopId,
|
|
|
app_version: isApp
|
|
|
}),
|
|
|
more_url: `openby:yohobuy={"action":"go.list","params":{"shop_id":${shopId},"title":"人气单品"}}`
|
|
|
}, formatData);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return formatData;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 新店铺首页
|
|
|
* @param {object} req
|
|
|
* @param {int} shopId 店铺id
|
|
|
* @param {int} uid 用户id
|
|
|
* @param {string} isApp app版本
|
|
|
* @return array
|
|
|
*/
|
|
|
const _getShopData = (shopId, uid, isApp) => {
|
|
|
const _getShopData = (req, shopId, uid, isApp) => {
|
|
|
let data = {};
|
|
|
let channel = req.yoho.channel;
|
|
|
isApp = isApp || '';
|
|
|
|
|
|
Promise.all([searchModel.getShopDecorator(shopId),searchModel.getShopInfo(shopId, uid)]).then((result) => {
|
|
|
return Promise.all([searchModel.getShopDecorator(shopId), searchModel.getShopInfo(shopId, uid)]).then((result) => {
|
|
|
data = {
|
|
|
decorator: result[0], // 店铺装修资源数据
|
|
|
shopInfo: result[1] // 店铺信息
|
|
|
};
|
|
|
|
|
|
// 店铺使用基础模板,返回品牌页面
|
|
|
if (data.shopInfo.data.shopTemplateType && data.shopInfo.data.shopTemplateType ===1) {
|
|
|
if (data.shopInfo.shopTemplateType && data.shopInfo.shopTemplateType === '1') {
|
|
|
return {
|
|
|
goBrand: data.shopInfo.data
|
|
|
goBrand: data.shopInfo
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -43,7 +170,7 @@ const _getShopData = (shopId, uid, isApp) => { |
|
|
shopCategory: shopCategory
|
|
|
}, data);
|
|
|
|
|
|
return searchModel.formShopData(data, shopId, isApp); // 组织楼层数据
|
|
|
return _formShopData(data, shopId, isApp); // 组织楼层数据
|
|
|
});
|
|
|
};
|
|
|
|
...
|
...
|
@@ -70,13 +197,13 @@ const _shop = (req, res, shopId) => { |
|
|
});
|
|
|
}
|
|
|
|
|
|
_getShopData(shopId, uid, isApp).then((result) => {
|
|
|
_getShopData(req, shopId, uid, isApp).then((result) => {
|
|
|
if (result.goBrand) {
|
|
|
// 跳转基础模板
|
|
|
_baseShop(result.goBrand);
|
|
|
//_baseShop(result.goBrand);
|
|
|
}
|
|
|
|
|
|
res.render('shop', {
|
|
|
res.render('shop/index', _.assign({
|
|
|
shopIndex: result,
|
|
|
shopPage: {
|
|
|
text: '分类',
|
...
|
...
|
@@ -86,10 +213,8 @@ const _shop = (req, res, shopId) => { |
|
|
},
|
|
|
gender: req.query.gender,
|
|
|
channel: req.query.channel
|
|
|
}
|
|
|
}, pageHeader));
|
|
|
});
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
// 搜索落地页
|
...
|
...
|
@@ -206,7 +331,7 @@ const category = (req, res) => { |
|
|
// 品牌落地页
|
|
|
const brand = (req, res, next) => {
|
|
|
let params = Object.assign({}, req.query);
|
|
|
let domain = 'vans';
|
|
|
let domain = 'colormad';
|
|
|
let uid = req.user.uid || 20000032;
|
|
|
let brandId = 0;
|
|
|
let brandLogo = {};
|
...
|
...
|
@@ -223,9 +348,9 @@ const brand = (req, res, next) => { |
|
|
title = brandLogo.name;
|
|
|
|
|
|
//无店铺:0--->品牌页 无单品店有多品店:1--->搜索页 有单品店:2--->店铺页面
|
|
|
if (brandLogo.type === 2 && brandLogo.shopId) {
|
|
|
if (brandLogo.type === '2' && brandLogo.shopId) {
|
|
|
_shop(req, res, brandLogo.shopId);
|
|
|
return false;
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
if (brandLogo && brandLogo.id) {
|
...
|
...
|
|