diff --git a/apps/product/controllers/search.js b/apps/product/controllers/search.js index 1550a67..417eee9 100644 --- a/apps/product/controllers/search.js +++ b/apps/product/controllers/search.js @@ -145,8 +145,8 @@ const searchHistory = (req, res) => { }); ResData['data'] = data; //eslint-disable-line - res.type('text/plain'); - res.send(JSON.stringify(ResData)); + res.type('text/javascript'); + res.send(req.query.callback + '(' + JSON.stringify(ResData) + ')'); }; diff --git a/public/js/header.js b/public/js/header.js index 9cd0f4e..eadd286 100644 --- a/public/js/header.js +++ b/public/js/header.js @@ -909,9 +909,12 @@ function actionAddKeyWords() { */ function searchSuggestHistory() { + var param = { + return_type: 'jsonp', + query: encodeURIComponent($searchKey.val()) || '' + }; - $.getJSON('//search.yohobuy.com/product/search/history?query=' + - encodeURIComponent($searchKey.val()), function(jsonData) { + $.getJSON('//search.yohobuy.com/product/search/history?callback=?', param, function(jsonData) { if ($searchKey.val() === '') { @@ -941,7 +944,7 @@ function searchSuggestHistory() { * @return {[type]} [description] */ -$searchKey.mouseenter(function() { +$searchKey.focus(function() { var val = $.trim($(this).val()); diff --git a/yohobuypc_node.conf b/yohobuypc_node.conf new file mode 100644 index 0000000..57815f6 --- /dev/null +++ b/yohobuypc_node.conf @@ -0,0 +1,9 @@ + +location ~ / { + proxy_redirect off; + proxy_pass http://yohobuy-node; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Accept-Encoding "gzip"; + }