Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
周少峰
9 years ago
Commit
fbf9514a647618403aff2a87fafb14a10b5a403e
1 parent
c635794a
add search
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
140 additions
and
1 deletions
apps/product/controllers/search.js
apps/product/models/search-api.js
apps/product/models/search.js
apps/product/router.js
apps/product/controllers/search.js
0 → 100644
View file @
fbf9514
/**
* 商品搜索controller
* @author: sefon
* @date: 2016-7-12 10:09:25
*/
'use strict'
;
const
mRoot
=
'../models'
;
const
search
=
require
(
`
$
{
mRoot
}
/search`
)
;
/**
* search 首页
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports
.
index
=
(
req
,
res
,
next
)
=>
{
let
resData
=
{};
search
.
getSearchData
(
req
.
query
).
then
(
result
=>
{
Object
.
assign
(
resData
,
result
);
res
.
render
(
'search/index'
,
resData
);
}).
catch
(
next
);
};
...
...
apps/product/models/search-api.js
View file @
fbf9514
...
...
@@ -7,10 +7,79 @@
const
api
=
global
.
yoho
.
SearchAPI
;
const
yohoApi
=
global
.
yoho
.
API
;
const
getSortByConditionAsync
=
(
condition
)
=>
{
return
api
.
get
(
'sortgroup.json'
,
condition
);
};
/**
* 获取商品列表
* @return
*/
const
getProductList
=
(
params
)
=>
{
let
finalParams
=
{
limit
:
60
,
method
:
'app.search.li'
};
Object
.
assign
(
finalParams
,
params
);
return
yohoApi
.
get
(
''
,
finalParams
);
};
/**
* 获取分类列表
* @return
*/
const
getSortList
=
(
params
)
=>
{
let
finalParams
=
{
method
:
'app.sort.get'
};
Object
.
assign
(
finalParams
,
params
);
return
yohoApi
.
get
(
''
,
finalParams
);
};
/**
* 获取分类图文介绍
* @return
*/
const
getSortIntroList
=
(
params
)
=>
{
return
yohoApi
.
get
(
''
,
params
);
};
/**
* 获取分类左侧广告
* @return
*/
const
getSortads
=
(
params
)
=>
{
return
yohoApi
.
get
(
''
,
params
);
};
/**
* 获取品牌folder
* @return
*/
const
getBrandFolder
=
(
params
)
=>
{
return
yohoApi
.
get
(
''
,
params
);
};
/**
* 一周新品上架
* @return
*/
const
getWeekNew
=
(
params
)
=>
{
return
yohoApi
.
get
(
''
,
params
);
};
module
.
exports
=
{
getSortByConditionAsync
getSortByConditionAsync
,
getProductList
,
getSortList
,
getSortIntroList
,
getSortads
,
getBrandFolder
,
getWeekNew
};
...
...
apps/product/models/search.js
0 → 100644
View file @
fbf9514
/*
* @Author: Targaryen
* @Date: 2016-05-30 16:20:03
* @Last Modified by: Targaryen
* @Last Modified time: 2016-06-08 19:56:39
*/
'use strict'
;
// const utils = '../../../utils';
const
api
=
global
.
yoho
.
API
;
const
searchApi
=
require
(
'./search-api'
);
const
headerModel
=
require
(
'../../../doraemon/models/header'
);
// const _ = require('lodash');
//
// const log = global.yoho.logger;
/**
* 获取奥莱首页数据
* @param {[type]} origin [description]
* @return {[type]} [description]
*/
exports
.
getSearchData
=
(
params
)
=>
{
return
api
.
all
([
headerModel
.
requestHeaderData
(),
searchApi
.
getSortList
(),
searchApi
.
getProductList
(
params
)
]).
then
(
result
=>
{
let
finalResult
=
{
headerData
:
Object
.
assign
(
result
[
0
].
headerData
,
{
header
:
true
})
};
// 处理搜索结果数据
return
finalResult
;
});
};
...
...
apps/product/router.js
View file @
fbf9514
...
...
@@ -24,6 +24,9 @@ const outlets = require(`${cRoot}/outlets`);
// 商品促销controller
const
list
=
require
(
`
$
{
cRoot
}
/list`
)
;
// 搜索页
const
search
=
require
(
`
$
{
cRoot
}
/search`
)
;
// 商品促销routers
router
.
get
(
'/sale'
,
sale
.
index
);
// sale 首页
router
.
get
(
'/sale/discount/detail'
,
sale
.
discount
);
// 折扣专场详情页
...
...
@@ -50,4 +53,7 @@ router.get('/detail/hotarea', detail.indexHotArea);// 商品热区
router
.
post
(
'/index/favoriteBrand'
,
favorite
.
changeFavoriteBrand
);
// 收藏品牌
router
.
post
(
'/item/togglecollect'
,
favorite
.
collectProduct
);
//收藏商品
// 搜索
router
.
get
(
'/search/index'
,
search
.
index
);
module
.
exports
=
router
;
...
...
Please
register
or
login
to post a comment