Authored by 周少峰

search from

@@ -76,7 +76,7 @@ const getListData = (params, channel) => { @@ -76,7 +76,7 @@ const getListData = (params, channel) => {
76 let apiMethod = [ 76 let apiMethod = [
77 headerModel.requestHeaderData(channel), 77 headerModel.requestHeaderData(channel),
78 searchApi.getSortList(Object.assign({}, {msort: '', misort: ''})), 78 searchApi.getSortList(Object.assign({}, {msort: '', misort: ''})),
79 - searchApi.getProductList(searchParams) 79 + searchApi.getProductList(searchParams, 'categoryList')
80 ]; 80 ];
81 81
82 // 搜索分类介绍和广告 82 // 搜索分类介绍和广告
@@ -290,7 +290,7 @@ const getBrandData = (params, extra, channel) => { @@ -290,7 +290,7 @@ const getBrandData = (params, extra, channel) => {
290 let apiMethod = [ 290 let apiMethod = [
291 headerModel.requestHeaderData(channel), 291 headerModel.requestHeaderData(channel),
292 searchApi.getSortList(queryBase), 292 searchApi.getSortList(queryBase),
293 - searchApi.getProductList(Object.assign(searchParams, queryBase)) 293 + searchApi.getProductList(Object.assign(searchParams, queryBase), 'brand')
294 ]; 294 ];
295 295
296 if (queryBase.brand) { 296 if (queryBase.brand) {
@@ -588,7 +588,7 @@ const getShopData = (shopId, channel, params, shopInfo) => { @@ -588,7 +588,7 @@ const getShopData = (shopId, channel, params, shopInfo) => {
588 searchApi.getShopDecorator(shopId), // 店铺装修数据 588 searchApi.getShopDecorator(shopId), // 店铺装修数据
589 searchApi.getProductList(Object.assign({ 589 searchApi.getProductList(Object.assign({
590 shop_id: shopId 590 shop_id: shopId
591 - }, params)), // 搜索店铺商品 591 + }, params), 'shop'), // 搜索店铺商品
592 searchApi.getShopBrands(shopId), // 店铺品牌数据 592 searchApi.getShopBrands(shopId), // 店铺品牌数据
593 shopApi.shopCouponListAsync(shopId) // 店铺优惠券数据 593 shopApi.shopCouponListAsync(shopId) // 店铺优惠券数据
594 ]).then(result => { 594 ]).then(result => {
@@ -647,7 +647,7 @@ const getShopData = (shopId, channel, params, shopInfo) => { @@ -647,7 +647,7 @@ const getShopData = (shopId, channel, params, shopInfo) => {
647 searchApi.getProductList({ 647 searchApi.getProductList({
648 viewNum: sknList.length, 648 viewNum: sknList.length,
649 query: _.join(_.uniq(sknList), ',') 649 query: _.join(_.uniq(sknList), ',')
650 - }) 650 + }, 'shop')
651 ]; 651 ];
652 652
653 if (result[3].code === 200 && result[3].data) { 653 if (result[3].code === 200 && result[3].data) {
@@ -757,7 +757,7 @@ const getShopGoodsData = (shopId, channel, params) => { @@ -757,7 +757,7 @@ const getShopGoodsData = (shopId, channel, params) => {
757 return Promise.all([ 757 return Promise.all([
758 searchApi.getProductList(Object.assign({ 758 searchApi.getProductList(Object.assign({
759 shop_id: shopId 759 shop_id: shopId
760 - }, params)), // 搜索店铺商品 760 + }, params), 'shop'), // 搜索店铺商品
761 searchApi.getSortList({shop_id: shopId}) // 根据店铺id获取分类 761 searchApi.getSortList({shop_id: shopId}) // 根据店铺id获取分类
762 ]).then(result => { 762 ]).then(result => {
763 // 获取商品数据和顶部筛选条件 763 // 获取商品数据和顶部筛选条件
@@ -793,14 +793,14 @@ const getShopListData = (channel, params, uid) => { @@ -793,14 +793,14 @@ const getShopListData = (channel, params, uid) => {
793 searchApi.getShopDecorator(shopId), // 店铺装修数据 793 searchApi.getShopDecorator(shopId), // 店铺装修数据
794 searchApi.getShopInfo(shopId, uid), // 店铺介绍 794 searchApi.getShopInfo(shopId, uid), // 店铺介绍
795 searchApi.getProductList(Object.assign({shop_id: shopId}, params, 795 searchApi.getProductList(Object.assign({shop_id: shopId}, params,
796 - {limit: (params.limit || 60) - 1})), // 搜索店铺商品 796 + {limit: (params.limit || 60) - 1}), 'shop'), // 搜索店铺商品
797 searchApi.getSortList({shop_id: shopId}) // 店铺分类 797 searchApi.getSortList({shop_id: shopId}) // 店铺分类
798 ]; 798 ];
799 799
800 if (_.has(params, 'query')) { 800 if (_.has(params, 'query')) {
801 // 如果有店内搜索,则并行查询店铺所有商品,搜索不到商品则显示所有商品 801 // 如果有店内搜索,则并行查询店铺所有商品,搜索不到商品则显示所有商品
802 apiArr.push(searchApi.getProductList(Object.assign({shop_id: shopId}, 802 apiArr.push(searchApi.getProductList(Object.assign({shop_id: shopId},
803 - params, {query: ''}))); // 搜索店铺所有商品 803 + params, {query: ''}), 'shop')); // 搜索店铺所有商品
804 } 804 }
805 805
806 806
@@ -554,7 +554,7 @@ exports.getSaleSpecialData = (id, params, channel) => { @@ -554,7 +554,7 @@ exports.getSaleSpecialData = (id, params, channel) => {
554 } 554 }
555 555
556 // 搜索sale活动商品 556 // 搜索sale活动商品
557 - apiList.push(searchApi.getProductList(condition)); 557 + apiList.push(searchApi.getProductList(condition, 'promotion'));
558 } 558 }
559 559
560 return Promise.all(apiList).then(result => { 560 return Promise.all(apiList).then(result => {
@@ -94,7 +94,7 @@ const setSearchData = (result, params, channel) => { @@ -94,7 +94,7 @@ const setSearchData = (result, params, channel) => {
94 finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.search, 'goods'))}; 94 finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.search, 'goods'))};
95 } 95 }
96 return finalResult; 96 return finalResult;
97 -} 97 +};
98 98
99 /** 99 /**
100 * 转换价格 100 * 转换价格
@@ -135,7 +135,7 @@ exports.getSearchData = (params, channel) => { @@ -135,7 +135,7 @@ exports.getSearchData = (params, channel) => {
135 let apiMethod = [ 135 let apiMethod = [
136 headerModel.requestHeaderData(channel), 136 headerModel.requestHeaderData(channel),
137 searchApi.getSortList(Object.assign({}, searchParams, {msort: '', misort: '', sort: ''})), 137 searchApi.getSortList(Object.assign({}, searchParams, {msort: '', misort: '', sort: ''})),
138 - searchApi.getProductList(searchParams), 138 + searchApi.getProductList(searchParams, 'fuzzySearch'),
139 searchApi.getShopList(params) 139 searchApi.getShopList(params)
140 ]; 140 ];
141 141
@@ -144,10 +144,10 @@ exports.getSearchData = (params, channel) => { @@ -144,10 +144,10 @@ exports.getSearchData = (params, channel) => {
144 return searchApi.getSortList(Object.assign({}, searchParams, {msort: '', 144 return searchApi.getSortList(Object.assign({}, searchParams, {msort: '',
145 query: _.get(result, '[2]data.suggestion.terms_suggestion[0]', ''), 145 query: _.get(result, '[2]data.suggestion.terms_suggestion[0]', ''),
146 misort: '', sort: ''})).then(subRes => { 146 misort: '', sort: ''})).then(subRes => {
147 - result[1] = subRes; 147 + result[1] = subRes;
148 148
149 - return setSearchData(result, params, channel);  
150 - }); 149 + return setSearchData(result, params, channel);
  150 + });
151 } 151 }
152 152
153 return setSearchData(result, params, channel); 153 return setSearchData(result, params, channel);
@@ -294,8 +294,8 @@ exports.getSearchLessProduct = (channelNum, uid, udid, page) => { @@ -294,8 +294,8 @@ exports.getSearchLessProduct = (channelNum, uid, udid, page) => {
294 img: it.default_images ? helpers.image(it.default_images, 180, 240) : '', 294 img: it.default_images ? helpers.image(it.default_images, 180, 240) : '',
295 alt: it.product_name, 295 alt: it.product_name,
296 price: '¥' + transPrice(it.sales_price), 296 price: '¥' + transPrice(it.sales_price),
297 - marketPrice: transPrice(it.market_price) === transPrice(it.sales_price)  
298 - ? false : ('¥' + transPrice(it.market_price)) 297 + marketPrice: transPrice(it.market_price) === transPrice(it.sales_price) ?
  298 + false : ('¥' + transPrice(it.market_price))
299 }; 299 };
300 300
301 let firstGoods = it.goods_list && it.goods_list[0]; 301 let firstGoods = it.goods_list && it.goods_list[0];