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
Plain Diff
Browse Files
Authored by
yyq
7 years ago
Commit
f554b58260966536d10207445e465f7242085c6d
2 parents
9dbcb256
0a935348
Merge branch 'feature/qps' of git.yoho.cn:fe/yohobuy-node into feature/qps
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
22 deletions
doraemon/models/header.js
doraemon/models/header.js
View file @
f554b58
...
...
@@ -11,7 +11,8 @@ const _ = require('lodash');
const
api
=
global
.
yoho
.
API
;
const
serviceApi
=
global
.
yoho
.
ServiceAPI
;
const
helpers
=
global
.
yoho
.
helpers
;
const
keyPrefix
=
'COMMON_HEADER_'
;
const
cache
=
global
.
yoho
.
cache
;
/**
* 获取菜单
* @param undefined
...
...
@@ -214,31 +215,36 @@ const getHeaderNavAsync = () => {
* @param {String} 频道类型
* @return {promise}
*/
exports
.
requestHeaderData
=
(
type
)
=>
{
async
function
requestHeaderData
(
type
)
{
let
resData
=
{};
type
=
type
||
'boys'
;
let
headerKey
=
`
$
{
keyPrefix
}
$
{
type
}
`
;
let
header
=
await
cache
.
get
(
headerKey
);
if
(
!
header
)
{
let
channelNum
=
(
function
()
{
switch
(
type
)
{
case
'boys'
:
return
1
;
case
'girls'
:
return
2
;
case
'kids'
:
return
3
;
case
'lifestyle'
:
return
4
;
default
:
return
1
;
}
}());
let
channelNum
=
(
function
()
{
switch
(
type
)
{
case
'boys'
:
return
1
;
case
'girls'
:
return
2
;
case
'kids'
:
return
3
;
case
'lifestyle'
:
return
4
;
default
:
return
1
;
}
}());
let
res
=
await
Promise
.
all
([
getHeaderNavAsync
(),
getHotSearchAsync
(
channelNum
)
return
Promise
.
all
([
getHeaderNavAsync
(),
getHotSearchAsync
(
channelNum
)
]);
]).
then
(
res
=>
{
resData
.
headerData
=
{};
if
(
res
[
0
]
&&
res
[
0
].
data
)
{
...
...
@@ -258,6 +264,16 @@ exports.requestHeaderData = (type) => {
});
}
return
resData
;
});
if
(
res
[
0
]
&&
res
[
0
].
data
&&
res
[
1
]
&&
res
[
1
].
data
)
{
cache
.
set
(
headerKey
,
resData
,
300
);
}
}
else
{
resData
=
JSON
.
parse
(
header
);
}
return
resData
;
};
module
.
exports
=
{
requestHeaderData
}
...
...
Please
register
or
login
to post a comment