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
9 years ago
Commit
d9acc6a2deeeff5aa17924784b962ec0091a8aa4
1 parent
4829d8f7
最近浏览功能。
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
19 deletions
apps/product/controllers/detail.js
apps/product/models/detail-service.js
apps/product/controllers/detail.js
View file @
d9acc6a
...
...
@@ -29,6 +29,11 @@ class DetailAction extends YohoAction {
let
gid
=
req
.
params
[
1
];
let
uid
=
req
.
user
.
uid
||
''
;
let
vipLevel
=
detailHelper
.
vipLevel
(
req
.
user
.
vip
);
let
saveCurrentGoodsInCookies
=
_
.
partial
(
service
.
saveRecentGoodInCookies
,
req
.
cookies
.
_browse
,
req
.
cookies
.
_browseskn
,
this
.
response
);
return
service
.
showMainAsync
({
pid
:
pid
,
...
...
@@ -36,7 +41,8 @@ class DetailAction extends YohoAction {
channel
:
this
.
getSessionChannel
(),
gender
:
this
.
guessUserGender
(),
uid
:
uid
,
vipLevel
:
vipLevel
vipLevel
:
vipLevel
,
saveInCookies
:
saveCurrentGoodsInCookies
}).
then
(
result
=>
{
const
seo
=
result
.
seo
;
...
...
apps/product/models/detail-service.js
View file @
d9acc6a
...
...
@@ -529,6 +529,29 @@ function _getSortNavAsync(smallSortId, gender) {
})();
}
// 保存在 gids 和 skns ,最近流览功能
const
saveRecentGoodInCookies
=
(
oldGids
,
oldSkns
,
res
,
addGids
,
addSkns
)
=>
{
oldGids
=
(
oldGids
||
''
).
split
(
','
);
oldSkns
=
(
oldSkns
||
''
).
split
(
','
);
addSkns
=
`
$
{
addSkns
}
-
$
{
addGids
}
`
;
_
.
remove
(
oldGids
,
addGids
);
_
.
remove
(
oldSkns
,
addSkns
);
oldGids
.
unshift
(
addGids
);
oldSkns
.
unshift
(
addSkns
);
res
.
cookie
(
'_browse'
,
oldGids
.
splice
(
0
,
30
).
join
(
','
),
{
maxAge
:
2000000000
,
domain
:
'yohobuy.com'
});
res
.
cookie
(
'_browseskn'
,
oldSkns
.
splice
(
0
,
30
).
join
(
','
),
{
maxAge
:
2000000000
,
domain
:
'yohobuy.com'
});
};
/**
* 详情页数据格式化
* @param origin Object 原始数据
...
...
@@ -736,24 +759,21 @@ const _detailDataPkg = (origin, uid, vipLevel) => {
if
(
domainBrand
.
type
&&
domainBrand
.
shopId
)
{
switch
(
parseInt
(
domainBrand
.
type
,
10
))
{
case
1
:
{
case
1
:
{
// 多品店不显示
banner
=
[];
break
;
}
case
2
:
{
banner
=
[];
break
;
}
case
2
:
{
// 单品店显示新版的店铺banner
let
basisData
=
yield
shopService
.
basisTemplateAsync
(
domainBrand
.
shopId
);
banner
.
bgImg
=
basisData
.
shopTopBanner
.
banner
||
banner
.
bgImg
;
break
;
}
default
:
{
break
;
}
let
basisData
=
yield
shopService
.
basisTemplateAsync
(
domainBrand
.
shopId
);
banner
.
bgImg
=
basisData
.
shopTopBanner
.
banner
||
banner
.
bgImg
;
break
;
}
default
:
{
break
;
}
}
}
}
...
...
@@ -1372,12 +1392,17 @@ const showMainAsync = (data) => {
HeaderModel
.
requestHeaderData
(
data
.
channel
)
]);
// 分类导航
// 分类导航
,seo
let
navs
=
requestData
[
0
];
const
seo
=
_getSeoByGoodsInfo
(
productInfo
.
goodsInfo
,
navs
);
result
.
seo
=
seo
;
// 最近浏览功能 ,限量商品不能使用这个功能
if
(
!
_
.
has
(
productInfo
,
'goodsInfo.fashionTopGoods'
))
{
data
.
saveInCookies
(
data
.
gid
,
_
.
get
(
productInfo
,
'goodsInfo.skn'
,
''
));
}
// 获取商品尺寸相关
let
sizeInfo
=
_getSizeInfo
(
productInfo
.
goodsInfo
,
productInfo
.
goodsInfo
.
maxSortId
);
...
...
@@ -1407,5 +1432,6 @@ module.exports = {
indexConsultAsync
:
consultService
.
indexAsync
,
// 获取咨询列表
createConsultAsync
:
consultService
.
createAsync
,
// 添加咨询
showMainAsync
:
showMainAsync
,
// 获取某一个商品详情主页面
indexHotAreaAsync
:
hotAreaService
.
indexAsync
// 获取某一个商品的热区数据
indexHotAreaAsync
:
hotAreaService
.
indexAsync
,
// 获取某一个商品的热区数据
saveRecentGoodInCookies
// 保存最近的商品
};
...
...
Please
register
or
login
to post a comment