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
周少峰
8 years ago
Commit
66c2f0cab90fe96d8fd0c83d00674b540586f93a
1 parent
26cd7dd0
keyword page
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
70 deletions
apps/3party/controllers/sitemap.js
apps/channel/router.js
apps/product/models/search-handler.js
apps/product/models/search.js
doraemon/middleware/mobile-refer.js
apps/3party/controllers/sitemap.js
View file @
66c2f0c
...
...
@@ -37,19 +37,19 @@ const getStaticUrls = (currentStatics) => {
};
// 关键词页面
const
keywordsPage
=
()
=>
{
return
redis
.
getAsync
(
'golobal:yoho:seo:keywords:allIds'
).
then
(
function
(
res
)
{
let
page
=
[];
const
keywordsPage
=
(
page
)
=>
{
return
redis
.
getAsync
(
`
global
:
yoho
:
seo
:
keywords
:
allIds
:
page
:
$
{
page
}
`
).
then
(
function
(
res
)
{
let
pages
=
[];
_
.
forEach
(
JSON
.
parse
(
res
),
val
=>
{
page
.
push
({
page
s
.
push
({
url
:
`
https
:
//www.yohobuy.com/chanpin/${val}.html`,
changefreq
:
'daily'
,
priority
:
0.5
});
});
return
page
;
return
page
s
;
}).
catch
(()
=>
{
return
{};
});
...
...
@@ -74,8 +74,8 @@ const getArticleUrls = () => {
};
// www 地图数据
const
wwwXmlData
=
()
=>
{
// eslint-disable-line
return
Promise
.
all
([
keywordsPage
(),
getStaticUrls
(
_
.
get
(
staticUrls
,
'www'
)),
getArticleUrls
()]).
then
(
result
=>
{
const
wwwXmlData
=
(
page
)
=>
{
// eslint-disable-line
return
Promise
.
all
([
keywordsPage
(
page
),
getStaticUrls
(
_
.
get
(
staticUrls
,
'www'
)),
getArticleUrls
()]).
then
(
result
=>
{
return
_
.
concat
(
result
[
1
],
result
[
0
],
result
[
2
]);
});
};
...
...
@@ -125,6 +125,7 @@ const itemXmlData = () => {// eslint-disable-line
// 站点地图
const
siteMap
=
(
req
,
res
,
next
)
=>
{
let
page
=
_
.
get
(
req
,
'params[0]'
,
1
);
let
siteList
=
[
'www'
,
'list'
,
'item'
],
subdomain
=
req
.
subdomains
[
0
]
||
'www'
;
...
...
@@ -133,7 +134,7 @@ const siteMap = (req, res, next) => {
return
;
}
eval
(
subdomain
+
'XmlData'
)().
then
(
urls
=>
{
// eslint-disable-line
eval
(
subdomain
+
'XmlData'
)(
page
).
then
(
urls
=>
{
// eslint-disable-line
sm
.
createSitemap
({
hostname
:
`
https
:
//${subdomain}.yohobuy.com`,
xmlNs
:
' '
,
...
...
apps/channel/router.js
View file @
66c2f0c
...
...
@@ -30,6 +30,6 @@ router.post('/common/getNewArrival', channelController.getNewArrival);
router
.
get
(
'/guide'
,
channelController
.
getIndexGuide
);
// www站点地图
router
.
get
(
'/sitemap.xml'
,
sitemap
.
siteMap
);
router
.
get
(
/
\/
sitemap
(\d
*
)\.
xml/
,
sitemap
.
siteMap
);
module
.
exports
=
router
;
...
...
apps/product/models/search-handler.js
View file @
66c2f0c
...
...
@@ -17,8 +17,6 @@ const indexUrl = {
kids
:
helpers
.
urlFormat
(
'/kids'
),
lifestyle
:
helpers
.
urlFormat
(
'/lifestyle'
)
};
const
utils
=
'../../../utils'
;
const
stringCode
=
require
(
`
$
{
utils
}
/string-code`
)
;
// 打折、新品、限量
const
checksName
=
{
...
...
@@ -1759,44 +1757,3 @@ exports.handleBrandShopCoupons = (data, params) => {
return
false
;
};
/**
* 处理页面左侧分类筛选数据
* @param origin 分类原始数据,一般是接口返回数据中的 group_sort 字段
* @param params 当前 URL 中已有的参数
* @param extra 可以任意传值用来处理特殊情况
* @param {string} [baseUrl] 需要跳转非当前页面传的相对路径(可不传,默认为空字符串)
* @returns {{}}
*/
exports
.
handleSuggestData
=
(
origin
,
query
)
=>
{
let
leftContent
=
{};
let
list
=
[];
let
all
=
[{
name
:
'全部推荐'
}];
_
.
forEach
(
origin
,
value
=>
{
if
(
query
===
value
.
keyword
||
value
.
keyword
.
length
<=
2
)
{
return
;
}
list
.
push
({
name
:
`
$
{
value
.
keyword
}
`
,
href
:
helpers
.
urlFormat
(
`
/
so
/
$
{
stringCode
.
utf8ToHex
(
value
.
keyword
)}.
html
`
,
null
,
'www'
)
});
});
leftContent
.
allSuggest
=
{
all
:
all
,
title
:
'相关推荐'
,
list
:
list
};
return
leftContent
;
};
...
...
apps/product/models/search.js
View file @
66c2f0c
...
...
@@ -334,27 +334,18 @@ const setSearchKeywordData = (result, params, channel) => {
_
.
unset
(
changeQuery
,
'query'
);
// 获取左侧类目数据
if
(
result
[
1
].
code
===
200
)
{
finalResult
.
search
=
{
leftContent
:
searchHandler
.
handleSuggestData
(
_
.
get
(
result
,
'[1].data'
,
[]),
params
.
query
),
isSearch
:
true
};
}
// 获取商品数据和顶部筛选条件
if
(
result
[
2
].
code
===
200
)
{
if
(
result
[
1
].
code
===
200
)
{
Object
.
assign
(
finalResult
.
search
,
searchHandler
.
handlePathNavData
({
total
:
result
[
2
].
data
.
total
},
params
,
'search'
,
channel
),
searchHandler
.
handlePathNavData
({
total
:
result
[
1
].
data
.
total
},
params
,
'search'
,
channel
),
{
opts
:
searchHandler
.
handleOptsData
(
changeQuery
,
result
[
2
].
data
.
total
),
totalCount
:
result
[
2
].
data
.
total
,
footPager
:
searchHandler
.
handlePagerData
(
result
[
2
].
data
.
total
,
changeQuery
),
goods
:
productProcess
.
processProductList
(
result
[
2
].
data
.
product_list
,
opts
:
searchHandler
.
handleOptsData
(
changeQuery
,
result
[
1
].
data
.
total
),
totalCount
:
result
[
1
].
data
.
total
,
footPager
:
searchHandler
.
handlePagerData
(
result
[
1
].
data
.
total
,
changeQuery
),
goods
:
productProcess
.
processProductList
(
result
[
1
].
data
.
product_list
,
Object
.
assign
({
showDiscount
:
false
,
from
:
{
type
:
'search'
,
params
:
params
}},
params
)),
latestWalk
:
6
,
hasNextPage
:
searchHandler
.
handleNextPage
(
changeQuery
,
result
[
2
].
data
.
total
),
hasNextPage
:
searchHandler
.
handleNextPage
(
changeQuery
,
result
[
1
].
data
.
total
),
name
:
params
.
query
});
...
...
@@ -393,7 +384,6 @@ exports.getSearchKeywordData = (params, channel) => {
// 调用接口
let
apiMethod
=
[
headerModel
.
requestHeaderData
(
channel
),
searchApi
.
getSuggest
({
keyword
:
searchParams
.
query
.
substring
(
0
,
2
)}),
searchApi
.
getSeoProductList
(
searchParams
,
'fuzzySearch'
)
];
...
...
@@ -442,7 +432,7 @@ exports.getSearchKeywordDataById = (id, params, channel) => {
});
});
_
.
set
(
resData
,
'search.leftContent.allSuggest
.list'
,
redisData
.
data
);
_
.
set
(
resData
,
'search.leftContent.allSuggest
'
,
{
title
:
'相关推荐'
,
list
:
redisData
.
data
}
);
}
return
resData
;
...
...
doraemon/middleware/mobile-refer.js
View file @
66c2f0c
...
...
@@ -59,6 +59,8 @@ module.exports = () => {
}
}
else
if
(
proRegNew
.
test
(
url
))
{
data
.
mobileRefer
=
url
.
replace
(
proRegNew
,
`
//${domain}/product/pro_$1_1/1.html$2`);
}
else
{
data
.
mobileRefer
=
`
//${domain}${req.originalUrl}`;
}
if
(
!
_
.
isEmpty
(
req
.
query
)
&&
!
qsReg
.
test
(
data
.
mobileRefer
))
{
...
...
Please
register
or
login
to post a comment