...
|
...
|
@@ -4,18 +4,17 @@ var fs = require('fs'); |
|
|
var searchDomain = require('../../config/common.js').yohoSearch;
|
|
|
|
|
|
exports.brandlist = function (req, res) {
|
|
|
request.get(searchDomain+"/brand/list.json").pipe(res);
|
|
|
request.get(searchDomain + "/brand/list.json").pipe(res);
|
|
|
};
|
|
|
|
|
|
exports.search = function (req, res) {
|
|
|
var size = 10;//每页数据量
|
|
|
var params = [];
|
|
|
for (var key in req.body) {
|
|
|
params.push(key + "=" + req.body[key]);
|
|
|
params.push(key + "=" + encodeURI(req.body[key]));
|
|
|
}
|
|
|
console.log("params",params);
|
|
|
var url = searchDomain+"/search.json?viewNum=" + size + "&"+params.join('&');
|
|
|
console.log("请求url",url);
|
|
|
var url = searchDomain + "/search.json?viewNum=" + size + "&" + params.join('&');
|
|
|
//console.log("请求url",url);
|
|
|
request({url: url}, function (error, response, body) {
|
|
|
var data = {};
|
|
|
data.list = [];
|
...
|
...
|
@@ -31,13 +30,12 @@ exports.search = function (req, res) { |
|
|
for (var i = 0; i < goodslist.length; i++) {
|
|
|
goodslist1[i] = _.assign({}, goodslist[i].a, goodslist[i].b);
|
|
|
}
|
|
|
//data.list=body.data.product_list;
|
|
|
data.list = goodslist1.concat();//显示数据
|
|
|
data.page = body.data.page;//页码
|
|
|
data.totalPage = body.data.page_total;
|
|
|
data.nums = data.list.length;//记录每一页数据量
|
|
|
//console.log("最终data", data);
|
|
|
res.json({data: {data: data,code:200}});
|
|
|
res.json({data: {data: data, code: 200}});
|
|
|
});
|
|
|
};
|
|
|
|
...
|
...
|
|