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
郝肖肖
7 years ago
Commit
f39b58ee5a964307d94dc32dbf72706da848b9e7
1 parent
5e52d7ea
'news-brands'
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
204 additions
and
55 deletions
apps/news/models/news-service.js
apps/news/models/utils.js
apps/news/views/action/news-detail.hbs
apps/product/models/search.js
doraemon/models/hot-brands.js
doraemon/views/partial/product/rec-keywords.hbs
public/scss/news/_detail.css
public/scss/news/_index.css
public/scss/news/_recommend-keywords.css
apps/news/models/news-service.js
View file @
f39b58e
...
...
@@ -7,6 +7,7 @@ const NewsAPi = require('./news-api');
const
utils
=
require
(
'./utils'
);
const
moment
=
require
(
'moment'
);
const
searchHandler
=
require
(
'../../product/models/search-handler'
);
const
hotBrandsModel
=
require
(
'../../../doraemon/models/hot-brands'
);
const
redis
=
global
.
yoho
.
redis
;
const
BOYS
=
'boys'
;
...
...
@@ -123,8 +124,6 @@ module.exports = class extends global.yoho.BaseModel {
getIndexList
(
channel
,
param
)
{
let
newsAPi
=
new
NewsAPi
(
this
.
ctx
);
let
params
=
{
type
:
'wechat'
,
limit
:
20
,
page
:
param
.
page
||
1
};
...
...
@@ -139,7 +138,11 @@ module.exports = class extends global.yoho.BaseModel {
content_code
:
ADS_CODE
[
channel
]
||
ADS_CODE
.
boys
,
isAdDegrade
:
_
.
get
(
this
.
ctx
,
'req.app.locals.pc.guang.removeAd'
,
false
)
}),
newsAPi
.
getPolymerizationList
(
Object
.
assign
({},
params
,
{
id
:
ATYPE
})),
newsAPi
.
getPolymerizationList
(
Object
.
assign
({},
params
,
{
type
:
'wechat'
,
limit
:
20
,
id
:
ATYPE
})),
];
return
Promise
.
all
(
apiMethod
).
then
(
result
=>
{
...
...
@@ -177,8 +180,8 @@ module.exports = class extends global.yoho.BaseModel {
'点击这里'
,
'点这里'
]);
return
{
header
:
header
,
content
:
utils
.
filterAhtml
(
content
)};
content
=
utils
.
filterAhtml
(
content
);
return
{
header
:
header
,
content
:
utils
.
imgAlt
(
content
,
contents
.
title
,
5
)};
}
// 潮流详情
...
...
@@ -194,6 +197,16 @@ module.exports = class extends global.yoho.BaseModel {
});
}
// 获取热销品牌
_getHotBrands
()
{
return
{
recommendKeywords
:
{
keywordsTitle
:
'热销品牌'
,
keywords
:
_
.
map
(
hotBrandsModel
.
hotBrands
(),
item
=>
{
return
Object
.
assign
({},
item
,
{
keyword
:
item
.
title
});
})
}};
}
detail
(
channel
,
param
)
{
let
params
=
{
id
:
param
.
id
,
...
...
@@ -229,6 +242,9 @@ module.exports = class extends global.yoho.BaseModel {
// 详情页数据
Object
.
assign
(
responseData
,
this
.
_formatDetail
(
result
[
3
],
params
));
// 热销品牌
Object
.
assign
(
responseData
,
this
.
_getHotBrands
());
// 导航pathNav
let
title
=
_
.
get
(
responseData
,
'header.title'
,
'潮流资讯详情页'
);
...
...
apps/news/models/utils.js
View file @
f39b58e
...
...
@@ -23,7 +23,10 @@ const util = {
});
return
$
.
html
();
html
=
$
.
html
();
$
=
''
;
return
html
;
},
// 过滤 a标签连接和删除html标签中的script和link脚本
...
...
@@ -36,7 +39,30 @@ const util = {
$
(
'a:not(.a-anchor)'
).
attr
(
'href'
,
'javascript:void(0);'
).
css
({
cursor
:
'text'
});
// eslint-disable-line
$
(
'script,link'
).
remove
();
return
$
.
html
();
html
=
$
.
html
();
$
=
''
;
return
html
;
},
// 过滤 a标签连接和删除html标签中的script和link脚本
imgAlt
:
(
html
,
alt
,
num
)
=>
{
if
(
!
html
)
{
return
html
;
}
let
$
=
cheerio
.
load
(
html
,
{
decodeEntities
:
false
});
_
.
each
(
$
(
`
img
`
).
slice
(
0
,
num
),
item
=>
{
let
$dom
=
$
(
item
);
$dom
.
attr
(
'alt'
,
$dom
.
attr
(
'alt'
)
||
alt
);
})
html
=
$
.
html
();
$
=
''
;
return
html
;
}
};
...
...
apps/news/views/action/news-detail.hbs
View file @
f39b58e
<div
class=
"news-detail-page news-page yoho-page clearfix"
>
{{>
common
/
path-nav
}}
<div
class=
"left-side detail-body"
data-id=
"
{{
id
}}
"
>
{{#
header
}}
<h1
class=
"detail-title"
>
{{
title
}}
</h1>
<div
class=
"article-info clearfix"
>
{{#if
authorUrl
}}
<div
class=
"article-author"
>
<div
class=
"author-avatar"
>
<a
href=
"
{{
authorUrl
}}
"
target=
"_blank"
>
<img
src=
"http:
{{
image2
avatar
}}
"
>
</a>
</div>
{{>
common
/
path-nav
}}
<div
class=
"left-side detail-body"
data-id=
"
{{
id
}}
"
>
{{#
header
}}
<h1
class=
"detail-title"
>
{{
title
}}
</h1>
<div
class=
"article-info clearfix"
>
{{#if
authorUrl
}}
<div
class=
"article-author"
>
<div
class=
"author-avatar"
>
<a
href=
"
{{
authorUrl
}}
"
target=
"_blank"
>
<img
src=
"http:
{{
image2
avatar
}}
"
>
</a>
</div>
<div
class=
"author-info"
>
<a
class=
"author-name"
href=
"
{{
authorUrl
}}
"
>
{{
name
}}
</a>
</div>
{{/if}}
<div
class=
"article-status clearfix"
>
{{#if
time
}}
<span
class=
"article-time"
>
<i
class=
"iconfont"
>

</i>
{{
time
}}
</span>
{{/if}}
{{#if
click
}}
<span
class=
"article-click"
>
点击:
<em>
{{
click
}}
</em></span>
{{/if}}
{{#if
commentNum
}}
<a
href=
"#comment-info"
id=
"article-comment"
class=
"article-comment"
><em
class=
"comment-num"
>
{{
commentNum
}}
</em>
条评论
</a>
{{/if}}
</div>
<div
class=
"author-info"
>
<a
class=
"author-name"
href=
"
{{
authorUrl
}}
"
>
{{
name
}}
</a>
</div>
{{/if}}
<div
class=
"article-status clearfix"
>
{{#if
time
}}
<span
class=
"article-time"
>
<i
class=
"iconfont"
>

</i>
{{
time
}}
</span>
{{/if}}
{{#if
click
}}
<span
class=
"article-click"
>
点击:
<em>
{{
click
}}
</em></span>
{{/if}}
{{#if
commentNum
}}
<a
href=
"#comment-info"
id=
"article-comment"
class=
"article-comment"
><em
class=
"comment-num"
>
{{
commentNum
}}
</em>
条评论
</a>
{{/if}}
</div>
{{/
header
}}
<div
class=
"article-main"
>
{{{
content
}}}
</div>
{{/
header
}}
<div
class=
"article-main"
>
{{{
content
}}}
</div>
<div
class=
"right-side detail-side"
>
{{>
news-right-side
}}
</div>
</div>
<div
class=
"right-side detail-side"
>
{{>
news-right-side
}}
</div>
<div
class=
"hot-brand"
>
{{>
product
/
rec-keywords
}}
</div>
</div>
...
...
apps/product/models/search.js
View file @
f39b58e
...
...
@@ -518,7 +518,7 @@ function getSearchKeywordDataById(id, params, channel) {
}
// 前10的热销品牌
Object
.
assign
(
resData
.
search
.
leftContent
,
searchHandler
.
hotBrands
(
hotBrandsModel
.
hotBrands
()));
Object
.
assign
(
resData
.
search
.
leftContent
,
searchHandler
.
hotBrands
(
hotBrandsModel
.
hotBrands
()
.
slice
(
0
,
10
)
));
return
resData
;
}).
bind
(
this
)();
...
...
doraemon/models/hot-brands.js
View file @
f39b58e
...
...
@@ -5,6 +5,7 @@
*/
'use strict'
;
const
helpers
=
global
.
yoho
.
helpers
;
/**
* 热销品牌
*/
...
...
@@ -13,54 +14,104 @@ const hotBrands = () => {
return
[
{
url
:
'//www.yohobuy.com/shop/vans-1284.html'
,
url
:
helpers
.
urlFormat
(
'/shop/vans-1284.html'
)
,
image
:
`
//img10.static.yhbimg.com/yhb-img01/2016/03/24/15/01ef24d3ec4caabd8c416901cdf4739917.jpg${imgView}`,
title
:
'VANS/范斯'
},
{
url
:
'//www.yohobuy.com/shop/madness-1482.html'
,
url
:
helpers
.
urlFormat
(
'/shop/madness-1482.html'
)
,
image
:
`
//img11.static.yhbimg.com/yhb-img01/2015/12/07/10/01e12663e56ae7c559ac72de209b6bf787.jpg${imgView}`,
title
:
'MADNESS'
},
{
url
:
'//www.yohobuy.com/shop/hipanda-1488.html'
,
url
:
helpers
.
urlFormat
(
'/shop/hipanda-1488.html'
)
,
image
:
`
//img11.static.yhbimg.com/yhb-img01/2017/11/06/09/01a9ea04b54af0c2830041678ff8e1b6a2.jpg${imgView}`,
title
:
'HIPANDA/你好熊猫'
},
{
url
:
'//www.yohobuy.com/shop/dickies-1474.html'
,
url
:
helpers
.
urlFormat
(
'/shop/dickies-1474.html'
)
,
image
:
`
//img10.static.yhbimg.com/yhb-img01/2017/11/03/11/018c06003f58b0a5087258ed21f63fde7b.jpg${imgView}`,
title
:
'Dickies/迪凯斯'
},
{
url
:
'//www.yohobuy.com/shop/viishow-1360.html'
,
url
:
helpers
.
urlFormat
(
'/shop/viishow-1360.html'
)
,
image
:
`
//img11.static.yhbimg.com/yhb-img01/2017/11/06/10/012ca25acd7958b8b499f80a40c28de059.jpg${imgView}`,
title
:
'viishow/维秀'
},
{
url
:
'//www.yohobuy.com/shop/dusty-97.html'
,
url
:
helpers
.
urlFormat
(
'/shop/dusty-97.html'
)
,
image
:
`
//img10.static.yhbimg.com/yhb-img01/2017/11/02/17/01eaa0d064e0a59ea683686637271eede0.jpg${imgView}`,
title
:
'DUSTY/DUSTY潮牌'
},
{
url
:
'//www.yohobuy.com/shop/adidas-1258.html'
,
url
:
helpers
.
urlFormat
(
'/shop/adidas-1258.html'
)
,
image
:
`
//img10.static.yhbimg.com/yhb-img01/2017/10/31/10/013ec61b8ccd4440db11c9ab2371c3605d.jpg${imgView}`,
title
:
'adidas Originals/阿迪达斯'
},
{
url
:
'//www.yohobuy.com/shop/genanx-300.html'
,
url
:
helpers
.
urlFormat
(
'/shop/genanx-300.html'
)
,
image
:
`
//img11.static.yhbimg.com/yhb-img01/2017/10/31/10/0183880efb53bb6e13fce74b670aef1cff.jpg${imgView}`,
title
:
'Genanx/格男仕'
},
{
url
:
'//www.yohobuy.com/shop/glemall-2380.html'
,
url
:
helpers
.
urlFormat
(
'/shop/glemall-2380.html'
)
,
image
:
`
//img10.static.yhbimg.com/yhb-img01/2017/11/03/09/0127a25d415d0e5a70fb26dc43ac1a5663.jpg${imgView}`,
title
:
'GLEMALL'
},
{
url
:
'//www.yohobuy.com/shop/puma-1534.html'
,
url
:
helpers
.
urlFormat
(
'/shop/puma-1534.html'
)
,
image
:
`
//img11.static.yhbimg.com/yhb-img01/2017/10/31/10/01e78f852cf69a57fefe71dcb8aab4b457.jpg${imgView}`,
title
:
'PUMA/彪马'
},
{
url
:
helpers
.
urlFormat
(
'/shop/thething-1330.html'
),
image
:
`
//img10.static.yhbimg.com/yhb-img01/2017/11/06/10/018cedbc8d32fb54edc54cc9e75c726464.jpg${imgView}`,
title
:
'THETHING'
},
{
url
:
helpers
.
urlFormat
(
'/shop/stussy-1292.html'
),
image
:
`
//img11.static.yhbimg.com/yhb-img01/2017/11/02/17/01f0487eefeecfc15ab3f8559317a8a3dc.jpg${imgView}`,
title
:
'Stussy/斯图西'
},
{
url
:
helpers
.
urlFormat
(
'/shop/converse-1252.html'
),
image
:
`
//img10.static.yhbimg.com/yhb-img01/2017/10/31/10/01b21a4da5297218adf33bedca11e09ce5.jpg${imgView}`,
title
:
'Converse/匡威'
},
{
url
:
helpers
.
urlFormat
(
'/shop/akop-2222.html'
),
image
:
`
//img11.static.yhbimg.com/yhb-img01/2017/11/03/09/0168a4088b1db414fac91286addb44fbe5.jpg${imgView}`,
title
:
'AKOP'
},
{
url
:
helpers
.
urlFormat
(
'/shop/timberland-2642.html'
),
image
:
`
//img10.static.yhbimg.com/yhb-img01/2017/11/06/10/017f4e8f44cf9f3f273d149ad57aa10257.jpg${imgView}`,
title
:
'Timberland/添柏岚'
},
{
url
:
helpers
.
urlFormat
(
'/shop/levis-1248.html'
),
image
:
`
//img11.static.yhbimg.com/yhb-img01/2017/11/06/09/011ead0b91f6f2cf776eb295555121e47e.jpg${imgView}`,
title
:
'Levi’s/李维斯'
},
{
url
:
helpers
.
urlFormat
(
'/shop/dc-275.html'
),
image
:
`
//img11.static.yhbimg.com/yhb-img01/2017/10/31/10/01f1bb407957dc717119ab9d32ea3f95fd.jpg${imgView}`,
title
:
'DC/DCSHOECOUSA'
},
{
url
:
helpers
.
urlFormat
(
'/shop/guuka-492.html'
),
image
:
`
//img11.static.yhbimg.com/yhb-img01/2017/11/02/17/01fcb145bf9e9276549468702b1ec57a7e.jpg${imgView}`,
title
:
'Guuka/古由卡'
},
{
url
:
helpers
.
urlFormat
(
'/shop/lal-1540.html'
),
image
:
`
//img10.static.yhbimg.com/yhb-img01/2017/11/02/16/013acf2a31ab930d34a80b2d87bfe4a9a9.jpg${imgView}`,
title
:
'Life·After Life'
},
{
url
:
helpers
.
urlFormat
(
'/shop/redcharcoal-2996.html'
),
image
:
`
//img10.static.yhbimg.com/yhb-img01/2017/10/31/10/01a8b7f3f496fbeb7a681aeacb9ea9aba5.jpg${imgView}`,
title
:
'Red Charcoal'
}
];
};
...
...
doraemon/views/partial/product/rec-keywords.hbs
0 → 100644
View file @
f39b58e
{{#
recommendKeywords
}}
<div
class=
"recommend-keywords"
>
<h3>
{{#if
keywordsTitle
}}{{
keywordsTitle
}}{{^}}
相关推荐
{{/if}}
</h3>
<p>
{{#
keywords
}}
<a
href=
"
{{
url
}}
"
title=
"
{{
keyword
}}
"
target=
"_blank"
class=
"keyword"
>
{{
keyword
}}
</a>
{{/
keywords
}}
</p>
</div>
{{/
recommendKeywords
}}
...
...
public/scss/news/_detail.css
View file @
f39b58e
...
...
@@ -52,7 +52,7 @@
}
.detail-title
{
font-size
:
2
8
px
;
font-size
:
2
6
px
;
line-height
:
50px
;
border-bottom
:
1px
dotted
#c1c1c1
;
word-wrap
:
break-word
;
...
...
@@ -123,6 +123,7 @@
height
:
auto
;
width
:
auto
;
max-width
:
100%
;
color
:
#fff
;
}
.article-text
{
...
...
@@ -557,5 +558,10 @@
margin-bottom
:
0
;
}
}
.hot-brand
{
width
:
100%
;
overflow
:
hidden
;
}
}
...
...
public/scss/news/_index.css
View file @
f39b58e
@import
"base"
;
@import
"detail"
;
@import
"recommend-keywords"
;
...
...
public/scss/news/_recommend-keywords.css
0 → 100644
View file @
f39b58e
.recommend-keywords
{
margin
:
20px
0
;
border
:
1px
#e0e0e0
solid
;
h3
{
height
:
46px
;
border-bottom
:
1px
#e0e0e0
solid
;
line-height
:
44px
;
background
:
#f5f5f5
;
text-align
:
center
;
font-size
:
15px
;
}
p
{
padding
:
10px
;
.keyword
{
display
:
inline-block
;
margin
:
5px
15px
;
font-size
:
12px
;
width
:
150px
;
white-space
:
nowrap
;
overflow
:
hidden
;
text-overflow
:
ellipsis
;
}
.common
{
display
:
inline-block
;
margin
:
5px
15px
;
font-size
:
12px
;
width
:
190px
;
white-space
:
nowrap
;
overflow
:
hidden
;
text-overflow
:
ellipsis
;
}
}
}
...
...
Please
register
or
login
to post a comment