Authored by 沈志敏

fix bug

@@ -4,6 +4,32 @@ const api = global.yoho.API; @@ -4,6 +4,32 @@ const api = global.yoho.API;
4 const prettyFilter = require(`${global.utils}/beautify/filters`); 4 const prettyFilter = require(`${global.utils}/beautify/filters`);
5 const processProductList = require(`${global.utils}/beautify/product`); 5 const processProductList = require(`${global.utils}/beautify/product`);
6 6
  7 +// 排序转换
  8 +const getTypeCont = (type, order) => {
  9 + switch (type) {
  10 + case 'price':
  11 + return order === '0' ? 's_p_desc' : 's_p_asc';
  12 + case 'discount':
  13 + return order === '0' ? 'p_d_desc' : 'p_d_asc';
  14 + case 'sale':
  15 + return order === '0' ? 's_n_desc' : 's_n_asc';
  16 + case 'newest':
  17 + return order === '0' ? 's_t_desc' : 's_t_asc';
  18 + case 'stock':
  19 + return order === '0' ? 's_s_desc' : 's_s_asc';
  20 + case 'all':
  21 + return order === '0' ? 'd_s_desc' : 'd_s_asc';
  22 + case 'category':
  23 + return order === '0' ? 's_t_desc' : 's_t_asc';
  24 + case 'new':
  25 + return order === '0' ? 's_t_desc' : 's_t_asc';
  26 + case 'hot':
  27 + return order === '0' ? 's_n_desc' : 's_n_asc';
  28 + default:
  29 + return order === '0' ? 's_t_desc' : 's_t_asc';
  30 + }
  31 +};
  32 +
7 /* 查询最新产品列表 */ 33 /* 查询最新产品列表 */
8 exports.getNewData = (params) => { 34 exports.getNewData = (params) => {
9 if (params.hasOwnProperty('priceRange')) { 35 if (params.hasOwnProperty('priceRange')) {
@@ -11,6 +37,12 @@ exports.getNewData = (params) => { @@ -11,6 +37,12 @@ exports.getNewData = (params) => {
11 delete params.priceRange; 37 delete params.priceRange;
12 } 38 }
13 39
  40 + if (params.order) {
  41 + params.order = getTypeCont(params.type || '', params.order);
  42 + } else {
  43 + params.order = 's_t_asc';
  44 + }
  45 +
14 params = Object.assign({ 46 params = Object.assign({
15 method: 'app.search.newProduct', 47 method: 'app.search.newProduct',
16 }, params); 48 }, params);
@@ -49,4 +81,4 @@ exports.getNewData = (params) => { @@ -49,4 +81,4 @@ exports.getNewData = (params) => {
49 // data: filterConfig 81 // data: filterConfig
50 // }; 82 // };
51 // }); 83 // });
52 -// };  
  84 +// };
@@ -47,8 +47,11 @@ module.exports = (Vue) => { @@ -47,8 +47,11 @@ module.exports = (Vue) => {
47 value = value.replace(protocol, ''); 47 value = value.replace(protocol, '');
48 48
49 // 新品抢先看 49 // 新品抢先看
50 - if (value === 'm.yohobuy.com/product/blknew') {  
51 - return `${protocol}m.yohoblk.com/new`; 50 + let query = value.match(/^m\.yohobuy\.com\/product\/blknew(\?.*)?/);
  51 +
  52 + if (query) {
  53 + query = query[1] || '';
  54 + return `${protocol}m.yohoblk.com/new${query}`;
52 } 55 }
53 56
54 // 全部品类 57 // 全部品类
@@ -75,14 +78,12 @@ module.exports = (Vue) => { @@ -75,14 +78,12 @@ module.exports = (Vue) => {
75 } 78 }
76 } else if (subDomain === 'list') { 79 } else if (subDomain === 'list') {
77 // 品类 80 // 品类
78 - let query = value.match(/\?.*/);  
79 - 81 + query = value.match(/\?.*/);
80 query = query ? query[0] : ''; 82 query = query ? query[0] : '';
81 return `${protocol}m.yohoblk.com/product/list${query}`; 83 return `${protocol}m.yohoblk.com/product/list${query}`;
82 } else { 84 } else {
83 // 品牌 85 // 品牌
84 - let query = value.match(/\?.*/);  
85 - 86 + query = value.match(/\?.*/);
86 query = query ? query[0] : ''; 87 query = query ? query[0] : '';
87 return `${protocol}m.yohoblk.com/product/shop/${subDomain}${query}`; 88 return `${protocol}m.yohoblk.com/product/shop/${subDomain}${query}`;
88 } 89 }
@@ -254,4 +255,4 @@ module.exports = (Vue) => { @@ -254,4 +255,4 @@ module.exports = (Vue) => {
254 255
255 return en + cn; 256 return en + cn;
256 }); 257 });
257 -}; 258 +};