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
htoooth
8 years ago
Commit
23bd26ba3d2d040bfa2c004781cbee23871c8cf8
1 parent
5d093df7
add consult like userful
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
16 deletions
apps/product/controllers/detail.js
apps/product/models/detail-consult-api.js
apps/product/models/detail-consult-service.js
apps/product/models/detail-service.js
apps/product/router.js
apps/product/controllers/detail.js
View file @
23bd26b
...
...
@@ -233,6 +233,38 @@ const createConsult = (req, res, next) => {
}
};
const
likeConsult
=
(
req
,
res
,
next
)
=>
{
let
uid
=
req
.
user
.
uid
;
let
id
=
req
.
params
.
id
||
0
;
if
(
!
id
)
{
return
res
.
json
({
code
:
401
,
message
:
'咨询无效'
});
}
service
.
likeAsync
(
uid
,
id
).
then
((
result
)
=>
{
return
res
.
json
(
result
);
}).
catch
(
next
);
};
const
usefulConsult
=
(
req
,
res
,
next
)
=>
{
let
uid
=
req
.
user
.
uid
;
let
id
=
req
.
params
.
id
||
0
;
if
(
!
id
)
{
return
res
.
json
({
code
:
401
,
message
:
'咨询无效'
});
}
service
.
usefulAsync
(
uid
,
id
).
then
((
result
)
=>
{
return
res
.
json
(
result
);
}).
catch
(
next
);
};
const
recommend
=
(
req
,
res
,
next
)
=>
{
let
skn
=
req
.
query
.
skn
||
''
;
let
pageSize
=
req
.
query
.
size
||
5
;
...
...
@@ -276,7 +308,9 @@ module.exports = {
productHeader
:
detailHeader
,
detailReturn
,
recommend
,
getPackage
getPackage
,
likeConsult
,
usefulConsult
};
...
...
apps/product/models/detail-consult-api.js
View file @
23bd26b
...
...
@@ -37,7 +37,25 @@ const createAsync = function(uid, pid, content) {
});
};
const
likeAsync
=
(
uid
,
id
)
=>
{
return
api
.
get
(
''
,
{
method
:
'app.consult.like'
,
uid
:
uid
,
id
:
id
});
};
const
usefulAsync
=
(
uid
,
id
)
=>
{
return
api
.
get
(
''
,
{
method
:
'app.consult.useful'
,
uid
:
uid
,
id
:
id
});
};
module
.
exports
=
{
indexAsync
,
createAsync
createAsync
,
likeAsync
,
usefulAsync
};
...
...
apps/product/models/detail-consult-service.js
View file @
23bd26b
...
...
@@ -38,5 +38,7 @@ const indexAsync = (uid, pid, page, size) => {
module
.
exports
=
{
indexAsync
,
createAsync
:
api
.
createAsync
createAsync
:
api
.
createAsync
,
likeAsync
:
api
.
likeAsync
,
usefulAsync
:
api
.
usefulAsync
};
...
...
apps/product/models/detail-service.js
View file @
23bd26b
...
...
@@ -1589,6 +1589,8 @@ module.exports = {
getShareOrderListAsync
:
commentService
.
getShareOrderListAsync
,
// 获取评论列表
indexConsultAsync
:
consultService
.
indexAsync
,
// 获取咨询列表
createConsultAsync
:
consultService
.
createAsync
,
// 添加咨询
likeAsync
:
consultService
.
likeAsync
,
// 咨询喜欢
usefulAsync
:
consultService
.
usefulAsync
,
// 咨询有用
showMainAsync
:
showMainAsync
,
// 获取某一个商品详情主页面
indexHotAreaAsync
:
hotAreaService
.
indexAsync
,
// 获取某一个商品的热区数据
saveRecentGoodInCookies
,
// 保存最近的商品
...
...
apps/product/router.js
View file @
23bd26b
...
...
@@ -55,19 +55,21 @@ router.get('/outlets/:channel', outlets.channel); // 奥莱频道页
// 商品分类列表页
router
.
get
(
'/list'
,
outletsList
.
index
);
router
.
get
(
/
\/
pro_
([\d]
+
)
_
([\d]
+
)\/(
.*
)
/
,
detail
.
showMain
);
// 商品详情routers
router
.
get
(
'/detail/comment'
,
detail
.
indexComment
);
// 商品评论
router
.
get
(
'/detail/consult'
,
detail
.
indexConsult
);
// 商品咨询
router
.
post
(
'/detail/consult'
,
auth
,
detail
.
createConsult
);
// 创建咨询
router
.
get
(
'/detail/hotarea'
,
detail
.
indexHotArea
);
// 商品热区
router
.
post
(
'/index/favoriteBrand'
,
favorite
.
changeFavoriteBrand
);
// 收藏品牌
router
.
post
(
'/item/togglecollect'
,
favorite
.
collectProduct
);
// 收藏商品
router
.
get
(
'/detail/header'
,
detail
.
productHeader
);
// 价格数据重新获取接口
router
.
get
(
'/detail/return'
,
detail
.
detailReturn
);
// 特殊商品退换货
router
.
get
(
'/detail/recommend'
,
detail
.
recommend
);
// 推荐商品
router
.
get
(
'/index/isfav'
,
favorite
.
isFavoriteBrand
);
// 品牌收藏状态
router
.
get
(
'/detail/coupon'
,
auth
,
coupon
.
acquire
);
// 获得优惠券
router
.
get
(
'/detail/getPacakge'
,
detail
.
getPackage
);
// 获取套餐
router
.
get
(
/
\/
pro_
([\d]
+
)
_
([\d]
+
)\/(
.*
)
/
,
detail
.
showMain
);
// 商品详情routers
router
.
get
(
'/detail/comment'
,
detail
.
indexComment
);
// 商品评论
router
.
get
(
'/detail/consult'
,
detail
.
indexConsult
);
// 商品咨询
router
.
post
(
'/detail/consult'
,
auth
,
detail
.
createConsult
);
// 创建咨询
router
.
get
(
'/detail/consult/like/:id'
,
auth
,
detail
.
likeConsult
);
// 咨询喜欢
router
.
get
(
'/detail/consult/useful/:id'
,
auth
,
detail
.
usefulConsult
);
// 咨询有用
router
.
get
(
'/detail/hotarea'
,
detail
.
indexHotArea
);
// 商品热区
router
.
post
(
'/index/favoriteBrand'
,
favorite
.
changeFavoriteBrand
);
// 收藏品牌
router
.
post
(
'/item/togglecollect'
,
favorite
.
collectProduct
);
// 收藏商品
router
.
get
(
'/detail/header'
,
detail
.
productHeader
);
// 价格数据重新获取接口
router
.
get
(
'/detail/return'
,
detail
.
detailReturn
);
// 特殊商品退换货
router
.
get
(
'/detail/recommend'
,
detail
.
recommend
);
// 推荐商品
router
.
get
(
'/index/isfav'
,
favorite
.
isFavoriteBrand
);
// 品牌收藏状态
router
.
get
(
'/detail/coupon'
,
auth
,
coupon
.
acquire
);
// 获得优惠券
router
.
get
(
'/detail/getPacakge'
,
detail
.
getPackage
);
// 获取套餐
// 搜索
router
.
get
(
'/search/index'
,
search
.
index
);
...
...
Please
register
or
login
to post a comment