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
周少峰
8 years ago
Commit
b27d3fdc1e17bc315ce6a6084ac44b9e7c98343d
2 parents
87d47404
79cbabe5
master
...
baidu_ocpcapi
develop
feature/canbuy
feature/channelDataMap
feature/company-profile
feature/contact
feature/detail-link
feature/home-optimize
feature/overseas-edition
feature/payment
feature/pcurl
feature/reduce
feature/refactor_alert
feature/shoppingPay
feature/virtualOrder
hotfix/11
hotfix/cart
hotfix/changeappversion
hotfix/gift
hotfix/im
hotfix/link
hotfix/ocpc
hotfix/shop
hotfix/upload
hotfix/yohobi
release/6.9.0
release/6.9.2
2019-12-5
all
Merge branch 'gray'
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
251 additions
and
79 deletions
apps/common/controllers/suggestFeedBack.js
apps/common/models/suggestFeedBack-api.js
apps/common/models/suggestFeedBack-service.js
apps/product/controllers/search.js
apps/product/models/detail-hotarea-service.js
apps/product/models/detail-product-api.js
apps/product/models/detail-service.js
apps/product/views/action/product/detail.hbs
apps/product/views/partial/product/alike.hbs
apps/product/views/partial/product/recommend-keywords.hbs
apps/product/views/partial/product/recommend-receiveview.hbs
doraemon/middleware/redis.js
package.json
public/js/product/detail.page.js
public/scss/product/_detail.css
apps/common/controllers/suggestFeedBack.js
View file @
b27d3fd
...
...
@@ -11,7 +11,7 @@ const suggestFeedBackModel = require('../models/suggestFeedBack-service');
const
getFeedBack
=
(
req
,
res
,
next
)
=>
{
suggestFeedBackModel
.
suggestFeedBack
().
then
((
result
)
=>
{
suggestFeedBackModel
.
suggestFeedBack
(
req
.
user
.
uid
).
then
((
result
)
=>
{
res
.
jsonp
(
result
);
}).
catch
(
next
);
};
...
...
apps/common/models/suggestFeedBack-api.js
View file @
b27d3fd
...
...
@@ -14,9 +14,9 @@ const URL_ACTIVITY_QUESTION = '/activity/question/';
* @param uid
* @return string
*/
const
feedBackApi
=
()
=>
{
const
feedBackApi
=
(
uid
)
=>
{
return
service
.
get
(
URL_ACTIVITY_QUESTION
+
'questionList'
,
{});
return
service
.
get
(
URL_ACTIVITY_QUESTION
+
'questionList'
,
{
uid
:
uid
});
};
module
.
exports
=
{
...
...
apps/common/models/suggestFeedBack-service.js
View file @
b27d3fd
...
...
@@ -9,9 +9,9 @@ const api = require('./suggestFeedBack-api');
const
helpers
=
global
.
yoho
.
helpers
;
const
_
=
require
(
'lodash'
);
const
suggestFeedBack
=
()
=>
{
const
suggestFeedBack
=
(
uid
)
=>
{
return
api
.
feedBackApi
().
then
((
result
)
=>
{
return
api
.
feedBackApi
(
uid
).
then
((
result
)
=>
{
let
suggestData
=
[];
if
(
result
&&
result
.
code
===
200
&&
_
.
get
(
result
,
'data.rows'
))
{
...
...
apps/product/controllers/search.js
View file @
b27d3fd
...
...
@@ -210,28 +210,29 @@ const keyId = (req, res, next) => {
let
params
=
req
.
query
;
let
id
=
req
.
params
.
id
;
return
search
.
getSearchKeywordDataById
(
id
,
params
,
req
.
yoho
.
channel
).
then
(
result
=>
{
return
search
.
getSearchKeywordDataById
(
id
,
Object
.
assign
({
stocknumber
:
-
1
},
params
),
req
.
yoho
.
channel
).
then
(
result
=>
{
if
(
!
result
)
{
return
next
();
}
if
(
!
result
)
{
return
next
();
}
let
query
=
result
.
queryKey
;
let
query
=
result
.
queryKey
;
Object
.
assign
(
result
,
{
pageNoFollow
:
true
,
title
:
`
$
{
query
}
价格
_
图片
_
品牌
_
怎么样
-
YOHO
!
BUY
有货`
,
keywords
:
`
$
{
query
},
$
{
query
}
价格
,
$
{
query
}
图片
,
$
{
query
}
怎么样
,
$
{
query
}
品牌
,
YOHO
!
BUY
有货`
,
description
:
`
YOHO
!
BUY
有货网
yohobuy
.
com
是国内专业的
$
{
query
}
网上潮流购物商城
,
为您找到
$
{
_
.
get
(
result
,
Object
.
assign
(
result
,
{
pageNoFollow
:
true
,
title
:
`
$
{
query
}
价格
_
图片
_
品牌
_
怎么样
-
YOHO
!
BUY
有货`
,
keywords
:
`
$
{
query
},
$
{
query
}
价格
,
$
{
query
}
图片
,
$
{
query
}
怎么样
,
$
{
query
}
品牌
,
YOHO
!
BUY
有货`
,
description
:
`
YOHO
!
BUY
有货网
yohobuy
.
com
是国内专业的
$
{
query
}
网上潮流购物商城
,
为您找到
$
{
_
.
get
(
result
,
'search.totalCount'
,
0
)}
条
$
{
query
}
、产品的详细参数
,
实时报价
,
价格行情
,
图片、评价、品牌等信息。买
$
{
query
},
就上
YOHO
!
BUY
有货`
});
});
if
(
!
_
.
get
(
result
,
'search.goods'
)
||
!
_
.
get
(
result
,
'search.goods'
).
length
)
{
_
.
set
(
result
,
'search.keyWord'
,
query
);
return
res
.
render
(
'search/no-result'
,
result
);
}
res
.
render
(
'search/index'
,
result
);
}).
catch
(
next
);
if
(
!
_
.
get
(
result
,
'search.goods'
)
||
!
_
.
get
(
result
,
'search.goods'
).
length
)
{
_
.
set
(
result
,
'search.keyWord'
,
query
);
return
res
.
render
(
'search/no-result'
,
result
);
}
res
.
render
(
'search/index'
,
result
);
}).
catch
(
next
);
};
module
.
exports
=
{
...
...
apps/product/models/detail-hotarea-service.js
View file @
b27d3fd
...
...
@@ -56,7 +56,7 @@ const indexAsync = pid => {
marketPrice
:
cur
.
product
.
productPriceBo
.
formatMarketPrice
,
productName
:
cur
.
product
.
productName
,
href
:
helpers
.
getUrlBySkc
(
_
.
get
(
goods
,
'goodsImagesList[0]
.productSkn'
,
''
))
_
.
get
(
cur
.
product
,
'productPriceBo
.productSkn'
,
''
))
};
acc
.
push
(
point
);
...
...
apps/product/models/detail-product-api.js
View file @
b27d3fd
...
...
@@ -6,6 +6,7 @@
const
api
=
global
.
yoho
.
API
;
const
config
=
global
.
yoho
.
config
;
const
redis
=
global
.
yoho
.
redis
;
/**
* 商品的 banner
...
...
@@ -131,8 +132,8 @@ const getShopRecommendAsync = (skn, page, limit) => {
return
api
.
get
(
''
,
{
method
:
'web.product.shopRecommend'
,
product_skn
:
skn
,
page
:
page
,
limit
:
limit
page
:
page
||
1
,
limit
:
limit
||
20
});
};
...
...
@@ -146,6 +147,24 @@ const getBundleAsync = (skn) => {
});
};
/**
* 找相似
*/
const
getLikeAsync
=
(
skn
,
limit
)
=>
{
return
api
.
get
(
''
,
{
method
:
'app.search.findLike'
,
limit
:
limit
||
10
,
product_skn
:
skn
});
};
// 根据small_sort从redis获取分类下的关键词
const
getRecommendKeywords
=
(
smallSort
)
=>
{
return
redis
.
all
([[
'get'
,
`
golobal
:
yoho
:
seo
:
keywords
:
sortId
:
$
{
smallSort
}
`
]]).
then
(
res
=>
{
return
res
[
0
];
});
};
module
.
exports
=
{
getProductBannerAsync
,
sizeInfoAsync
,
...
...
@@ -156,5 +175,7 @@ module.exports = {
isSupportReturnedSale
,
getLimitedProductStatusAsync
,
getShopRecommendAsync
,
getBundleAsync
getBundleAsync
,
getLikeAsync
,
getRecommendKeywords
};
...
...
apps/product/models/detail-service.js
View file @
b27d3fd
...
...
@@ -36,6 +36,7 @@ const BLANK_STR = ' ';
const
BUNDLE_PRODUCE
=
2
;
// 量贩
const
BUNDLE_PACKAGE
=
1
;
// 套餐
const
tdk
=
require
(
'../../../utils/getTDK'
);
const
Helpers
=
global
.
yoho
.
helpers
;
const
_getProductAdditionInfoAsync
=
(
data
)
=>
{
return
co
(
function
*
()
{
...
...
@@ -1009,6 +1010,19 @@ const _getIntroInfo = (productSkn, maxSortId, additionalData)=> {
return
result
;
};
// 返回6条推荐关键词页面
const
getKeywordsInfo
=
(
keywords
)
=>
{
let
res
=
[];
_
.
forEach
(
_
.
slice
(
_
.
shuffle
(
keywords
),
0
,
12
),
val
=>
{
res
.
push
({
url
:
Helpers
.
urlFormat
(
`
/
chanpin
/
$
{
val
.
id
}.
html
`
),
keyword
:
val
.
keyword
});
});
return
res
;
};
/**
* 获取seo信息
*
...
...
@@ -1103,6 +1117,9 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => {
return
result
;
}
// sku商品信息,尺寸信息
let
skuData
=
_getSkuDataByProductBaseInfo
(
origin
);
result
.
name
=
propOrigin
(
'product_name'
);
result
.
skn
=
propOrigin
(
'product_skn'
);
result
.
productId
=
propOrigin
(
'product_id'
);
...
...
@@ -1145,6 +1162,17 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => {
requestApi
.
bundle
=
productAPI
.
getBundleAsync
(
result
.
skn
);
// 量贩
}
// 找相似
if
(
skuData
.
totalStorageNum
===
0
)
{
requestApi
.
alike
=
productAPI
.
getLikeAsync
(
result
.
skn
);
}
// 相关推荐词
requestApi
.
recommendKeywords
=
productAPI
.
getRecommendKeywords
(
result
.
smallSortId
);
// 店铺推荐直出(seo需要)
requestApi
.
shopRecommend
=
productAPI
.
getShopRecommendAsync
(
result
.
skn
);
let
requestData
=
yield
Promise
.
props
(
requestApi
);
let
additionalData
=
requestData
.
addition
;
...
...
@@ -1153,6 +1181,20 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => {
let
coupon
=
requestData
.
coupon
;
let
limitedInfo
=
requestData
.
limited
;
let
bundle
=
requestData
.
bundle
;
let
recommendKeywords
=
requestData
.
recommendKeywords
?
JSON
.
parse
(
requestData
.
recommendKeywords
)
:
[];
// 处理相似商品
result
.
alike
=
_
.
map
(
_
.
get
(
requestData
,
'alike.data.product_list'
,
''
),
val
=>
{
return
Object
.
assign
({
url
:
Helpers
.
getUrlBySkc
(
val
.
product_skn
)},
val
);
});
// 推荐关键词页面
result
.
recommendKeywords
=
getKeywordsInfo
(
recommendKeywords
);
// 处理店铺推荐
result
.
shopRecommend
=
_
.
map
(
_
.
get
(
requestData
,
'shopRecommend.data.product_list'
,
''
),
val
=>
{
return
Object
.
assign
({
url
:
Helpers
.
getUrlBySkc
(
val
.
product_skn
)},
val
);
});
// 商品标签
result
.
tags
=
_getTagsDataByProductInfo
(
origin
);
...
...
@@ -1240,9 +1282,6 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => {
result
.
presale
=
'Y'
;
}
// sku商品信息,尺寸信息
let
skuData
=
_getSkuDataByProductBaseInfo
(
origin
);
result
.
img
=
skuData
.
defaultImage
;
result
.
colors
=
skuData
.
skuGoods
;
let
totalStorageNum
=
skuData
.
totalStorageNum
;
...
...
@@ -1722,7 +1761,6 @@ const getPackage = co(function * (skn) {
return
resData
;
});
module
.
exports
=
{
getShareOrderListAsync
:
commentService
.
getShareOrderListAsync
,
// 获取评论列表
indexConsultAsync
:
consultService
.
indexAsync
,
// 获取咨询列表
...
...
apps/product/views/action/product/detail.hbs
View file @
b27d3fd
...
...
@@ -23,6 +23,8 @@
<div
id=
"package"
class=
"package-box clearfix hide"
></div>
{{>
product
/
alike
}}
<div
class=
"total-content"
>
<div
class=
"other-infos"
>
{{>
product
/
description
}}
...
...
@@ -39,6 +41,8 @@
{{>
product
/
after-service
}}
{{>
product
/
recommend-keywords
}}
{{>
product
/
recommend-receiveview
}}
</div>
...
...
apps/product/views/partial/product/alike.hbs
0 → 100644
View file @
b27d3fd
{{#if
goodsInfo
.
alike
}}
<div
class=
"bottom-tab alike-title"
>
<p>
<span
class=
"bottom-title bottom-cur"
>
相似商品
</span>
<span
class=
"bottom-title change"
>
换一批
<span
class=
"iconfont change-icon"
>

</span>
</span>
</p>
</div>
<div
class=
"individual-comment info-block info-bottom alike"
>
<div>
<div
class=
"recommend-content clearfix"
>
<div
class=
"recommend-slider-alike"
>
<ul
class=
" img-list"
>
{{#
goodsInfo
.
alike
}}
<li
class=
"img-item"
>
<span
class=
"hide goods-id"
>
{{
goods_id
}}
</span>
<div
class=
"good"
>
<a
href=
"
{{
url
}}
"
target=
"_blank"
>
<img
class=
"lazy"
src=
"
{{
image2
default_images
w
=
280
h
=
382
}}
"
/>
</a>
<a
class=
"name"
href=
"
{{
url
}}
"
target=
"_blank"
>
{{
product_name
}}
</a>
<p
class=
"price"
>
<span
class=
"market-price"
>
¥
{{
market_price
}}
</span>
<span
class=
"sale-price"
>
¥
{{
sales_price
}}
</span>
</p>
</div>
</li>
{{/
goodsInfo
.
alike
}}
</ul>
<div
class=
"img-brand-switch"
>
<a
class=
"prev iconfont"
href=
"javascript:;"
>

</a>
<a
class=
"next iconfont"
href=
"javascript:;"
>

</a>
</div>
</div>
</div>
</div>
</div>
{{/if}}
\ No newline at end of file
...
...
apps/product/views/partial/product/recommend-keywords.hbs
0 → 100644
View file @
b27d3fd
{{#if
goodsInfo
.
recommendKeywords
}}
<div
class=
"recommend-keywords"
>
<h3>
相关推荐
</h3>
<p>
{{#
goodsInfo
.
recommendKeywords
}}
<a
href=
"
{{
url
}}
"
title=
"
{{
keyword
}}
"
target=
"_blank"
>
{{
keyword
}}
</a>
{{/
goodsInfo
.
recommendKeywords
}}
</p>
</div>
{{/if}}
...
...
apps/product/views/partial/product/recommend-receiveview.hbs
View file @
b27d3fd
...
...
@@ -25,17 +25,34 @@
{{>
product
/
latest-walk-tpl
}}
</div>
{{/if}}
<div
id=
"recommend-shop"
class=
"hide"
>
<div
class=
"recommend-content clearfix"
>
<div
class=
"recommend-slider"
>
<ul
class=
" img-list"
id=
"recommend-content"
></ul>
<div
class=
"img-brand-switch"
>
<a
class=
"prev iconfont"
href=
"javascript:;"
>

</a>
<a
class=
"next iconfont"
href=
"javascript:;"
>

</a>
{{#if
goodsInfo
.
shopRecommend
}}
<div
id=
"recommend-shop"
>
<div
class=
"recommend-content clearfix"
>
<div
class=
"recommend-slider"
>
<ul
class=
" img-list"
id=
"recommend-content"
>
{{#
goodsInfo
.
shopRecommend
}}
<li
class=
"img-item"
>
<span
class=
"hide goods-id"
>
{{
goods_id
}}
</span>
<div
class=
"good"
>
<a
href=
"
{{
url
}}
"
target=
"_blank"
>
<img
class=
"lazy"
src=
"
{{
image2
default_images
w
=
280
h
=
382
}}
"
/>
</a>
<a
class=
"name"
href=
"
{{
url
}}
"
target=
"_blank"
>
{{
product_name
}}
</a>
<p
class=
"price"
>
<span
class=
"market-price"
>
¥
{{
market_price
}}
</span>
<span
class=
"sale-price"
>
¥
{{
sales_price
}}
</span>
</p>
</div>
</li>
{{/
goodsInfo
.
shopRecommend
}}
</ul>
<div
class=
"img-brand-switch"
>
<a
class=
"prev iconfont"
href=
"javascript:;"
>

</a>
<a
class=
"next iconfont"
href=
"javascript:;"
>

</a>
</div>
</div>
</div>
</div>
</div>
{{/if}}
</div>
{{/
unless
}}
...
...
doraemon/middleware/redis.js
View file @
b27d3fd
...
...
@@ -3,6 +3,8 @@ const _ = require('lodash');
const
redis
=
require
(
'redis'
);
const
bluebird
=
require
(
'bluebird'
);
const
config
=
require
(
'../../config/common'
);
const
logger
=
global
.
yoho
.
logger
;
const
timeout
=
200
;
// redis 操作超时时间
let
client
;
try
{
...
...
@@ -20,9 +22,14 @@ try {
}
}
return
client
.
multi
.
call
(
client
,
args
).
execAsync
();
return
client
.
multi
.
call
(
client
,
args
).
execAsync
().
timeout
(
timeout
).
catch
(()
=>
{
logger
.
err
(
'redis exe time out'
);
return
false
;
});
};
client
.
on
(
'error'
,
function
()
{
global
.
yoho
.
redis
=
''
;
});
...
...
package.json
View file @
b27d3fd
{
"name"
:
"yohobuy-node"
,
"version"
:
"5.9.
3
"
,
"version"
:
"5.9.
4
"
,
"private"
:
true
,
"description"
:
"A New Yohobuy Project With Express"
,
"repository"
:
{
...
...
public/js/product/detail.page.js
View file @
b27d3fd
...
...
@@ -1495,45 +1495,29 @@ function initPageYas() {
yas
.
givePoint
(
'YB_CHOOSE_FOR_YOU_Y'
,
loadYas
);
}
// 店铺推荐
// 店铺推荐
改为后台直出
function
loadRecommend
()
{
return
$
.
ajax
({
type
:
'GET'
,
url
:
'/product/detail/recommend'
,
data
:
{
skn
:
skn
,
size
:
20
,
num
:
1
}
}).
then
(
function
(
data
)
{
var
pro
=
data
.
data
.
products
;
var
recommendTpl
=
require
(
'hbs/product/recommend.hbs'
);
var
html
=
recommendTpl
(
data
.
data
);
if
(
data
.
code
===
200
&&
pro
.
length
!==
0
)
{
$
(
'#recommend-shop'
).
removeClass
(
'hide'
);
$
(
'#recommend-content'
).
append
(
html
);
$
(
'.recommend-slider'
).
slider2
({
shownum
:
5
,
isCircle
:
true
});
$
(
'.recommend-slider .img-item .goods-id'
).
each
(
function
()
{
$goodsIdArr
.
push
(
$
(
this
).
html
());
});
}
else
{
$
(
'.bottom-title'
).
eq
(
0
).
removeClass
(
'bottom-cur'
).
addClass
(
'hide'
);
$
(
'.bottom-title'
).
eq
(
1
).
addClass
(
'bottom-cur'
);
$
(
'.bottom-title'
).
filter
(
'.change'
).
addClass
(
'hide'
);
var
imgItem
=
$
(
'.recommend-slider .img-item'
),
$bottomTitle
=
$
(
'.bottom-tab .bottom-title'
);
$
(
'#recommend-shop'
).
remove
();
$
(
'.individual-comment .latest-walk'
).
show
();
fetchLatestWalk
();
// eslint-disable-line
}
if
(
imgItem
.
length
!==
0
)
{
// 页面加载完,埋点
initPageYas
();
});
$
(
'.recommend-slider .img-item .goods-id'
).
each
(
function
()
{
$goodsIdArr
.
push
(
$
(
this
).
html
());
});
}
else
{
$bottomTitle
.
eq
(
0
).
removeClass
(
'bottom-cur'
).
addClass
(
'hide'
);
$bottomTitle
.
eq
(
1
).
addClass
(
'bottom-cur'
);
$bottomTitle
.
filter
(
'.change'
).
addClass
(
'hide'
);
$
(
'#recommend-shop'
).
remove
();
$
(
'.individual-comment .latest-walk'
).
show
();
fetchLatestWalk
();
// eslint-disable-line
}
// 页面加载完,埋点
initPageYas
();
}
// 点击为您推荐商品埋点
...
...
@@ -1835,14 +1819,14 @@ $('.bottom-tab').on('click', '.bottom-title', function() {
$recommendComment
.
slideDown
(
SLIDETIME
);
$latestWalk
.
slideUp
(
SLIDETIME
);
$
(
'.change'
).
removeClass
(
'hide'
);
$
(
this
).
siblings
(
'.change'
).
removeClass
(
'hide'
);
}
else
{
// 最近游览
window
.
fetchLatestWalk
();
// eslint-disable-line
$recommendComment
.
slideUp
(
SLIDETIME
);
$latestWalk
.
slideDown
(
SLIDETIME
);
$
(
'.change'
).
addClass
(
'hide'
);
$
(
this
).
siblings
(
'.change'
).
addClass
(
'hide'
);
}
});
...
...
@@ -1959,6 +1943,16 @@ $(function() {
}
});
});
// 猜你喜欢、店铺推荐初始化,
$
(
'.recommend-slider-alike'
).
slider2
({
shownum
:
5
,
isCircle
:
true
});
$
(
'.recommend-slider'
).
slider2
({
shownum
:
5
,
isCircle
:
true
});
});
yasAtBottom
.
yasBottom
();
...
...
public/scss/product/_detail.css
View file @
b27d3fd
...
...
@@ -1009,7 +1009,8 @@
}
}
.bottom-tab
{
.bottom-tab
,
.alike-title
{
.bottom-title
{
font-size
:
15px
;
display
:
inline-block
;
...
...
@@ -1804,6 +1805,31 @@
}
}
.recommend-keywords
{
margin-top
:
30px
;
margin-bottom
:
20px
;
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
;
a
{
display
:
inline-block
;
margin
:
5px
15px
;
font-size
:
12px
;
}
}
}
.support-salereturned-service
{
$
service
:
product
/
service
.
png
;
...
...
@@ -2083,6 +2109,20 @@
}
}
}
.alike-title
{
margin-top
:
30px
;
}
.alike
{
.recommend-content
{
height
:
340px
;
li
{
height
:
340px
;
}
}
}
}
.coupon-big
{
...
...
Please
register
or
login
to post a comment