Authored by ccbikai(👎🏻🍜)

Merge remote-tracking branch 'origin/feature/hotWordSearch' into release/5.5

@@ -170,10 +170,10 @@ const _getLeftNav = (choosed) => { @@ -170,10 +170,10 @@ const _getLeftNav = (choosed) => {
170 /** 170 /**
171 * 获取热门搜索 171 * 获取热门搜索
172 **/ 172 **/
173 -const _getSearchIndex = () => {  
174 - return API.get('', { 173 +const _getSearchIndex = (params) => {
  174 + return API.get('', _.assign({
175 method: 'app.search.getTerms' 175 method: 'app.search.getTerms'
176 - }, { 176 + }, params), {
177 cache: true 177 cache: true
178 }).then((result) => { 178 }).then((result) => {
179 if (result && result.code === 200) { 179 if (result && result.code === 200) {
@@ -270,10 +270,11 @@ let getChannelData = (params) => { @@ -270,10 +270,11 @@ let getChannelData = (params) => {
270 var channelData = {}; 270 var channelData = {};
271 let navGender = _.cloneDeep(params.gender); 271 let navGender = _.cloneDeep(params.gender);
272 272
273 - return Promise.all([getChannelResource(params), _getLeftNav(navGender), _getSearchIndex()]).then((data) => { 273 + return Promise.all([getChannelResource(params), _getLeftNav(navGender), _getSearchIndex(params)]).then((data) => {
274 channelData.content = data[0] || []; // 资源位数据 274 channelData.content = data[0] || []; // 资源位数据
275 channelData.sideNav = data[1] || []; // 侧边栏数据 275 channelData.sideNav = data[1] || []; // 侧边栏数据
276 - channelData.defaultTerms = (data[2] && data[2].defaultTerms && data[2].defaultTerms.length !== 0) ? data[2].defaultTerms[0].content : '搜索商品、品牌'; 276 + channelData.defaultTerms = (data[2] && data[2].defaultTerms && data[2].defaultTerms.length) ?
  277 + data[2].defaultTerms[0].content : '搜索商品、品牌';
277 return channelData; 278 return channelData;
278 }); 279 });
279 }; 280 };
@@ -157,7 +157,11 @@ const index = (req, res, next) => { @@ -157,7 +157,11 @@ const index = (req, res, next) => {
157 if (_.get(req, 'app.locals.wap.search.removeHotSearch', false)) { 157 if (_.get(req, 'app.locals.wap.search.removeHotSearch', false)) {
158 render([]); 158 render([]);
159 } else { 159 } else {
160 - searchModel.getSearchIndex(uid).then((result) => { 160 +
  161 + searchModel.getSearchIndex({
  162 + gender: req.yoho.channel || 'boys',
  163 + uid: uid
  164 + }).then((result) => {
161 render(result); 165 render(result);
162 }).catch(next); 166 }).catch(next);
163 } 167 }
@@ -172,9 +176,8 @@ const index = (req, res, next) => { @@ -172,9 +176,8 @@ const index = (req, res, next) => {
172 pageFooter: true, 176 pageFooter: true,
173 width750: true, 177 width750: true,
174 search: { 178 search: {
175 - defaultTerms: (result && result.hotTerms &&  
176 - result.hotTerms.defaultTerms && result.hotTerms.defaultTerms.length !== 0) ?  
177 - result.hotTerms.defaultTerms[0].content : '', 179 + defaultTerms: (result && result.defaultTerms && result.defaultTerms.length) ?
  180 + result.defaultTerms[0].content : '',
178 url: helpers.urlFormat('', null, 'search'), 181 url: helpers.urlFormat('', null, 'search'),
179 hotTerms: result.hotTerms, 182 hotTerms: result.hotTerms,
180 wantTerms: result.guessTerms 183 wantTerms: result.guessTerms
@@ -300,11 +300,22 @@ const getAllBrandNames = () => { @@ -300,11 +300,22 @@ const getAllBrandNames = () => {
300 /** 300 /**
301 * 搜索主页 301 * 搜索主页
302 */ 302 */
303 -const getSearchIndex = (uid) => {  
304 - return api.get('', {  
305 - method: 'app.search.getTerms',  
306 - uid: uid  
307 - }, { 303 +const getSearchIndex = (params) => {
  304 + let channels = {
  305 + boys: 1,
  306 + girl: 2,
  307 + kids: 3,
  308 + lifestyle: 4
  309 + };
  310 +
  311 + if (params.gender && channels[params.gender]) {
  312 + params.yh_channel = channels[params.gender];
  313 + delete params.gender;
  314 + }
  315 +
  316 + return api.get('', _.assign({
  317 + method: 'app.search.getTerms'
  318 + }, params), {
308 cache: true 319 cache: true
309 }).then((result) => { 320 }).then((result) => {
310 if (result && result.code === 200) { 321 if (result && result.code === 200) {
@@ -15,15 +15,9 @@ const domains = { @@ -15,15 +15,9 @@ const domains = {
15 liveApi: 'http://testapi.live.yohops.com:9999/', 15 liveApi: 'http://testapi.live.yohops.com:9999/',
16 singleApi: 'http://api-test3.yohops.com:9999/', 16 singleApi: 'http://api-test3.yohops.com:9999/',
17 17
18 - // api: 'http://api.yoho.yohoops.org/',  
19 - // service: 'http://service.yoho.yohoops.org/',  
20 - // liveApi: 'http://api.live.yoho.cn/',  
21 - // singleApi: 'http://single.yoho.cn/',  
22 -  
23 - imSocket: 'wss://imsocket.yohobuy.com:443',  
24 - imCs: 'https://imhttp.yohobuy.com/api',  
25 - imServer: 'https://imhttp.yohobuy.com/server'  
26 - 18 + imSocket: 'ws://socket.yohobuy.com:10240',
  19 + imCs: 'https://im.yohobuy.com/api',
  20 + imServer: 'https://im.yohobuy.com/server'
27 }; 21 };
28 22
29 module.exports = { 23 module.exports = {