Authored by 郭成尧

Merge branch 'feature/wantSearch' into 'release/5.3.1'

搜索接口调整



See merge request !63
... ... @@ -155,8 +155,8 @@ const index = (req, res, next) => {
search: {
defaultTerms: (result && result.hotTerms && result.hotTerms.defaultTerms && result.hotTerms.defaultTerms.length !== 0) ? result.hotTerms.defaultTerms[0].content : '',
url: helpers.urlFormat('', null, 'search'),
hotTerms: result.hotTerms.hotTerms,
wantTerms: result.wantTerms.guessTerms
hotTerms: result.hotTerms,
wantTerms: result.guessTerms
}
});
... ...
... ... @@ -259,34 +259,16 @@ const getAllBrandNames = () => {
};
/**
* 获取猜你想找
**/
const getWantSearch = (uid) => {
* 搜索主页
*/
const getSearchIndex = (uid) => {
return api.get('', {
method: 'app.search.getSomeTerms',
method: 'app.search.getTerms',
uid: uid
}, {
cache: true
}).then((result) => {
if (result && result.code === 200) {
return result.data;
} else {
logger.error('Hot Search return code is not 200');
return {};
}
});
};
/**
* 获取热门搜索
**/
const getHotSearch = () => {
return api.get('', {
method: 'app.search.getTerms'
}, {
cache: true
}).then((result) => {
if (result && result.code === 200) {
if (result.data.hotTerms && result.data.hotTerms.length > 10) {
result.data.hotTerms = result.data.hotTerms.slice(0, 10);
}
... ... @@ -299,18 +281,6 @@ const getHotSearch = () => {
};
/**
* 搜索主页
*/
const getSearchIndex = (uid) => {
return Promise.all([getHotSearch(), getWantSearch(uid)]).then((result) => {
return {
hotTerms: result[0],
wantTerms: result[1]
};
});
};
/**
* 获取联想词
* @param params
* @returns {*|Promise.<TResult>}
... ...