...
|
...
|
@@ -31,6 +31,7 @@ const _formShopData = (data, shopId, isApp) => { |
|
|
if (data.decorator) {
|
|
|
_.forEach(data.decorator.list, (floor) => {
|
|
|
let resData = JSON.parse(floor.resourceData);
|
|
|
|
|
|
floor[_.camelCase(floor.resourceName)] = true;
|
|
|
|
|
|
// 店铺banner
|
...
|
...
|
@@ -61,6 +62,7 @@ const _formShopData = (data, shopId, isApp) => { |
|
|
let brand = {
|
|
|
list: []
|
|
|
};
|
|
|
|
|
|
brandId = '';
|
|
|
|
|
|
// 少于2个不展示 单品店:单品店根据品牌id查询
|
...
|
...
|
@@ -71,7 +73,7 @@ const _formShopData = (data, shopId, isApp) => { |
|
|
_.forEach(resData, (item) => {
|
|
|
if (item.brandDomain) {
|
|
|
brand.list.push({
|
|
|
url: helpers.urlFormat('', '', item.brandDomain) + (isApp ? `?openby:yohobuy={"action":"go.brand","params":{"shop_id":${shopId},"brand_id":${item.id}}}` : ''),
|
|
|
url: helpers.urlFormat('', '', item.brandDomain) + (isApp ? `?openby:yohobuy={"action":"go.brand","params":{"shop_id":${shopId},"brand_id":${item.id}}}` : ''), //eslint-disable-line
|
|
|
img: helpers.image(item.brandIco, 640, 400),
|
|
|
brandName: item.brandName
|
|
|
});
|
...
|
...
|
@@ -95,6 +97,7 @@ const _formShopData = (data, shopId, isApp) => { |
|
|
let bannerTop = {
|
|
|
data: []
|
|
|
};
|
|
|
|
|
|
_.forEach(resData, (item) => {
|
|
|
if (item.data[0]) {
|
|
|
bannerTop.data.push({
|
...
|
...
|
@@ -134,7 +137,7 @@ const _formShopData = (data, shopId, isApp) => { |
|
|
|
|
|
_.forEach(resData, (item) => {
|
|
|
goods.push({
|
|
|
url: helpers.urlFormat(item.productId, item.goodsId, item.cnAlphabet) + (isApp ? `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":${item.productSkn}}` : ''),
|
|
|
url: helpers.urlFormat(item.productId, item.goodsId, item.cnAlphabet) + (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,
|
...
|
...
|
@@ -155,7 +158,7 @@ const _formShopData = (data, shopId, isApp) => { |
|
|
|
|
|
formatData = _.assign({
|
|
|
logoImg: data.shopInfo.shopLogo,
|
|
|
storeName: (data.shopInfo.isShowShopName === 'Y') ? list.shopName : '',
|
|
|
storeName: (data.shopInfo.isShowShopName === 'Y') ? data.shopInfo.shopName : '',
|
|
|
collect: data.shopInfo.isFavorite === 'Y',
|
|
|
url: helpers.urlFormat('', {
|
|
|
shop_id: shopId
|
...
|
...
|
@@ -183,12 +186,12 @@ const _formShopData = (data, shopId, isApp) => { |
|
|
}, formatData);
|
|
|
} else {
|
|
|
formatData = _.assign({
|
|
|
allGoods: `${helpers.urlFormat('', allGoodsParam, 'search')}&openby:yohobuy={"action":"go.list","params":{"title":"全部商品", "actiontype":"0","shop_id":"' . self::$shopId . '","page":"1"}}`,
|
|
|
allGoods: `${helpers.urlFormat('', allGoodsParam, 'search')}&openby:yohobuy={"action":"go.list","params":{"title":"全部商品", "actiontype":"0","shop_id":"' . self::$shopId . '","page":"1"}}`,//eslint-disable-line
|
|
|
shopIntroHref: helpers.urlFormat('/product/index/intro', {
|
|
|
shop_id: shopId,
|
|
|
app_version: isApp
|
|
|
}),
|
|
|
more_url: formatData.more_url + `?openby:yohobuy={"action":"go.list","params":{"shop_id":${shopId},"title":"人气单品"}}`
|
|
|
more_url: formatData.more_url + `?openby:yohobuy={"action":"go.list","params":{"shop_id":${shopId},"title":"人气单品"}}`//eslint-disable-line
|
|
|
}, formatData);
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -240,7 +243,7 @@ const _getShopData = (req, shopId, uid, isApp) => { |
|
|
let data = {};
|
|
|
let channel = req.yoho.channel;
|
|
|
|
|
|
return Promise.all([searchModel.getShopDecorator(shopId), searchModel.getShopInfo(shopId, uid)]).then((result) => {
|
|
|
return Promise.all([listModel.getShopDecorator(shopId), listModel.getShopInfo(shopId, uid)]).then((result) => {
|
|
|
data = {
|
|
|
decorator: result[0], // 店铺装修资源数据
|
|
|
shopInfo: result[1] // 店铺信息
|
...
|
...
|
@@ -254,7 +257,7 @@ const _getShopData = (req, shopId, uid, isApp) => { |
|
|
}
|
|
|
|
|
|
// 店铺分类
|
|
|
return searchModel.getShopCategory(shopId, channel).then((shopCategory) => {
|
|
|
return listModel.getShopCategory(shopId, channel).then((shopCategory) => {
|
|
|
data = _.assign({
|
|
|
shopCategory: shopCategory
|
|
|
}, data);
|
...
|
...
|
@@ -272,7 +275,7 @@ const _baseShop = (req, res, data) => { |
|
|
cartUrl: helpers.urlFormat('/cart/index/index')
|
|
|
}, req.query);
|
|
|
|
|
|
Promise.all([searchModel.getShopDecorator(data.shopsId), searchModel.getShopBrands(data.shopsId)]).then((result) => {
|
|
|
Promise.all([listModel.getShopDecorator(data.shopsId), listModel.getShopBrands(data.shopsId)]).then((result) => {
|
|
|
result[0] = result[0] || {};
|
|
|
|
|
|
console.log(result[0], result[1]);
|
...
|
...
|
@@ -345,7 +348,7 @@ const _shop = (req, res, shopId) => { |
|
|
_getShopData(req, shopId, uid, isApp).then((result) => {
|
|
|
if (result.goBrand) {
|
|
|
// 跳转基础模板
|
|
|
_baseShop(req, res, result.goBrand);
|
|
|
_baseShop(req, res, result.goBrand);
|
|
|
} else {
|
|
|
result = _.assign(result, pageHeader);
|
|
|
|
...
|
...
|
@@ -390,7 +393,7 @@ const brand = (req, res, next) => { |
|
|
res.redirect('/?go=1');
|
|
|
}
|
|
|
|
|
|
searchModel.getBrandLogoByDomain(domain).then((result) => {
|
|
|
listModel.getBrandLogoByDomain(domain).then((result) => {
|
|
|
brandLogo = result;
|
|
|
|
|
|
title = brandLogo.name;
|
...
|
...
|
@@ -407,7 +410,7 @@ const brand = (req, res, next) => { |
|
|
if (brandLogo.type === '2' && brandLogo.shopId) {
|
|
|
_shop(req, res, brandLogo.shopId);
|
|
|
} else { // 获取品牌店铺信息
|
|
|
searchModel.getBrandShops(brandId).then((brandShop) => {
|
|
|
listModel.getBrandShops(brandId).then((brandShop) => {
|
|
|
if (brandId === 0) {
|
|
|
params.query = domain;
|
|
|
}
|
...
|
...
|
@@ -415,20 +418,20 @@ const brand = (req, res, next) => { |
|
|
// 从搜索页过来的,显示搜索框, 和进入品牌引导信息 或者品牌关联多店铺
|
|
|
if (req.query.from === 'search' || brandShop.length > 0) {
|
|
|
params = {
|
|
|
brandWay: brandShop ? brandShop : brandLogo,
|
|
|
brandWay: brandShop ? brandShop : brandLogo,
|
|
|
search: {
|
|
|
default: req.query.query,
|
|
|
url: helpers.urlFormat('', null, 'search')
|
|
|
}
|
|
|
};
|
|
|
} else if (brandId !== 0) { // 品牌一览过来的展示品牌介绍和LOGO
|
|
|
return Promise.all([searchModel.getBrandIntro(brandId, uid), searchModel.getBrandBanner(brandId)]).then((result) => {
|
|
|
title = result[0].title;
|
|
|
delete result[0].title;
|
|
|
return Promise.all([listModel.getBrandIntro(brandId, uid), listModel.getBrandBanner(brandId)]).then((resData) => { //eslint-disable-line
|
|
|
title = resData[0].title;
|
|
|
delete resData[0].title;
|
|
|
|
|
|
return _.assign({
|
|
|
banner: result[1]
|
|
|
}, result[0]);
|
|
|
banner: resData[1]
|
|
|
}, resData[0]);
|
|
|
});
|
|
|
}
|
|
|
}).then((brandHome) => {
|
...
|
...
|
@@ -455,8 +458,8 @@ const shopIntro = (req, res, next) => { |
|
|
let appVersion = req.body.appVersion || false;
|
|
|
let params = {};
|
|
|
|
|
|
if (shopId){
|
|
|
searchModel.getShopIntro(shopId).then((result) => {
|
|
|
if (shopId) {
|
|
|
listModel.getShopIntro(shopId).then((result) => {
|
|
|
if (appVersion) {
|
|
|
params = {
|
|
|
title: '店铺简介'
|
...
|
...
|
@@ -509,13 +512,13 @@ const favoriteBrand = (req, res, next) => { |
|
|
});
|
|
|
return false;
|
|
|
} else if (opt !== 'ok') { // 取消收藏
|
|
|
searchModel.setFavoriteCancel(id, uid, type).then((data) => {
|
|
|
listModel.setFavoriteCancel(id, uid, type).then((data) => {
|
|
|
res.json(data);
|
|
|
return false;
|
|
|
}).catch(next);
|
|
|
}
|
|
|
|
|
|
searchModel.setFavorite(id, uid, type).then((result) => {
|
|
|
listModel.setFavorite(id, uid, type).then((result) => {
|
|
|
if (!result.code) { // 收藏
|
|
|
result = {
|
|
|
code: 401,
|
...
|
...
|
|