Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuywap-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
毕凯
7 years ago
Commit
f31b5f12389cc03c39ff665b2e0e175628c6ccae
2 parents
5507f56c
28de0c3d
Merge branch 'feature/listseo' into 'gray'
Feature/listseo See merge request
!1056
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
71 additions
and
15 deletions
apps/channel/models/brand.js
apps/product/controllers/new-detail.js
apps/product/controllers/new-shop.js
apps/product/models/detail.js
apps/product/router.js
doraemon/middleware/url-rewrite.js
doraemon/views/partial/product/recommend-goods.hbs
utils/detail-process.js
utils/product-process.js
apps/channel/models/brand.js
View file @
f31b5f1
...
...
@@ -156,7 +156,7 @@ module.exports = class extends global.yoho.BaseModel {
return
{
1
:
helpers
.
urlFormat
(
''
,
{
from
:
'search'
,
query
:
row
.
brand_name
},
'search'
),
2
:
helpers
.
urlFormat
(
'/product/shop'
,
{
domain
:
row
.
brand_domain
})
,
2
:
`
/
shop
/
$
{
row
.
brand_domain
}
-
$
{
row
.
shop_id
}.
html
`
,
3
:
helpers
.
urlFormat
(
'/product/global/list/'
,
{
brand
:
row
.
global_brand_id
})
}[
key
];
}
...
...
apps/product/controllers/new-detail.js
View file @
f31b5f1
...
...
@@ -62,7 +62,7 @@ const newDetail = {
pageHeader
:
headerData
,
result
:
result
,
page
:
'new-detail'
,
title
:
result
.
goodsName
+
result
.
sortName
+
'正品 | YOHO!BUY 有货'
,
title
:
`
$
{
result
.
brandName
}
$
{
result
.
sortName
}
$
{
result
.
goodsName
}
|
YOHO
!
BUY
有货`
,
keywords
:
result
.
brandName
+
result
.
sortName
+
','
+
result
.
brandName
+
'官网专卖店,'
+
result
.
brandName
+
'官方授权店,'
+
result
.
brandName
+
'正品,'
+
result
.
brandName
+
'打折,'
+
result
.
brandName
+
'折扣店,'
+
...
...
apps/product/controllers/new-shop.js
View file @
f31b5f1
...
...
@@ -20,15 +20,61 @@ const co = require('bluebird').coroutine;
const
shop
=
{
/**
* 老路由处理,查数据,拼链接
*/
redirect
(
req
,
res
,
next
)
{
let
shopId
=
_
.
parseInt
(
stringProcess
.
paramsFilter
(
req
.
query
.
shop_id
));
let
domain
=
stringProcess
.
paramsFilter
(
req
.
query
.
domain
);
let
brandId
=
_
.
parseInt
(
stringProcess
.
paramsFilter
(
req
.
query
.
brand_id
));
co
(
function
*
()
{
if
(
shopId
&&
domain
)
{
return
res
.
redirect
(
301
,
`
//m.yohobuy.com/shop/${domain}-${shopId}.html`);
}
if
(
shopId
)
{
let
shopInfoApi
=
(
yield
req
.
ctx
(
shopModel
).
getShopInfo
(
shopId
))
||
{};
return
res
.
redirect
(
301
,
`
//m.yohobuy.com/shop/${_.get(shopInfoApi, 'data.shop_domain')}-${shopId}.html`); // eslint-disable-line
}
if
(
domain
)
{
let
domainInfo
=
(
yield
req
.
ctx
(
shopModel
).
getBrandLogoByDomain
(
domain
))
||
{};
// 通过域名查询店铺类型,或者品牌信息
if
(
domainInfo
.
shopId
&&
domainInfo
.
type
===
'2'
)
{
return
res
.
redirect
(
301
,
`
//m.yohobuy.com/shop/${domain}-${_.get(domainInfo, 'shopId')}.html`);
}
else
{
return
res
.
redirect
(
301
,
helpers
.
urlFormat
(
'/index/brand'
,
{
brand_id
:
_
.
get
(
domainInfo
,
'id'
)
}));
}
}
if
(
brandId
)
{
return
res
.
redirect
(
301
,
helpers
.
urlFormat
(
'/index/brand'
,
{
brand_id
:
brandId
}));
}
})().
catch
(
next
);
},
/**
* 新路由承接页,参数解析
*/
resolveParams
(
req
,
res
,
next
)
{
let
pathParams
=
_
.
last
(
_
.
split
(
req
.
path
.
replace
(
'.html'
,
''
),
'/'
));
req
.
query
.
shop_id
=
_
.
last
(
_
.
split
(
pathParams
,
'-'
));
shop
.
entry
(
req
,
res
,
next
);
},
/**
* 店铺统一入口
*/
entry
(
req
,
res
,
next
)
{
const
shopId
=
_
.
parseInt
(
stringProcess
.
paramsFilter
(
req
.
query
.
shop_id
));
const
brandId
=
_
.
parseInt
(
stringProcess
.
paramsFilter
(
req
.
query
.
brand_id
));
const
{
domain
}
=
req
.
query
;
const
domain
=
req
.
query
.
domain
;
const
uid
=
req
.
user
.
uid
;
req
.
shopInfo
=
{};
...
...
apps/product/models/detail.js
View file @
f31b5f1
...
...
@@ -561,9 +561,7 @@ module.exports = class extends global.yoho.BaseModel {
let
storeUrl
=
''
;
if
(
origin
.
shop_id
)
{
storeUrl
=
helpers
.
urlFormat
(
'/product/shop'
,
{
shop_id
:
origin
.
shop_id
});
storeUrl
=
`
/
shop
/
$
{
_
.
get
(
origin
,
'brand_info.brand_domain'
)}
-
$
{
_
.
get
(
origin
,
'shop_id'
)}.
html
`
;
}
// 悬浮的购物车信息
...
...
apps/product/router.js
View file @
f31b5f1
...
...
@@ -167,7 +167,9 @@ router.get('/index/category', list.shopCategory);
router
.
get
(
'/index/getBrandCouponsList'
,
list
.
getBrandCouponsList
);
// 店铺重构
router
.
get
(
'/shop'
,
newShop
.
entry
);
// 统一店铺入口
router
.
get
(
'/shop'
,
newShop
.
redirect
);
// 老路由重定向前置处理
router
.
get
(
'/shop/:domain-:shop_id.html'
,
newShop
.
resolveParams
);
// 新入口
router
.
get
(
'/index/brand'
,
newShop
.
entry
);
// 旧的路由,走到新的 controller
router
.
get
(
'/index/brandFav'
,
newShop
.
brandFav
);
router
.
get
(
'/new/shop/hotlist'
,
newShop
.
shopHotList
);
...
...
doraemon/middleware/url-rewrite.js
View file @
f31b5f1
...
...
@@ -66,6 +66,11 @@ module.exports = () => {
req
.
url
=
`
/
product
/
search$
{
req
.
path
}
`
;
}
if
(
/^
\/
shop/
.
test
(
req
.
url
))
{
// SEO 店铺路由重写 新路由
req
.
url
=
`
/
product
/
$
{
req
.
url
}
`
;
}
next
();
};
};
...
...
doraemon/views/partial/product/recommend-goods.hbs
View file @
f31b5f1
...
...
@@ -53,11 +53,11 @@
{{/
tags
}}
</div>
<div
class=
"good-detail-img"
>
<a
class=
"good-thumb"
href=
"
{{
url
}}
"
>
<a
class=
"good-thumb"
href=
"
{{
url
}}
"
title=
"
{{
seoTitle
}}
"
>
{{#if
@root
.
_noLazy
}}
<img
src=
"
{{
image2
default_images
w
=
235
h
=
314
q
=
60
}}
"
/>
<img
src=
"
{{
image2
default_images
w
=
235
h
=
314
q
=
60
}}
"
alt=
"
{{
seoTitle
}}
"
/>
{{else}}
<img
class=
"lazy"
data-original=
"
{{
image2
default_images
w
=
235
h
=
314
q
=
60
}}
"
/>
<img
class=
"lazy"
data-original=
"
{{
image2
default_images
w
=
235
h
=
314
q
=
60
}}
"
alt=
"
{{
seoTitle
}}
"
/>
{{/if}}
</a>
{{#
is_soon_sold_out
}}
...
...
@@ -79,7 +79,7 @@
</div>
<div
class=
"good-detail-text"
>
<div
class=
"name"
>
<a
href=
"
{{
url
}}
"
>
{{
product_name
}}
</a>
<a
href=
"
{{
url
}}
"
title=
"
{{
seoTitle
}}
"
>
{{
product_name
}}
</a>
</div>
<div
class=
"price"
>
{{#if
@root
.
saleViplogin
}}
...
...
utils/detail-process.js
View file @
f31b5f1
...
...
@@ -2,7 +2,6 @@
* @Author: Targaryen
* @Date: 2017-06-20 15:48:39
* @Last Modified by: Targaryen
* @Last Modified time: 2017-06-20 16:04:05
*/
const
_
=
require
(
'lodash'
);
const
helpers
=
global
.
yoho
.
helpers
;
...
...
@@ -129,7 +128,7 @@ class DetailProcess {
// 底部简介URL链接
dest
.
introUrl
=
'/product/detail/intro/'
+
origin
.
product_skn
;
dest
.
brandName
=
_
.
get
(
origin
,
'brand_info.brand_name'
,
''
);
dest
.
sortName
=
_
.
get
(
origin
,
'
middle
_sort_name'
,
''
);
dest
.
sortName
=
_
.
get
(
origin
,
'
small
_sort_name'
,
''
);
return
dest
;
}
...
...
utils/product-process.js
View file @
f31b5f1
...
...
@@ -2,6 +2,10 @@
require
(
'../app'
);
const
_
=
require
(
'lodash'
);
const
helpers
=
global
.
yoho
.
helpers
;
const
GENDER
=
{
1
:
'男'
,
2
:
'女'
};
/**
* 根据性别来决定 默认图片获取字段 如果是 2、3
...
...
@@ -228,6 +232,8 @@ exports.processProductList = (list, options) => {
product
.
similar
=
true
;
}
product
.
seoTitle
=
`
$
{
product
.
brand_name
}
|
$
{
product
.
gender
?
GENDER
[
product
.
gender
]
+
'|'
:
''
}
$
{
product
.
small_sort_name
}
|
$
{
product
.
product_name
}
|
YOHO
!
BUY
有货`
;
// eslint-disable-line
pruductList
.
push
(
product
);
});
...
...
Please
register
or
login
to post a comment