Authored by yyq

店铺首页

... ... @@ -80,16 +80,17 @@ exports.brand = (req, res, next) => {
// req.shopId存在,直接走店铺
if (req.shopId) {
shop(req.shopId, req, res, next);
return shop(req.shopId, req, res, next);
}
let brandDomain = 'colormad';
let brandDomain = req.brandDomain || 'colormad';
// let brandDomain = req.brandDomain || 'shop$15';
// 获取品牌信息
list.getBrandInfo({domain: brandDomain}).then(brandInfo => {
// brandInfo.type = 2;
// brandInfo.shopId = 746;
// brandInfo.shopId = 15;
switch (parseInt(brandInfo.type, 10)) {
case 1:
// 搜索
... ...
... ... @@ -5,7 +5,6 @@
'use strict';
const utils = '../../../utils';
const api = global.yoho.API;
const searchApi = require('./search-api');
const headerModel = require('../../../doraemon/models/header');
const productProcess = require(`${utils}/product-process`);
... ... @@ -46,7 +45,7 @@ exports.getListData = (params) => {
apiMethod.push(searchApi.getSortAds(Object.assign(IntroParams, {position_id: sortAdsId})));
}
return api.all(apiMethod).then(result => {
return Promise.all(apiMethod).then(result => {
let finalResult = {
headerData: Object.assign(result[0].headerData, {
header: true
... ... @@ -102,7 +101,7 @@ exports.getListNewData = (params) => {
searchApi.getWeekNew(params)
];
return api.all(apiMethod).then(result => {
return Promise.all(apiMethod).then(result => {
let finalResult = {
headerData: Object.assign(result[0].headerData, {
header: true
... ... @@ -185,7 +184,7 @@ exports.getBrandData = (params, extra) => {
];
return api.all(apiMethod).then(result => {
return Promise.all(apiMethod).then(result => {
let finalResult = {
headerData: Object.assign(result[0].headerData, {
header: true
... ... @@ -241,7 +240,7 @@ exports.getNodeContentData = (params) => {
*/
exports.getAdnav = (params) => {
return api.all([searchApi.getBrandFolder(params), searchApi.getBrandSeries(params)]).then(result => {
return Promise.all([searchApi.getBrandFolder(params), searchApi.getBrandSeries(params)]).then(result => {
let dest = {
picTitle: '',
... ... @@ -296,6 +295,8 @@ exports.getShopInfo = (shopId, uid) => {
* @param shopInfo 店铺介绍
*/
exports.getShopData = (shopId, uid, params, shopInfo) => {
params = params || {};
params.shopId = shopId;
// 店铺所有品牌
return searchApi.getShopBrands(shopId).then(shopBrands => {
... ... @@ -336,16 +337,16 @@ exports.getShopData = (shopId, uid, params, shopInfo) => {
});
// 根据品牌获取分类 (腾讯云测试没有该接口,暂时不调用分类)
// apiMethod.push(
// // 店铺分类
// searchApi.getSortList({brand: shopBrandIds})
// );
apiMethod.push(
// 店铺分类
searchApi.getSortList({brand: shopBrandIds})
);
// apiMethod 添加调用相关文章的接口
apiMethod = _.concat(apiMethod, articleApiMethod);
return api.all(apiMethod).then(result => {
return Promise.all(apiMethod).then(result => {
let finalResult = {
headerData: Object.assign(result[0].headerData, {header: true}),
pathNav: searchHandler.handlePathNavData(shopInfo, params, 'shop')
... ... @@ -363,6 +364,8 @@ exports.getShopData = (shopId, uid, params, shopInfo) => {
return Promise.reject('No ShopDecorator data');
}
// // 获取左侧类目数据
// if (result[1].code === 200) {
// Object.assign(finalResult.shop, {
... ... @@ -377,16 +380,28 @@ exports.getShopData = (shopId, uid, params, shopInfo) => {
// }
// 获取商品数据和顶部筛选条件
// if (result[2].code === 200) {
// Object.assign(finalResult.shop, {
// filters: searchHandler.handleFilterData(result[2].data.filter, params),
// opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter),
// 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))
// });
// }
if (result[2].code === 200) {
let allGoods = {
name: '全部商品 ALL',
sort: searchHandler.handleOptsData(params, _.get(result[2], 'data.total', 0)),
list: productProcess.processProductList(_.get(result[2], 'data.product_list', []))
};
_.set(allGoods, 'sort.newPage', true); // 启用新的分页导航
finalResult.allGoods = allGoods;
}
if (result[3].code === 200) {
let groupSort = _.get(result[3], 'data.filter.group_sort', []);
finalResult.leftContent = searchHandler.handleSortData(groupSort, params);
if (finalResult.allGoods) {
Object.assign(finalResult.allGoods, searchHandler.setShopSort(groupSort, params));
}
}
return finalResult;
});
... ...
... ... @@ -45,9 +45,12 @@ const getProductList = (params) => {
*/
const getSortList = (params) => {
let finalParams = {
method: 'web.regular.groupsort'
method: 'app.search.li',
// method: 'app.search.li'
// method: 'web.regular.groupsort',
sales: 'Y', // 在销售商品分类
status: 1, // 上架商品分类
stocknumber: 1 // 过滤掉已售罄
};
Object.assign(finalParams, params);
... ...
... ... @@ -176,7 +176,7 @@ exports.handleOptsData = (params, total, extra) => {
switch (i) {
case 0:
opt.href = handleFilterUrl(params, {order: 's_t_desc'});
opt.href = handleFilterUrl(params, {order: ''});
if (extra === 'discont') { // 如果是折扣专场
opt.name = '全部';
if (_.isEmpty(params.order) || params.order === 's_t_desc') {
... ... @@ -186,13 +186,11 @@ exports.handleOptsData = (params, total, extra) => {
}
} else {
opt.name = '默认';
opt.hasSortOrient = true;
if (_.isEmpty(params.order) || params.order === 's_n_desc') {
opt.active = true;
} else {
opt.active = false;
}
opt.desc = true;
}
break;
case 1:
... ... @@ -306,19 +304,21 @@ exports.handleOptsData = (params, total, extra) => {
total : parseInt(dest.start, 10) + paramsLimit - 1;
}
// 新品
if (extra.new === 'Y') {
dest.checks.push(hadleChecks('new', params));
}
if (extra) {
// 新品
if (extra.new === 'Y') {
dest.checks.push(hadleChecks('new', params));
}
// 打折
if (extra.specialoffer === 'Y') {
dest.checks.push(hadleChecks('specialoffer', params));
}
// 打折
if (extra.specialoffer === 'Y') {
dest.checks.push(hadleChecks('specialoffer', params));
}
// 限量
if (extra.limited === 'Y') {
dest.checks.push(hadleChecks('limited', params));
// 限量
if (extra.limited === 'Y') {
dest.checks.push(hadleChecks('limited', params));
}
}
return dest;
};
... ... @@ -342,7 +342,7 @@ exports.handleSortData = (origin, params) => {
num: value.count,
childList: [
{
name: '全部' + value.sort_name,
name: `全部${value.sort_name}`,
num: value.count,
href: handleFilterUrl(params, {msort: value.sort_id}),
childActive: params.misort === value.sort_id
... ... @@ -372,6 +372,35 @@ exports.handleSortData = (origin, params) => {
};
/**
* 店铺品类聚合
* @param data 分类数据
* @returns {{}}
*/
exports.setShopSort = (data, params) => {
let resData = {};
if (!_.isEmpty(data)) {
let list = [];
_.forEach(data, value => {
_.forEach(value.sub, subValue => {
list.push({
name: subValue.sort_name,
href: handleFilterUrl(params, {msort: value.sort_id, misort: subValue.sort_id}),
curMenu: params.misort === subValue.sort_id
});
});
});
if (list.length) {
_.set(resData, 'goodsMenu.menuList', list);
}
}
return resData;
};
/**
* 处理一般筛选数据
* @param origin 要处理的筛选数据 filter
* @param params 当前 URL 中已有的参数,处理选中状态使用
... ...
... ... @@ -19,23 +19,27 @@ const shopListUrl = '/shoplist';
* 新品上架
*/
const newProducts = (data) => {
let dest = {
name: newProductsName,
list: []
};
let dest = {};
_.forEach(data, (value) => {
if (!_.isEmpty(data)) {
Object.assign(dest, {
name: newProductsName,
list: []
});
_.forEach(data, (value) => {
dest.list.push({
productId: value.productId,
title: value.productName,
productSkn: value.productSkn,
price: '¥' + value.salesPrice,
img: value.src
dest.list.push({
productId: value.productId,
title: value.productName,
productSkn: value.productSkn,
price: '¥' + value.salesPrice,
img: value.src
// url: helpers.getProductUrl(value.productId, value.productSkn, value.productName)
// url: helpers.getProductUrl(value.productId, value.productSkn, value.productName)
});
});
});
}
return dest;
};
... ... @@ -153,7 +157,6 @@ const navigationBar = (data, shopId) => {
const largeSlideImg = (data) => {
let dest = [];
console.log(data);
_.forEach(data, (value) => {
dest.push({
img: value.data[0].src,
... ... @@ -221,7 +224,7 @@ const brandBrowse = (data, params) => {
_.forEach(data, value => {
list.push({
url: helpers.urlFormat('/shoplist', {
url: helpers.urlFormat(shopListUrl, {
shopId: _.get(params, 'shopId', ''),
brand: value.id,
navBar: 1
... ... @@ -288,10 +291,10 @@ exports.getShopDecorator = (data, params, shopId) => {
case 'signboard':
break;
case 'newProducts':
dest.newArrivel = newProducts(info);
Object.assign(dest.newArrivel, newProducts(info));
break;
case 'hotProducts':
dest.hotSingle = hotProducts(info);
Object.assign(dest.hotSingle, hotProducts(info));
break;
case 'goodsTabBar':
tabBar = goodsTabBar(info);
... ... @@ -324,7 +327,5 @@ exports.getShopDecorator = (data, params, shopId) => {
}
});
// console.log(dest);
return dest;
};
... ...
<div class="shop-index-page product-list-page product-page yoho-page center-content home-page">
<div class="center-content clearfix">
{{> common/path-nav}}
... ... @@ -54,7 +53,7 @@
{{> index/floor-header}}
<div class="goods-wrap">
{{> product/goods-list}}
{{> list/shop-list}}
</div>
<div class="loading">
... ...
<div class="fixed-area">
{{# goodsMenu}}
<div class="all-goods-menu">
<span class="menu-tag">所有商品</span>
<ul class="menu-list">
{{#each menuList}}
<li class="{{#if curMenu}} on{{/if}}"><a class="pjax" href="{{href}}">{{name}}</a></li>
{{/each}}
</ul>
<a href="{{url}}" class="more">MORE</a>
</div>
{{/ goodsMenu}}
{{> common/sort-pager}}
</div>
<div class="goods-container clearfix">
{{# list}}
{{> product/good}}
{{/list}}
<div class="good-item-wrapper">
<div class="good-info-main"></div>
<div class="good-select-color"></div>
</div>
</div>
... ...
... ... @@ -372,6 +372,7 @@
li {
display: inline-block;
padding: 0 15px;
vertical-align: middle;
}
.on {
... ... @@ -391,10 +392,6 @@
}
}
.sort-pager .sort-type:first-child .iconfont {
display: inline-block;
}
.loading {
position: relative;
width: 100%;
... ...