Authored by 姜敏

yohosearch搜索

... ... @@ -319,18 +319,22 @@ var goodsgird = new common.grid({
el: '#goodsgird',
parms: function() {
return {
xxx: "",
xxx1: "",
query:common.util.__input('skns')
};
},
columns: [{
display: "选择",
type: "checkbox"
}, {
},{
display: "产品图片",
render: function(item) {
item.default_images = common.util.__joinImg("goodsimg", item.default_images)
return "<img width=120 height=60 src='" + item.default_images + "'/>";
if(item.default_images){
item.default_images=common.util.__joinImg("goodsimg",item.default_images);
}
else{
item.default_images="";
}
return "<img width=120 height=60 src='"+item.default_images+"'/>";
}
}, {
display: "产品名称",
... ...
... ... @@ -3,37 +3,40 @@ var _ = require('lodash');
var fs = require('fs');
var searchDomain = require('../../config/common.js').yohoSearch;
exports.getJSONFile=function(req,res){
exports.getJSONFile = function (req, res) {
request.get("http://192.168.102.208:8087/yohosearch/brand/list.json").pipe(res);
}
exports.search=function(req,res){
//req.body
var url="http://192.168.102.208:8087/yohosearch/search.json";//?viewNum=15&query=51022754,51178582
request({url: url}, function (error, response, body) {
var data={};
data.list=[];
body=JSON.parse(body);
var dataList=body.data.product_list;
var goodslist=[];
var goodslist1=[];
for(var m=0;m<dataList.length;m++){
for(var n=0;n<dataList[m].goods_list.length;n++){
goodslist.push({a:dataList[m],b:dataList[m].goods_list[n]})
}
}
for(var i=0;i<goodslist.length;i++){
goodslist1[i]= _.assign({},goodslist[i].a,goodslist[i].b);
}
data.list=goodslist1.concat();
//data.list=body.data.product_list;
data.total=data.list.length;
data.page=body.data.page;
data.size=5;
var a = (/^[1-9]\d*$/).test(data.total/data.size);
data.totalPage=a?parseInt(data.total/data.size):parseInt(data.total/data.size)+1;
res.json({data:{data:data}});
});
exports.search = function (req, res) {
var size = 10;//每页数据量
var page = 1;
if (req.body.page) {
page = req.body.page;
}
var url = "http://x.yohobuy.com//yohosearch/search.json?viewNum=" + size + "&query=" + req.body.query + "&page=" + page;
request({url: url}, function (error, response, body) {
var data = {};
data.list = [];
body = JSON.parse(body);
var dataList = body.data.product_list;
var goodslist = [];
var goodslist1 = [];
for (var m = 0; m < dataList.length; m++) {
for (var n = 0; n < dataList[m].goods_list.length; n++) {
goodslist.push({a: dataList[m], b: dataList[m].goods_list[n]})
}
}
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}});
});
};
... ...
... ... @@ -400,12 +400,12 @@
<script type="text/template" id="template_dialog_goodsgird">
<div class="rows">
<div class="form-group">
<div class="col-sm-4">
<input class="form-control" placeholder="输入SKN" />
</div>
<div class="col-sm-4">
<input class="form-control" placeholder="输入标签" />
<div class="col-sm-6">
<input class="form-control" id="skns" placeholder="输入SKN(多个skn以逗号分隔)" />
</div>
<!--<div class="col-sm-4">-->
<!--<input class="form-control" placeholder="输入标签" />-->
<!--</div>-->
<div class="col-sm-1">
<input type="button" id="search" class="btn btn-primary mr5" value="搜索" />
</div>
... ...