Authored by 沈志敏

fix bug

... ... @@ -4,6 +4,32 @@ const api = global.yoho.API;
const prettyFilter = require(`${global.utils}/beautify/filters`);
const processProductList = require(`${global.utils}/beautify/product`);
// 排序转换
const getTypeCont = (type, order) => {
switch (type) {
case 'price':
return order === '0' ? 's_p_desc' : 's_p_asc';
case 'discount':
return order === '0' ? 'p_d_desc' : 'p_d_asc';
case 'sale':
return order === '0' ? 's_n_desc' : 's_n_asc';
case 'newest':
return order === '0' ? 's_t_desc' : 's_t_asc';
case 'stock':
return order === '0' ? 's_s_desc' : 's_s_asc';
case 'all':
return order === '0' ? 'd_s_desc' : 'd_s_asc';
case 'category':
return order === '0' ? 's_t_desc' : 's_t_asc';
case 'new':
return order === '0' ? 's_t_desc' : 's_t_asc';
case 'hot':
return order === '0' ? 's_n_desc' : 's_n_asc';
default:
return order === '0' ? 's_t_desc' : 's_t_asc';
}
};
/* 查询最新产品列表 */
exports.getNewData = (params) => {
if (params.hasOwnProperty('priceRange')) {
... ... @@ -11,6 +37,12 @@ exports.getNewData = (params) => {
delete params.priceRange;
}
if (params.order) {
params.order = getTypeCont(params.type || '', params.order);
} else {
params.order = 's_t_asc';
}
params = Object.assign({
method: 'app.search.newProduct',
}, params);
... ... @@ -49,4 +81,4 @@ exports.getNewData = (params) => {
// data: filterConfig
// };
// });
// };
\ No newline at end of file
// };
... ...
... ... @@ -47,8 +47,11 @@ module.exports = (Vue) => {
value = value.replace(protocol, '');
// 新品抢先看
if (value === 'm.yohobuy.com/product/blknew') {
return `${protocol}m.yohoblk.com/new`;
let query = value.match(/^m\.yohobuy\.com\/product\/blknew(\?.*)?/);
if (query) {
query = query[1] || '';
return `${protocol}m.yohoblk.com/new${query}`;
}
// 全部品类
... ... @@ -75,14 +78,12 @@ module.exports = (Vue) => {
}
} else if (subDomain === 'list') {
// 品类
let query = value.match(/\?.*/);
query = value.match(/\?.*/);
query = query ? query[0] : '';
return `${protocol}m.yohoblk.com/product/list${query}`;
} else {
// 品牌
let query = value.match(/\?.*/);
query = value.match(/\?.*/);
query = query ? query[0] : '';
return `${protocol}m.yohoblk.com/product/shop/${subDomain}${query}`;
}
... ... @@ -254,4 +255,4 @@ module.exports = (Vue) => {
return en + cn;
});
};
};
\ No newline at end of file
... ...