Authored by OF1706

service

... ... @@ -8,6 +8,7 @@
const mRoot = '../models';
const search = require(`${mRoot}/search`);
const _ = require('lodash');
const helpers = global.yoho.helpers;
const config = global.yoho.config;
... ... @@ -120,7 +121,6 @@ const searchHistory = (req, res) => {
let history = req.cookies['_History'];
let q = req.query.query || '';
console.log('////////////----------------------');
console.log(history);
console.log('///////////----------------------');
... ... @@ -139,6 +139,7 @@ const searchHistory = (req, res) => {
_.forEach(history, function(item) {
let list = {};
list['keyword'] = item;
list['href'] = helpers.urlFormat('', {query: list['keyword']}, 'search')
data.push(list);
});
let ResData = {};
... ...
... ... @@ -215,24 +215,26 @@ exports.getSearchRecommend = (params) => {
if (result.code === 200) {
let resData = {
defaultTerms: [],
// defaultTerms: [],
hotTerms: [],
guessTerms: []
// 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.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,
// };
// });
console.log(result.data.hotTerms);
resData.hotTerms = _.map(result.data.hotTerms, function(value) {
return {
href: helpers.urlFormat('', {query: value.url}, 'search'),
href: helpers.urlFormat('', {query: value.content}, 'search'),
content: value.content,
sort: value.sort,
status: value.status,
... ... @@ -240,15 +242,15 @@ exports.getSearchRecommend = (params) => {
};
});
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,
};
});
// 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{
... ...
... ... @@ -921,17 +921,27 @@ function searchSuggestRecommend(key) {
};
$.getJSON('//search.yohobuy.com/product/search/recommend?callback=?', param, function(jsonData) {
console.log("*********************");
console.log(jsonData);
console.log("*********************");
var searchSuggestRecommendHtml;
if (jsonData.code === 200) {
// if (jsonData.data && jsonData.data.hotTerms.length && jsonData.data.guessTerms.length) {
if (jsonData.data && jsonData.data.hotTerms.length) {
searchSuggestRecommendHtml = handlebars.compile($searchRecommendHbs.html() || '');
$searchRecommend.html(searchSuggestRecommendHtml(jsonData)).show();
console.log(searchSuggestRecommendHtml(jsonData));
$searchRecommend.html(searchSuggestRecommendHtml(jsonData)).show();
} else {
$searchRecommend.hide();
}
// } else {
// $searchRecommend.hide();
// }
}
});
}
... ...
... ... @@ -415,8 +415,8 @@
float: right;
width: 378px;
padding-right: 18px;
margin-top: 45px;
margin-bottom: 12px;
margin-top: 40px;
/*margin-bottom: 12px;*/
}
.search-2016 {
... ... @@ -456,8 +456,9 @@
.search-suggest {
position: absolute;
width: 320px;
box-sizing: border-box;
border: 1px solid #000;
margin-top: 29px;
margin-top: 27px;
padding-top: 20px;
background-color: #fff;
display: none;
... ... @@ -517,6 +518,7 @@
.search-hot {
width: 320px;
height:16px;
box-sizing: border-box;
overflow: hidden;
display: inline-block;
... ...