Authored by 周少峰

Merge branch 'master' into feature/studentsTwo

... ... @@ -33,7 +33,7 @@ exports.getNewArrival = (req, res, next) => {
let reqBody = req.body,
pageIndex = reqBody.pageIndex,
pageCount = reqBody.pageCount,
channel = reqBody.type,
channel = reqBody.type || req.yoho.channel,
goods = [],
result = {};
... ...
... ... @@ -15,8 +15,18 @@ const searchApi = require(`${mRoot}/search-api`);
const shop = (shopId, req, res, next, brandInfo) => {
shopId = parseInt(shopId, 10);
list.getShopInfo(shopId, req.user.id).then(shopInfo => {
list.getShopInfo(shopId, req.user.uid).then(shopInfo => {
if (+shopInfo.shopTemplateType === 2) { // 经典模板
let pjax = req.query._pjax;
if (pjax) {
list.getShopGoodsData(shopId, req.yoho.channel, req.query, shopInfo).then(result => {
Object.assign(result, {layout: false});
res.render('list/goods-list', result);
}).catch(next);
return;
}
list.getShopData(shopId, req.yoho.channel, req.query, shopInfo).then(result => {
Object.assign(result, {
page: 'shop',
... ... @@ -27,9 +37,9 @@ const shop = (shopId, req, res, next, brandInfo) => {
} else { // 基础模板
list.getBaseShopData(req.query, Object.assign({uid: req.user.uid}, brandInfo),
req.yoho.channel, shopId).then(result => {
Object.assign(result, {page: 'list'});
res.render('list/brand', result);
}).catch(next);
Object.assign(result, {page: 'list'});
res.render('list/brand', result);
}).catch(next);
}
}).catch(next);
};
... ... @@ -148,7 +158,7 @@ exports.shopList = (req, res, next) => {
return next();
}
list.getShopListData(req.yoho.channel, req.query).then(result => {
list.getShopListData(req.yoho.channel, req.query, req.user.uid).then(result => {
Object.assign(result, {
page: 'shop',
shopId: shopId
... ...
... ... @@ -16,7 +16,7 @@ const sale = require(`${mRoot}/sale`); // sale 页 model
* @return {[type]} [description]
*/
exports.index = (req, res, next) => {
let channel = req.query.channel || req.cookies._Channel || 'boys';
let channel = req.query.channel || req.yoho.channel;
// 真实数据输出
sale.getSaleIndexData(channel).then(result => {
... ... @@ -41,7 +41,7 @@ exports.discount = (req, res, next) => {
saleType: '3'
}, req.query);
let channel = req.query.channel || req.cookies._Channel || 'boys';
let channel = req.query.channel || req.yoho.channel;
let responseData = {
module: 'product',
... ... @@ -68,7 +68,7 @@ exports.vip = (req, res, next) => {
saleType: '2'
}, req.query);
let channel = req.query.channel || req.cookies._Channel || 'boys';
let channel = req.query.channel || req.yoho.channel;
params.uid = req.user.uid || 0;
... ... @@ -95,7 +95,7 @@ exports.newSale = (req, res, next) => {
order: 's_t_desc'
}, req.query);
let channel = req.query.channel || req.cookies._Channel || 'boys';
let channel = req.query.channel || req.yoho.channel;
sale.getSaleOthersData(params, channel).then((result) => {
res.render('sale/other', Object.assign({
... ... @@ -119,7 +119,7 @@ exports.breakingYards = (req, res, next) => {
saleType: '5'
}, req.query);
let channel = req.query.channel || req.cookies._Channel || 'boys';
let channel = req.query.channel || req.yoho.channel;
let responseData = {
module: 'product',
... ...
... ... @@ -373,7 +373,7 @@ const _getFashionTopGoodsStatus = (uid, showStatus, isBeginSale) => {
// dis //失效
// buyNow //是否立即购买
let result = {
getLimitedCode: true,
getLimitedCode: false,
hadLimitedCode: false,
limitedCodeSoldOut: false,
openSoon: false,
... ... @@ -393,17 +393,16 @@ const _getFashionTopGoodsStatus = (uid, showStatus, isBeginSale) => {
result.openSoon = true;
result.hadLimitedCode = false;
}
result.getLimitedCode = true;
break;
case 2: // 开售后,限购码已抢光(用户未领取限购码)
result.buyNow = true;
result.dis = true;
result.limitedCodeSoldOut = true;
result.getLimitedCode = false;
result.hadLimitedCode = false;
break;
case 3: // 开售后,商品已经售罄
result.soldOut = true;
result.getLimitedCode = false;
break;
case 4:// 开售后,立即购买(用户已领取限购码)
result.buyNow = true;
... ... @@ -417,7 +416,6 @@ const _getFashionTopGoodsStatus = (uid, showStatus, isBeginSale) => {
result.openSoon = true;
result.hadLimitedCode = true;
result.limitedCodeSoldOut = true;
result.getLimitedCode = false;
break;
case 6: // 开售前,即将开售(用户已领取限购码)
result.openSoon = true;
... ... @@ -1102,21 +1100,22 @@ const _detailDataPkg = (origin, uid, vipLevel) => {
result.vipPrice = _getVipDataByProductBaseInfo(origin, vipLevel, uid);
}
// 促销活动banner,虚拟商品无促销
// 促销活动banner,虚拟商品无促销
if (propOrigin('attribute') !== 3) {
result.activity = _getActivityDataByProductBaseInfo(promotionData, additionalData);
}
const C_VALUE = {
type: '返有货币',
des: '每件返 ',
rest: '个 有货币'
};
// 有货币
if (!_.includes(['', '0'], propOrigin('yohoCoinNum'))) {
const C_VALUE = {
type: '返有货币',
des: '每件返 ',
rest: '个 有货币'
};
if (propOrigin('yoho_coin_num', '0') !== '0') {
result.activity.push({
type: C_VALUE.type,
des: `${C_VALUE.des}${propOrigin('yoho_coin_num')}${C_VALUE.rest}`
des: `${C_VALUE.des}${propOrigin('yohoCoinNum')}${C_VALUE.rest}`
});
}
... ... @@ -1152,12 +1151,12 @@ const _detailDataPkg = (origin, uid, vipLevel) => {
// 是否收藏
result.isCollect = favoriteData.product;
if (propOrigin('is_limit_buy', false)) {
if (propOrigin('isLimitBuy', false)) {
// 是否开售
let isBeginSale = propOrigin('sale_status', 0) === 1;
let isBeginSale = propOrigin('saleStatus', 0) === 1;
// 限购商品有关的展示状态
let showStatus = propOrigin('show_status', 1);
let showStatus = propOrigin('showStatus', 1);
let fashTopGoods = _getFashionTopGoodsStatus(uid, showStatus, isBeginSale);
... ... @@ -1237,8 +1236,13 @@ const _detailDataPkg = (origin, uid, vipLevel) => {
statGoodsInfo.productId = propOrigin('product_id');
statGoodsInfo.productName = result.name.replace('\'', '’');
statGoodsInfo.brandName = (result.brandName || '').replace('\'', '’');
statGoodsInfo.marketPrice = result.marketPrice;
statGoodsInfo.salePrice = result.salePrice ? result.salePrice : result.marketPrice;
statGoodsInfo.marketPrice = result.marketPrice.replace('¥', ''); // 数字
statGoodsInfo.salePrice = (result.salePrice ? result.salePrice : result.marketPrice).replace('¥', ''); // 数字
statGoodsInfo.imageUrl = 'http:' + result.img.split('?')[0];
statGoodsInfo.productUrl = 'http:' +
helpers.urlFormat(url.parse(propOrigin('product_url')).pathname, null, 'item');
statGoodsInfo.smallSortId = result.smallSortId;
statGoodsInfo.soldOut = soldOut ? 1 : 0;
if (banner.brandId) {
let domainBrand = yield brandService.getBrandByDomainAsync(banner.brandDomain);
... ... @@ -1258,11 +1262,6 @@ const _detailDataPkg = (origin, uid, vipLevel) => {
}
}
statGoodsInfo.imageUrl = 'http:' + result.img.split('?')[0];
statGoodsInfo.productUrl = 'http:' +
helpers.urlFormat(url.parse(propOrigin('product_url')).pathname, null, 'item');
statGoodsInfo.smallSortId = result.smallSortId;
statGoodsInfo.soldOut = soldOut ? 1 : 0;
// 获取商品尺寸相关
let sizeInfo = _getSizeInfo(result, result.maxSortId, additionalData);
... ...
... ... @@ -118,7 +118,9 @@ const getListData = (params, channel) => {
totalCount: result[2].data.total,
footPager: searchHandler.handlePagerData(result[2].data.total, params),
goods: productProcess.processProductList(result[2].data.product_list,
Object.assign({showDiscount: false}, params)),
Object.assign({showDiscount: false}, params, {
from: {type: 'list', params: params}
})),
hasNextPage: searchHandler.handleNextPage(params, result[2].data.total),
// 最近浏览记录
... ... @@ -194,7 +196,8 @@ const getListNewData = (params, channel) => {
totalCount: result[2].data.total,
footPager: searchHandler.handlePagerData(result[2].data.total, params),
goods: productProcess.processProductList(result[2].data.product_list,
Object.assign({showDiscount: false, showNew: false}, params)),
Object.assign({showDiscount: false, showNew: false,
from: {type: 'listNew', params: params}}, params)),
hasNextPage: searchHandler.handleNextPage(params, result[2].data.total),
// 最近浏览记录
... ... @@ -265,7 +268,7 @@ const getBrandData = (params, extra, channel) => {
let apiMethod = [
headerModel.requestHeaderData(channel),
searchApi.getSortList(queryBase),
searchApi.getProductList(Object.assign({order: order}, searchParams, queryBase))
searchApi.getProductList(Object.assign(searchParams, {order: order}, queryBase))
];
... ... @@ -304,16 +307,16 @@ const getBrandData = (params, extra, channel) => {
totalCount: result[2].data.total,
footPager: searchHandler.handlePagerData(result[2].data.total, params),
goods: productProcess.processProductList(result[2].data.product_list,
Object.assign({showDiscount: false}, params)),
Object.assign({showDiscount: false, from: {type: 'brand', params: params}}, params)),
hasNextPage: searchHandler.handleNextPage(params, result[2].data.total),
// 最近浏览记录
latestWalk: 7
});
}
// 品牌页不显示品牌筛选项
delete finalResult.brand.filters.brand;
// 品牌页不显示品牌筛选项
_.unset(finalResult, 'brand.filters.brand');
}
finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.brand, 'goods'))};
... ... @@ -417,7 +420,7 @@ const getShopAbout = (shopId, uid, channel) => {
if (result[1].code === 200) {
let data = result[1].data || {},
decorator = shopHandler.getShopDecorator(data, {}, shopId);
decorator = shopHandler.getShopDecorator(data, {}, shopId, true);
Object.assign(decorator.shopTopBannerBase, {
shopId: shopId,
... ... @@ -637,7 +640,8 @@ const getShopData = (shopId, channel, params, shopInfo) => {
finalResult.leftContent = searchHandler.handleSortData(groupSort, params);
if (finalResult.allGoods) {
Object.assign(finalResult.allGoods, searchHandler.setShopSort(groupSort, params));
Object.assign(finalResult.allGoods, searchHandler.setShopSort(groupSort, Object.assign({},
params, {page: 1})));
}
}
... ... @@ -652,7 +656,7 @@ const getShopData = (shopId, channel, params, shopInfo) => {
for (let i = 0; i < 3; i++) {
trendList.push({
href: articleList[i].url,
href: helpers.urlFormat(`/${articleList[i].id}.html`, '', 'guang'),
src: helpers.getForceSourceUrl(articleList[i].src) +
'?imageView/1/w/{width}/h/{height}',
mainTitle: articleList[i].title,
... ... @@ -672,6 +676,55 @@ const getShopData = (shopId, channel, params, shopInfo) => {
});
};
/**
* 获取店铺商品数据
*/
const getShopGoodsData = (shopId, channel, params) => {
let gender = _getGender(channel);
let resData = {};
_.unset(params, '_pjax');
return Promise.all([
searchApi.getProductList(Object.assign({
shop_id: shopId
}, params)), // 搜索店铺商品
searchApi.getShopBrands(shopId) // 店铺品牌数据
]).then(result => {
// 获取商品数据和顶部筛选条件
if (result[0].code === 200) {
Object.assign(resData, {
sort: searchHandler.handleOptsData(params, _.get(result[0], 'data.total', 0)),
list: productProcess.processProductList(_.get(result[0], 'data.product_list', []), {
newCoverSort: true,
showDiscount: false,
gender: gender
})
});
_.set(resData, 'sort.newPage', true); // 启用新的分页导航
}
let shopBrandIds = []; // 店铺的所有品牌id
if (result[1].code === 200 && result[1].data) {
_.forEach(result[1].data, value => {
shopBrandIds.push(value.brand_id);
});
}
// 根据品牌获取分类 (腾讯云测试没有该接口,暂时不调用分类)
return searchApi.getSortList({brand: shopBrandIds}).then(subRes => {
if (subRes.code === 200) {
let groupSort = _.get(subRes, 'data.sort', []);
Object.assign(resData, searchHandler.setShopSort(groupSort, Object.assign(params,
{page: 1})));
}
return resData;
});
});
};
const getShopListData = (channel, params, uid) => {
let gender = _getGender(channel),
shopId = params.shopId,
... ... @@ -741,10 +794,14 @@ const getShopListData = (channel, params, uid) => {
goods: productProcess.processProductList(goodsList, {
newCoverSort: true,
showDiscount: false,
gender: _getGender(channel)
gender: _getGender(channel),
query: params.query
}),
footPager: {tip: tip}
});
_.set(finalResult, 'filters.checkedConditions.clearUrl',
`?navBar=${params.navBar}&shopId=${params.shopId}`);
} else {
finalResult.searchEmpty = true;
... ... @@ -812,7 +869,7 @@ const getBaseShopData = (params, extra, channel, shopId) => {
if (result[1].code === 200) {
let data = result[1].data || {},
decorator = shopHandler.getShopDecorator(data, {}, shopId);
decorator = shopHandler.getShopDecorator(data, {}, shopId, true);
Object.assign(decorator.shopTopBannerBase, {
shopId: shopId,
... ... @@ -822,6 +879,10 @@ const getBaseShopData = (params, extra, channel, shopId) => {
});
_.set(resData, 'brand.shopBanner', decorator.shopTopBannerBase);
_.unset(resData, 'brand.brandBanner');
if (decorator.signboard) {
_.set(resData, 'brand.signboard', decorator.signboard);
}
}
if (result[2].code === 200) {
... ... @@ -833,6 +894,11 @@ const getBaseShopData = (params, extra, channel, shopId) => {
});
}
// 临时删除seo信息
_.unset(resData, 'title');
_.unset(resData, 'keywords');
_.unset(resData, 'description');
return resData;
});
};
... ... @@ -848,6 +914,7 @@ module.exports = {
getAdnav,
getShopInfo,
getShopData,
getShopGoodsData,
getShopListData,
getBaseShopData
};
... ...
... ... @@ -63,14 +63,14 @@ exports.getSalebreakingYardsSortList = (params) => {
* @return {[type]} [description]
*/
exports.getSaleActivityList = (params, channel) => {
let tempChannel = _.isEmpty(channel) ? 'boys' : channel;
let tempChannel = yhChannel[channel] || yhChannel.boys;
return api.get('', {
id: params.id || null,
method: 'app.activity.get',
sort: '2',
plateform: '1',
yh_channel: yhChannel[tempChannel].channel
yh_channel: tempChannel.channel
});
};
... ...
... ... @@ -379,7 +379,8 @@ exports.getSaleDiscountData = (params, channel) => {
// 处理分页等筛选信息
if (subResult[0].code === 200) {
Object.assign(finalResult, {
leftContent: publicHandler.handleSaleSortData(subResult[0].data.filter.group_sort, params, 'discount'),
leftContent: publicHandler.handleSaleSortData(subResult[0].data.filter.group_sort,
params, 'discount'),
saleList: {
footPager: publicHandler.handlePagerData(subResult[0].data.total, params),
opts: publicHandler.handleSaleOptsData(params, subResult[0].data.total, 'default')
... ... @@ -528,7 +529,7 @@ exports.getSaleSpecialData = (id, params, channel) => {
limit: limit,
attribute_not: 2
});
let banner = JSON.parse(data.banner_img) || [];
let banner = data.banner_img ? JSON.parse(data.banner_img) : [];
Object.assign(resData, {
mainBanner: {
... ... @@ -580,7 +581,8 @@ exports.getSaleSpecialData = (id, params, channel) => {
Object.assign(resData, {
filters: searchHandler.handleFilterDataAll(_.get(result[2], 'data', {}), params),
opts: searchHandler.handleOptsData(params, tip.total),
goods: productProcess.processProductList(_.get(result[2], 'data.product_list', [])),
goods: productProcess.processProductList(_.get(result[2], 'data.product_list', []),
{from: {type: 'saleSpecial', params: params}}),
footPager: {tip: tip}
});
... ...
... ... @@ -99,7 +99,7 @@ const handleBrandCheckedData = (params, origin) => {
if (!_.isEmpty(origin)) {
_.forEach(origin, (value) => {
if (typeof _.find(intBrands, o => {
return _.isEqual(o, value.id);
return _.isEqual(o, +value.id);
}) !== 'undefined') {
let checked = {
name: value.name
... ... @@ -204,9 +204,7 @@ const formatterFilterBrands = (source, paramBrand, params) => {
index: '0-9',
name: '0~9'
}],
selectedBrands: [],
showMore: true,
showMulti: true
selectedBrands: []
};
... ... @@ -233,7 +231,7 @@ const formatterFilterBrands = (source, paramBrand, params) => {
_.forEach(source, function(value) {
let brand = {
checked: (typeof _.find(intBrands, o => {
return _.isEqual(o, value.id);
return _.isEqual(o, +value.id);
}) !== 'undefined'),
href: handleFilterUrl(params, {brand: value.id}),
name: value.brand_name,
... ... @@ -257,6 +255,13 @@ const formatterFilterBrands = (source, paramBrand, params) => {
count++;
});
if (dbrand.default.length > 9) {
Object.assign(dbrand, {
showMore: true,
showMulti: true
});
}
if (paramBrand) {
_.forEach(paramBrand, value => {
let brand = {
... ... @@ -306,7 +311,7 @@ exports.handleOptsData = (params, total, extra) => {
switch (i) {
case 0:
opt.href = handleFilterUrl(params, {order: ''}, {page: true});
opt.href = handleFilterUrl(params, {}, {page: true, order: true});
if (extra === 'discont') { // 如果是折扣专场
opt.name = '全部';
if (_.isEmpty(params.order) || params.order === 's_t_desc') {
... ... @@ -538,7 +543,10 @@ exports.setShopSort = (data, params) => {
});
if (list.length) {
_.set(resData, 'goodsMenu.menuList', list);
resData.goodsMenu = {
menuList: list,
url: `/product/shoplist?navBar=1&shopId=${params.shopId}`
};
}
}
... ... @@ -554,19 +562,6 @@ exports.setShopSort = (data, params) => {
exports.handleFilterData = (origin, params, total) => {
let dest = {
ageLevel: [],
brand: {
default: [],
brandsShow: [],
brandIndex: [{
index: 'all',
name: '全部'
}, {
index: '0-9',
name: '0~9'
}],
showMore: true,
showMulti: true
},
price: [],
gender: [],
color: [],
... ... @@ -587,6 +582,9 @@ exports.handleFilterData = (origin, params, total) => {
if (params.price === key) {
priceRangechecked = true;
}
if (_.isString(value)) {
value = _.replace(value, '¥', '¥');
}
let price = {
checked: params.price === key,
href: handleFilterUrl(params, {price: key}),
... ... @@ -873,11 +871,12 @@ exports.handleSeniorFilterData = (data, params) => {
};
exports.handleFilterDataAll = (data, qs) => {
let destFilter = {};
let params = _.cloneDeep(qs);
_.unset(params, 'page'); // 去除筛选项page
let baseFilter = this.handleFilterData(data.filter, params, data.total);
let baseFilter = this.handleFilterData(_.get(data, 'filter', {}), params, data.total);
let seniorFilter = this.handleSeniorFilterData({
style: _.get(data, 'filter.style', []),
standard: _.get(data, 'standard', [])
... ... @@ -886,12 +885,9 @@ exports.handleFilterDataAll = (data, qs) => {
let conditions = _.union(_.get(baseFilter, 'checkedConditions.conditions'),
_.get(seniorFilter, 'checkedConditions.conditions'));
let destFilter = Object.assign({}, seniorFilter, baseFilter);
Object.assign(destFilter, seniorFilter, baseFilter);
if (!destFilter.checkedConditions) {
destFilter.checkedConditions = {};
}
destFilter.checkedConditions.conditions = conditions;
_.set(destFilter, 'checkedConditions.conditions', conditions);
return destFilter;
};
... ... @@ -1397,7 +1393,6 @@ exports.getBrandSeo = (channel, brandInfo) => {
bb = b + ' ' + bcn,
bc = b + c,
bbc = b + bcn + c,
title = bb || b || '',
keywords = [b ? b + ',' : '',
((b && bcn) ? (bb + ',') : ''),
bc || '',
... ... @@ -1406,7 +1401,7 @@ exports.getBrandSeo = (channel, brandInfo) => {
bbc || '',
'品牌官方授权!YOHO! 有货中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。'].join('');
title += (title ? (title + '|') : '') + c + '品牌|YOHO!BUY 有货 100%正品保证';
let title = (b ? (b + '|') : '') + (bb ? (bb + '|') : '') + c + '品牌|YOHO!BUY 有货 100%正品保证';
return {
title: title,
... ...
... ... @@ -68,7 +68,7 @@ exports.getSearchData = (params, channel) => {
totalCount: result[2].data.total,
footPager: searchHandler.handlePagerData(result[2].data.total, params),
goods: productProcess.processProductList(result[2].data.product_list,
Object.assign({showDiscount: false}, params)),
Object.assign({showDiscount: false, from: {type: 'search', params: params}}, params)),
latestWalk: 6,
hasNextPage: searchHandler.handleNextPage(params, result[2].data.total),
shopEntry: result[3]
... ...
... ... @@ -5,6 +5,8 @@
'use strict';
const _ = require('lodash');
const Fn = require('lodash/fp');
const qs = require('querystring');
const helpers = global.yoho.helpers;
... ... @@ -68,32 +70,34 @@ const hotProducts = (data) => {
*/
const goodsTabBar = (data, shopId) => {
let dest = {
hot: [],
new: []
},
more = {name: 'MORE', href: shopListUrl + '?shopId=' + shopId};
hot: [],
new: []
};
_.forEach(data.hot, (value) => {
if (value.url) {
_.forEach(_.sortBy(data.hot, o => {
return -o.position;
}), (value) => {
if (value.url && value.position) {
dest.hot.push({
name: value.name,
href: value.url
url: value.url
});
}
});
_.forEach(data.new, (value) => {
if (value.url) {
_.forEach(_.sortBy(data.new, o => {
return -o.position;
}), (value) => {
if (value.url && value.position) {
dest.new.push({
name: value.name,
href: value.url
url: value.url
});
}
});
dest.hot.push(more);
dest.new.push(more);
dest.hot.push({name: 'MORE', url: `${shopListUrl}?navBar=2&order=s_n_desc&shopId=${shopId}`});
dest.new.push({name: 'MORE', url: `${shopListUrl}?navBar=3&order=s_t_desc&shopId=${shopId}`});
return dest;
};
... ... @@ -144,17 +148,24 @@ const navigationBar = (data, shopId) => {
},
{
name: '人气单品',
url: `${shopListUrl}/?navBar=2&shopId=${shopId}`
url: `${shopListUrl}/?navBar=2&order=s_n_desc&shopId=${shopId}`
},
{
name: '新品上架',
url: `${shopListUrl}/?navBar=3&shopId=${shopId}`
url: `${shopListUrl}/?navBar=3&order=s_t_desc&shopId=${shopId}`
}
];
return {navigationBar: _.union(shopNav, _.filter(data, (value) => {
return value.url;
}))};
_.forEach(data, (value) => {
if (value.url) {
shopNav.push({
name: value.name,
url: `${value.url}&navBar=${shopNav.length}`
});
}
});
return {navigationBar: shopNav};
};
/**
... ... @@ -166,9 +177,10 @@ const largeSlideImg = (data) => {
let dest = [];
_.forEach(data, (value) => {
value = _.get(value, 'data[0]', {});
dest.push({
img: value.data[0].src,
url: helpers.urlFormat(value.data[0].url)
img: value.src,
url: value.url
});
});
... ... @@ -184,9 +196,10 @@ const oneRowTwoColImages = (data) => {
let dest = [];
_.forEach(data, (value) => {
value = _.get(value, 'data[0]', {});
dest.push({
img: value.data[0].src,
url: helpers.urlFormat(value.data[0].url)
img: value.src,
url: value.url
});
});
return {oneRowTwoColImages: dest};
... ... @@ -197,7 +210,7 @@ const oneRowTwoColImages = (data) => {
* @param type $data
* @return type []
*/
const recommend = (data, shopId) => {
const recommend = (data) => {
let dest = [];
_.forEach(data, (value) => {
... ... @@ -206,7 +219,7 @@ const recommend = (data, shopId) => {
name: value.name,
img: value.src,
title: value.title,
url: `${shopListUrl}?shopId=${shopId}&filter_poolId=${value.categoryId}`
url: value.url
});
});
... ... @@ -277,62 +290,130 @@ const hotRecommend = (data) => {
};
/**
* 店铺装修楼层数据
* @param data 装修数据
* @returns {{}}
* 水牌
*/
exports.getShopDecorator = (data, params, shopId) => {
let dest = {
newArrivel: {},
hotSingle: {}
const signboard = (data) => {
let list = [];
_.forEach(data, value => {
if (value.data) {
_.forEach(value.data, val => {
list.push({
img: helpers.image(val.src, 160, 240),
url: val.url
});
});
}
});
return {
title: _.get(list, '[0].title', ''),
list: list
};
};
_.forEach(data.list, (value) => {
let info = JSON.parse(value.resource_data);
let tabBar;
switch (value.resource_name) {
case 'signboard':
break;
case 'newProducts':
Object.assign(dest.newArrivel, newProducts(info));
break;
case 'hotProducts':
Object.assign(dest.hotSingle, hotProducts(info));
break;
case 'goodsTabBar':
tabBar = goodsTabBar(info);
Object.assign(dest.newArrivel, {navs: tabBar.new});
Object.assign(dest.hotSingle, {navs: tabBar.hot});
break;
case 'shopTopBanner':
Object.assign(dest, shopTopBanner(info));
break;
case 'shopTopBanner_base':
Object.assign(dest, shopTopBannerBase(info));
break;
case 'navigationBar':
Object.assign(dest, navigationBar(info, shopId));
break;
case 'largeSlideImg':
Object.assign(dest, largeSlideImg(info));
break;
case 'oneRowTwoColImages':
Object.assign(dest, oneRowTwoColImages(info, shopId));
break;
case 'recommend':
Object.assign(dest, recommend(info, shopId));
break;
case 'brandBrowse':
Object.assign(dest, brandBrowse(info, params));
break;
case 'hotRecommend':
Object.assign(dest, hotRecommend(info));
break;
default:
break;
// 销售类目
const _handleSaleCategory = (shopId, resourceObj) => {
const thisShop = (categoryId) => shopListUrl + '?' + qs.stringify({
productPool: categoryId,
shopId: shopId,
navBar: -1
});
let hasSaleCategory = Fn.pipe(Fn.prop('linkType'), Fn.eq('1'));
if (hasSaleCategory(resourceObj)) {
return Object.assign(resourceObj, {url: thisShop(resourceObj.categoryId)});
}
_(resourceObj).forEach((value) => {
if (_.has(value, 'data')) {
_.forEach(value.data, (it) => {
if (hasSaleCategory(it)) {
Object.assign(it, {url: thisShop(it.categoryId)});
}
});
}
if (hasSaleCategory(value)) {
Object.assign(value, {url: thisShop(value.categoryId)});
}
});
return resourceObj;
};
/**
* 店铺装修楼层数据
* @param data 装修数据
* @returns {{}}
*/
exports.getShopDecorator = (data, params, shopId, base) => {
let dest = {};
if (base) {
_.forEach(data.list, (value) => {
let info = Fn.pipe(JSON.parse, _.partial(_handleSaleCategory, shopId))(value.resource_data);
switch (value.resource_name) {
case 'signboard':
dest.signboard = signboard(info);
break;
case 'shopTopBanner_base':
Object.assign(dest, shopTopBannerBase(info));
break;
default:
break;
}
});
} else {
Object.assign(dest, {
newArrivel: {},
hotSingle: {}
});
_.forEach(data.list, (value) => {
let info = Fn.pipe(JSON.parse, _.partial(_handleSaleCategory, shopId))(value.resource_data);
let tabBar;
switch (value.resource_name) {
case 'newProducts':
Object.assign(dest.newArrivel, newProducts(info));
break;
case 'hotProducts':
Object.assign(dest.hotSingle, hotProducts(info));
break;
case 'goodsTabBar':
tabBar = goodsTabBar(info, shopId);
Object.assign(dest.newArrivel, {navs: tabBar.new});
Object.assign(dest.hotSingle, {navs: tabBar.hot});
break;
case 'shopTopBanner':
Object.assign(dest, shopTopBanner(info));
break;
case 'navigationBar':
Object.assign(dest, navigationBar(info, shopId));
break;
case 'largeSlideImg':
Object.assign(dest, largeSlideImg(info, shopId));
break;
case 'oneRowTwoColImages':
Object.assign(dest, oneRowTwoColImages(info, shopId));
break;
case 'recommend':
Object.assign(dest, recommend(info, shopId));
break;
case 'brandBrowse':
Object.assign(dest, brandBrowse(info, params));
break;
case 'hotRecommend':
Object.assign(dest, hotRecommend(info));
break;
default:
break;
}
});
}
return dest;
};
... ...
{{> list/shop-list}}
\ No newline at end of file
... ...
... ... @@ -78,7 +78,7 @@
</p>
<div class="hideList hide">
{{#goods_list}}
<li data-src="{{image images_url 280 374}}" data-url="{{../url}}" data-status="{{status}}"></li>
<li data-src="{{image images_url 280 382}}" data-url="{{../url}}" data-status="{{status}}"></li>
{{/goods_list}}
</div>
</div>
... ...
{
"name": "yohobuy-node",
"version": "5.0.2",
"version": "5.0.3",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -300,6 +300,7 @@
.ud-price-range {
margin-top: 2px;
display: inline-block;
}
.limit {
... ...
... ... @@ -64,7 +64,7 @@ exports.setPager = (total, params)=>{
for (i = 1; i <= len; i++) {
let p = currentPage + i + 2;
if (i > total) {
if (p > total) {
break;
}
... ... @@ -78,7 +78,7 @@ exports.setPager = (total, params)=>{
for (i = 1; i <= len; i++) {
let p = currentPage - i - 2;
if (i < 1) {
if (p < 1) {
break;
}
... ...
... ... @@ -7,6 +7,15 @@ const helpers = global.yoho.helpers;
// const images = require(`${global.utils}/images`);
const itemFromBase = {
search: {domain: 'search', module: 's'}, // 搜索页search.yohobuy.com
list: {domain: 'list', module: 'c'}, // list.yohobuy.com
listSale: {domain: 'list', module: 's'}, // list.yohobuy.com/sale
listNew: {domain: 'list', module: 'n'}, // list.yohobuy.com/new
brand: {domain: 'brand', module: 'b'}, // xxx.yohobuy.com[品牌域名]
saleSpecial: {domain: 'sale', module: 's'}// sale.yohobuy.com
};
// NOTE: 这里修改了图片质量的参数
helpers.image = _.flow(helpers.image, fp.replace(/\/quality\/\d*$/, '/quality/90'));
... ... @@ -105,6 +114,8 @@ const procProductImgs = (item, gender) => {
*/
exports.processProductList = (list, options) => {
const pruductList = [];
let itemNum = 0,
itemFrom;
options = Object.assign({
showTags: true,
... ... @@ -118,11 +129,30 @@ exports.processProductList = (list, options) => {
height: 388,
isApp: false,
showPoint: true,
gender: '2,3'
gender: '2,3',
from: {} // 来源
}, options);
_.forEach(list, (product) => {
// 处理item from
if (!_.isEmpty(options.from) && itemFromBase[options.from.type]) {
let f = {domain: '', module: '', key: ''};
let params = options.from.params || {};
f.page = params.page || 1;
Object.assign(f, itemFromBase[options.from.type], {
page: params.page || 1,
key: params.misort || params.msort || ''
});
if (options.from.type === 'search') {
f.key = params.query || '';
}
itemFrom = `from=${f.domain}-${f.module}-${f.key}_${f.page}_`;
}
_.forEach(list, (product) => {
// 商品信息有问题,则不显示
if (!product || !product.product_skn || !product.goods_list.length) {
... ... @@ -166,7 +196,7 @@ exports.processProductList = (list, options) => {
});
product.is_few = product.is_soon_sold_out === 'Y';
product.url = helpers.urlFormat(`/product/pro_${product.product_id}_${product.goods_list[0].goods_id}/${product.cn_alphabet}.html`); // eslint-disable-line
product.url = helpers.urlFormat(`/product/pro_${product.product_id}_${product.goods_list[0].goods_id}/${product.cn_alphabet}.html`, '', 'item'); // eslint-disable-line
// tar add 1606071146 品牌链接处理
product.brandUrl = helpers.urlFormat('', '', product.brand_domain);
... ... @@ -175,6 +205,10 @@ exports.processProductList = (list, options) => {
// 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护
if (options.isApp) {
product.url += `?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":'${product.product_id}'}}`; // eslint-disable-line
} else if (itemFrom) {
// 累加商品数量
itemNum++;
product.url += `?${itemFrom}${itemNum}`;
}
if (options.showTags) {
... ...