Authored by 刘传洋

search old router

@@ -44,3 +44,31 @@ exports.suggest = (req, res, next) => { @@ -44,3 +44,31 @@ exports.suggest = (req, res, next) => {
44 }).catch(next); 44 }).catch(next);
45 }; 45 };
46 46
  47 +exports.suggest4Old = (req, res, next) => {
  48 + search.getSuggest(Object.assign({}, req.query, { keyword: req.query.query })).then(result => {
  49 + let dest = {
  50 + code: 200,
  51 + message: 'suggest'
  52 + };
  53 +
  54 + let data= [];
  55 +
  56 + if(result) {
  57 + for(let it of result) {
  58 +
  59 + let item = `<li>`+
  60 + `<a style="display: block;" href="${it.href}" class="clearfix clear search-item" title="${it.keyword}" act="${it.href}">`+
  61 + `<span class="searchvalue" >${it.keyword}</span><span class="valuenum">约${it.count}个商品</span>`+
  62 + `</a>`+
  63 + `</li>`;
  64 +
  65 + data.push(item);
  66 + }
  67 + }
  68 +
  69 + dest.data = data;
  70 + res.send(req.query.callback + '(' + JSON.stringify(dest) + ')');
  71 +
  72 + }).catch(next);
  73 +}
  74 +
@@ -65,6 +65,8 @@ router.get('/search/index', search.index); @@ -65,6 +65,8 @@ router.get('/search/index', search.index);
65 // 搜索提示 65 // 搜索提示
66 router.get('/search/suggest', search.suggest); 66 router.get('/search/suggest', search.suggest);
67 67
  68 +router.get('/api/suggest', search.suggest4Old);
  69 +
68 70
69 // 商品分类列表页 71 // 商品分类列表页
70 router.get('/list/index', list.index); 72 router.get('/list/index', list.index);