Authored by yyq

全球购 URL 伪静态

... ... @@ -19,7 +19,7 @@ exports.list = (req, res, next) => {
req.ctx(globalModel).getGlobalProductListData(req.query, req.yoho).then(result => {
res.render('list/index', Object.assign({
page: 'list',
pageClass: 'global-list-page'
pageClass: 'global-list-page static-list-page'
}, result));
}).catch(next);
};
... ...
... ... @@ -13,12 +13,14 @@ const helpers = global.yoho.helpers;
const homeService = require('./home-service');
const headerModel = require('../../../doraemon/models/header');
const listHandler = require('./list-handler');
const searchHandler = require('./search-handler');
const pager = require(`${global.utils}/pager`).setPager;
const productProcess = require(`${global.utils}/product-process`);
const handleFilterUrl = require(`${global.utils}/parameter`).fullParamToMinPath;
const GlobalApiModel = require('./global-api');
const GLOBAL_LIST_URI = '/product/global/list';
const GLOBAL_LIST_URI = '/list/global';
const _handelGlobalPathNav = (data, channel, page) => {
let rootName = '首页';
... ... @@ -74,7 +76,7 @@ const _checkSortEqual = (rp, params) => {
const _handelGlobalSort = (origin, params, originParams) => {
let all = [{
name: '全部品类',
href: `${searchHandler.handleFilterUrl(params, {}, {msort: true, misort: true, sort: true})}`
href: `${handleFilterUrl(GLOBAL_LIST_URI, params, {}, {msort: true, misort: true, sort: true})}`
}];
let list = [];
let selectSort = {};
... ... @@ -90,7 +92,7 @@ const _handelGlobalSort = (origin, params, originParams) => {
categoryId: value.category_id,
name: `全部${value.category_name}`,
num: value.node_count,
href: `${searchHandler.handleFilterUrl(params, value.relation_parameter)}`,
href: `${handleFilterUrl(GLOBAL_LIST_URI, params, value.relation_parameter)}`,
childActive: _checkSortEqual(value.relation_parameter, originParams)
}
]
... ... @@ -113,7 +115,7 @@ const _handelGlobalSort = (origin, params, originParams) => {
categoryId: subValue.category_id,
name: subValue.category_name,
num: subValue.node_count,
href: `${searchHandler.handleFilterUrl(params, subValue.relation_parameter)}`,
href: `${handleFilterUrl(GLOBAL_LIST_URI, params, subValue.relation_parameter)}`,
childActive: _checkSortEqual(subValue.relation_parameter, originParams)
};
... ... @@ -186,12 +188,6 @@ function getGlobalProductListData(params, yoho) {
let listData = _.get(result.list, 'data', {});
let totalNum = _.get(listData, 'total', 0);
let tip = {
start: (params.page - 1) * limitNum + 1,
total: listData.total || '',
end: _.min([listData.total, limitNum * params.page])
};
// opts 显示新品、折扣
listData.filter = listData.filter || {};
Object.assign(listData.filter, {
... ... @@ -201,10 +197,10 @@ function getGlobalProductListData(params, yoho) {
resData.list = {
leftContent: _handelGlobalSort(_.get(result.fullList, 'data.filter.group_sort', []), dps, params),
filters: searchHandler.handleFilterDataAll(listData, params),
opts: searchHandler.handleOptsData(params, totalNum, listData.filter),
filters: listHandler.handleFilterData(listData, params, GLOBAL_LIST_URI),
opts: listHandler.handleOptsData(params, totalNum, listData.filter, GLOBAL_LIST_URI),
totalCount: totalNum,
footPager: Object.assign({tip: tip}, pager(_.get(listData, 'page_total', 0), params)),
footPager: listHandler.handlePagerData(_.get(listData, 'total', 0), params, false, GLOBAL_LIST_URI),
goods: productProcess.processProductList(_.get(listData, 'product_list', []),
Object.assign({showDiscount: false, isGlobal: true}, params)),
hasNextPage: searchHandler.handleNextPage(params, totalNum),
... ...
... ... @@ -16,12 +16,25 @@ const indexUrl = {
const parameter = require(`${global.utils}/parameter`);
const handleFilterUrl = parameter.fullParamToMinPath;
// 页面商品数量
const pageSizeType = [40, 100, 200];
const handleFilterUrl = parameter.fullParamToMinPath;
const brandIndex = [{
index: 'all',
name: '全部'
}, {
index: '0-9',
name: '0~9'
}];
// 品牌索引数据处理
for (let i = 65; i < 91; i++) {
brandIndex.push({
index: String.fromCharCode(i).toLowerCase(),
name: String.fromCharCode(i)
});
}
/**
* 根据页面设置面包屑导航
... ... @@ -195,6 +208,10 @@ class FilterTools {
this.origin = origin;
this.params = params;
this.baseUrl = baseUrl;
if (+params.page < 2) {
_.unset(params, 'page');
}
}
handleFilterCheckedConditions() {
let {baseUrl, origin, params} = this;
... ... @@ -333,30 +350,53 @@ class FilterTools {
handleFilterBrand() { // 组装brand筛选数据
let {baseUrl, origin, params} = this;
const filter = _.get(origin, 'filter', {});
const brands = {};
if (!filter.brand || !filter.brand.length) {
return false;
}
const brands = [];
const defaultBrands = [];
const brandsShow = [];
const href = handleFilterUrl(baseUrl, params, {brand: '${brand}'});
const brandids = _.split(params.brand, ',');
_.each(filter.brand, brand => {
brands.push({
let brandItem = {
name: brand.brand_name,
href: href.replace('${brand}', _.replace(brand.id, '-', '__')), // 替换全球购品牌id中-
checked: _.some(brandids, bid => _.parseInt(bid) === brand.id)
});
if (brands.length >= 10) {
return false;
checked: _.some(brandids, bid => _.parseInt(bid) === +brand.id),
id: brand.id
};
if (brand.brand_alif) {
if (!_.isNaN(parseInt(brand.brand_alif, 10))) {
brandItem.index = '0-9';
} else {
brandItem.index = brand.brand_alif.toLowerCase();
}
}
brandsShow.push(brandItem);
if (brandsShow.length <= 10) {
defaultBrands.push(brandItem);
}
});
return {
default: brands,
showMore: brands.length > 9,
showMulti: brands.length > 9,
if (brandsShow.length > 10) {
_.assign(brands, {
showMore: true,
showMulti: true,
brandIndex: brandIndex || []
});
}
return _.assign(brands, {
default: defaultBrands,
brandsShow: brandsShow,
seatUrl: handleFilterUrl(baseUrl, params, {brand: '{seat}'})
};
});
}
handleFilterSizes() { // 组装sizes筛选数据
let {baseUrl, origin, params} = this;
... ...
... ... @@ -97,6 +97,8 @@ router.post('/detail/notify/add', auth, notify.add); // 增
router.post('/detail/notify/cancel', auth, notify.cancel); // 删除到货通知
// 全球购routers
router.get('/list/global', globalCtrl.list); // 全球购列表页
router.get('/list/global/:pathQs', paramParse, globalCtrl.list); // 全球购列表页
router.get('/global/list', globalCtrl.list); // 全球购列表页
router.get('/global/detail', globalCtrl.detail);
router.get(/\/global\/([\d]+)(.*)/, globalCtrl.detail);
... ...
... ... @@ -16,7 +16,6 @@ const minToFullMap = {
cn: 'channel',
gd: 'gender',
sn: 'sort_name',
pa: 'phrase',
ci: 'category_id',
so: 'sort',
ms: 'msort',
... ... @@ -35,7 +34,15 @@ const minToFullMap = {
st: 'style',
sd: 'standard',
si: 'specialsale_id',
sf: 'specialoffer'
sf: 'specialoffer',
fp: 'filter_poolId',
pp: 'productPool',
pm: 'promotion',
sh: 'shop_id',
cc: 'coupon_code',
cd: 'coupon_id',
pd: 'p_d',
ol: 'outlets'
};
const fullToMinMap = _.transform(minToFullMap, (result, value, key) => {
... ...