Authored by OF1706

recommend list

... ... @@ -112,7 +112,7 @@ const serachFilterBrands = (req, res, next) => {
* @param {[type]} res [description]
* @return {[type]} [description]
*/
const suggestHistory = (req, res, next) => {
const searchHistory = (req, res, next) => {
search.getSearchHistory(req.query).then(result => {
if (req.query.json === '1') {
... ... @@ -121,7 +121,7 @@ const suggestHistory = (req, res, next) => {
let dest = {
code: 200,
message: 'suggest',
message: 'history',
data: result || ''
};
... ... @@ -138,16 +138,17 @@ const suggestHistory = (req, res, next) => {
* @param {[type]} res [description]
* @return {[type]} [description]
*/
const suggestRecommend = (req, res, next) => {
const searchRecommend = (req, res, next) => {
search.getSearchRecommend(req.query).then(result => {
// console.log(JSON.stringify(result));
if (req.query.json === '1') {
return res.send(result);
}
let dest = {
code: 200,
message: 'suggest',
message: 'recommend',
data: result || ''
};
... ... @@ -162,6 +163,6 @@ module.exports = {
suggest,
suggest4Old,
serachFilterBrands,
suggestHistory,
suggestRecommend
searchHistory,
searchRecommend
};
... ...
... ... @@ -424,7 +424,7 @@ const getBrands4Filter = (params) => {
* 搜索 历史记录提示
* @return
*/
const getSuggestHistory = (params) => {
const getSearchHistory = (params) => {
let finalParams = {
method: 'app.search.getTerms',
keyword: params.keyword || ''
... ... @@ -437,10 +437,14 @@ const getSuggestHistory = (params) => {
* 搜索 热门搜索和默认搜索
* @return
*/
const getSuggestRecommend = (params) => {
const getSearchRecommend = (params) => {
let finalParams = {
method: 'app.search.getTerms',
keyword: params.keyword || ''
content: params.content || '',
sort: params.sort,
status: params.status,
type: params.type
};
return api.get('', finalParams, config.apiCache);
... ... @@ -471,6 +475,6 @@ module.exports = {
getBrands4Filter,
getProductListOrig,
getSearchCacheKey,
getSuggestHistory,
getSuggestRecommend
getSearchHistory,
getSearchRecommend
};
... ...
... ... @@ -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;
});
};
... ...
... ... @@ -87,8 +87,8 @@ router.get('/search/index', gbk2utf, search.index);
router.get('/search/filter/brands', search.serachFilterBrands);
router.get('/search/suggest', search.suggest); // 搜索提示
router.get('/api/suggest', search.suggest4Old);
router.get('/search/suggest/history', search.suggestHistory); // 搜索历史提示
router.get('/search/suggest/recommend', search.suggestRecommend); // 热门搜索和默认搜索
router.get('/search/history', search.searchHistory); // 搜索历史提示
router.get('/search/recommend', search.searchRecommend); // 热门搜索和默认搜索
// 商品分类列表页
router.get('/list/index', gbk2utf, list.index);
... ...
... ... @@ -17,14 +17,14 @@ module.exports = {
cookieDomain: '.yohobuy.com',
domains: {
// test3
singleApi: 'http://api-test3.yohops.com:9999/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
// singleApi: 'http://api-test3.yohops.com:9999/',
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
// // prod
// singleApi: 'http://single.yoho.cn/',
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
singleApi: 'http://single.yoho.cn/',
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
// gray
// singleApi: 'http://single.gray.yohops.com/',
... ...
... ... @@ -129,11 +129,26 @@
<a class="search-btn" href="javascript:submitSearch();"></a>
</form>
<ul class="search-hot">
<li><a href=""><span>8888</span></a></li>
<li><a href=""><span>8888</span></a></li>
<li><a href=""><span>8888</span></a></li>
<li><a href=""><span>8888</span></a></li>
<li><a href=""><span>8888</span></a></li>
<script type="text/html" id="search-suggest-recommend">
\{{#data}}
\{{#hotTerms}}
<li>
<a style="display: block;" href="\{{href}}" title="\{{content}}"
act="\{{href}}">
<span class="searchvalue">\{{content}}</span>
</a>
</li>
\{{/hotTerms}}
\{{#guessTerms}}
<li>
<a style="display: block;" href="\{{href}}" title="\{{content}}"
act="\{{href}}">
<span class="searchvalue">\{{content}}</span>
</a>
</li>
\{{/guessTerms}}
\{{/data}}
</script>
</ul>
</div>
... ... @@ -345,16 +360,7 @@
</li>
\{{/data}}
</script>
<script type="text/html" id="search-suggest-recommend">
\{{#data}}
<li>
<a style="display: block;" href="\{{href}}" title="\{{keyword}}"
act="\{{href}}">
<span class="searchvalue">\{{keyword}}</span>
</a>
</li>
\{{/data}}
</script>
</div>
<input id="api-domain" type="hidden" value="{{apiDomain}}">
... ...