...
|
...
|
@@ -6,6 +6,7 @@ |
|
|
'use strict';
|
|
|
const utils = '../../../utils';
|
|
|
const api = global.yoho.API;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const saleApi = require('./sale-api');
|
|
|
const searchApi = require('./search-api');
|
|
|
const headerModel = require('../../../doraemon/models/header');
|
...
|
...
|
@@ -190,14 +191,14 @@ exports.getBrands4Filter = (params) => { |
|
|
* 搜索 历史记录提示
|
|
|
*/
|
|
|
exports.getSearchHistory = (params) => {
|
|
|
return searchApi.getSuggestHistory(params).then(result => {
|
|
|
let dest = [];
|
|
|
return searchApi.getSearchHistory(params).then(result => {
|
|
|
let resData = [];
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
dest = searchHandler.handleSuggest(result.data);
|
|
|
resData = searchHandler.handleSuggest(result.data);
|
|
|
}
|
|
|
|
|
|
return dest;
|
|
|
return resData;
|
|
|
});
|
|
|
};
|
|
|
|
...
|
...
|
@@ -208,14 +209,52 @@ exports.getSearchHistory = (params) => { |
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
exports.getSearchRecommend = (params) => {
|
|
|
return searchApi.getSuggestRecommend(params).then(result => {
|
|
|
let dest = [];
|
|
|
return searchApi.getSearchRecommend(params).then(result => {
|
|
|
|
|
|
// console.log(result);
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
dest = searchHandler.handleSuggest(result.data);
|
|
|
let resData = {
|
|
|
defaultTerms: [],
|
|
|
hotTerms: [],
|
|
|
guessTerms: []
|
|
|
};
|
|
|
|
|
|
resData.defaultTerms = _.map(result.data.defaultTerms, function(value) {
|
|
|
return {
|
|
|
href: helpers.urlFormat('', {query: value.url}, 'search'),
|
|
|
content: value.content,
|
|
|
sort: value.sort,
|
|
|
status: value.status,
|
|
|
type: value.type,
|
|
|
};
|
|
|
});
|
|
|
|
|
|
resData.hotTerms = _.map(result.data.hotTerms, function(value) {
|
|
|
return {
|
|
|
href: helpers.urlFormat('', {query: value.url}, 'search'),
|
|
|
content: value.content,
|
|
|
sort: value.sort,
|
|
|
status: value.status,
|
|
|
type: value.type,
|
|
|
};
|
|
|
});
|
|
|
|
|
|
resData.guessTerms = _.map(result.data.guessTerms, function(value) {
|
|
|
return {
|
|
|
href: helpers.urlFormat('', {query: value.url}, 'search'),
|
|
|
content: value.content,
|
|
|
sort: value.sort,
|
|
|
status: value.status,
|
|
|
type: value.type,
|
|
|
};
|
|
|
});
|
|
|
|
|
|
return resData;
|
|
|
}else{
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
return dest;
|
|
|
});
|
|
|
};
|
|
|
|
...
|
...
|
|