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
htoooth
8 years ago
Commit
7c00abe10e49a49b96950cecace881f436376ad4
2 parents
63a28105
8d502c51
merge master
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
85 additions
and
33 deletions
apps/channel/controllers/index.js
apps/product/controllers/list.js
apps/product/controllers/sale.js
apps/product/models/list.js
apps/product/models/sale-api.js
apps/product/models/sale.js
apps/product/models/search-handler.js
apps/product/models/search.js
apps/product/views/action/product/detail.hbs
apps/product/views/partial/product/detail-header.hbs
doraemon/views/partial/product/good.hbs
public/scss/product/_filter-box.css
utils/product-process.js
apps/channel/controllers/index.js
View file @
7c00abe
...
...
@@ -33,7 +33,7 @@ exports.getNewArrival = (req, res, next) => {
let
reqBody
=
req
.
body
,
pageIndex
=
reqBody
.
pageIndex
,
pageCount
=
reqBody
.
pageCount
,
channel
=
reqBody
.
type
,
channel
=
reqBody
.
type
||
req
.
yoho
.
channel
,
goods
=
[],
result
=
{};
...
...
apps/product/controllers/list.js
View file @
7c00abe
...
...
@@ -15,7 +15,7 @@ const searchApi = require(`${mRoot}/search-api`);
const
shop
=
(
shopId
,
req
,
res
,
next
,
brandInfo
)
=>
{
shopId
=
parseInt
(
shopId
,
10
);
list
.
getShopInfo
(
shopId
,
req
.
user
.
id
).
then
(
shopInfo
=>
{
list
.
getShopInfo
(
shopId
,
req
.
user
.
u
id
).
then
(
shopInfo
=>
{
if
(
+
shopInfo
.
shopTemplateType
===
2
)
{
// 经典模板
let
pjax
=
req
.
query
.
_pjax
;
...
...
@@ -158,7 +158,7 @@ exports.shopList = (req, res, next) => {
return
next
();
}
list
.
getShopListData
(
req
.
yoho
.
channel
,
req
.
query
).
then
(
result
=>
{
list
.
getShopListData
(
req
.
yoho
.
channel
,
req
.
query
,
req
.
user
.
uid
).
then
(
result
=>
{
Object
.
assign
(
result
,
{
page
:
'shop'
,
shopId
:
shopId
...
...
apps/product/controllers/sale.js
View file @
7c00abe
...
...
@@ -16,7 +16,7 @@ const sale = require(`${mRoot}/sale`); // sale 页 model
* @return {[type]} [description]
*/
exports
.
index
=
(
req
,
res
,
next
)
=>
{
let
channel
=
req
.
query
.
channel
||
req
.
cookies
.
_Channel
||
'boys'
;
let
channel
=
req
.
query
.
channel
||
req
.
yoho
.
channel
;
// 真实数据输出
sale
.
getSaleIndexData
(
channel
).
then
(
result
=>
{
...
...
@@ -41,7 +41,7 @@ exports.discount = (req, res, next) => {
saleType
:
'3'
},
req
.
query
);
let
channel
=
req
.
query
.
channel
||
req
.
cookies
.
_Channel
||
'boys'
;
let
channel
=
req
.
query
.
channel
||
req
.
yoho
.
channel
;
let
responseData
=
{
module
:
'product'
,
...
...
@@ -68,7 +68,7 @@ exports.vip = (req, res, next) => {
saleType
:
'2'
},
req
.
query
);
let
channel
=
req
.
query
.
channel
||
req
.
cookies
.
_Channel
||
'boys'
;
let
channel
=
req
.
query
.
channel
||
req
.
yoho
.
channel
;
params
.
uid
=
req
.
user
.
uid
||
0
;
...
...
@@ -95,7 +95,7 @@ exports.newSale = (req, res, next) => {
order
:
's_t_desc'
},
req
.
query
);
let
channel
=
req
.
query
.
channel
||
req
.
cookies
.
_Channel
||
'boys'
;
let
channel
=
req
.
query
.
channel
||
req
.
yoho
.
channel
;
sale
.
getSaleOthersData
(
params
,
channel
).
then
((
result
)
=>
{
res
.
render
(
'sale/other'
,
Object
.
assign
({
...
...
@@ -119,7 +119,7 @@ exports.breakingYards = (req, res, next) => {
saleType
:
'5'
},
req
.
query
);
let
channel
=
req
.
query
.
channel
||
req
.
cookies
.
_Channel
||
'boys'
;
let
channel
=
req
.
query
.
channel
||
req
.
yoho
.
channel
;
let
responseData
=
{
module
:
'product'
,
...
...
apps/product/models/list.js
View file @
7c00abe
...
...
@@ -118,7 +118,9 @@ const getListData = (params, channel) => {
totalCount
:
result
[
2
].
data
.
total
,
footPager
:
searchHandler
.
handlePagerData
(
result
[
2
].
data
.
total
,
params
),
goods
:
productProcess
.
processProductList
(
result
[
2
].
data
.
product_list
,
Object
.
assign
({
showDiscount
:
false
},
params
)),
Object
.
assign
({
showDiscount
:
false
},
params
,
{
from
:
{
type
:
'list'
,
params
:
params
}
})),
hasNextPage
:
searchHandler
.
handleNextPage
(
params
,
result
[
2
].
data
.
total
),
// 最近浏览记录
...
...
@@ -194,7 +196,8 @@ const getListNewData = (params, channel) => {
totalCount
:
result
[
2
].
data
.
total
,
footPager
:
searchHandler
.
handlePagerData
(
result
[
2
].
data
.
total
,
params
),
goods
:
productProcess
.
processProductList
(
result
[
2
].
data
.
product_list
,
Object
.
assign
({
showDiscount
:
false
,
showNew
:
false
},
params
)),
Object
.
assign
({
showDiscount
:
false
,
showNew
:
false
,
from
:
{
type
:
'listNew'
,
params
:
params
}},
params
)),
hasNextPage
:
searchHandler
.
handleNextPage
(
params
,
result
[
2
].
data
.
total
),
// 最近浏览记录
...
...
@@ -265,7 +268,7 @@ const getBrandData = (params, extra, channel) => {
let
apiMethod
=
[
headerModel
.
requestHeaderData
(
channel
),
searchApi
.
getSortList
(
queryBase
),
searchApi
.
getProductList
(
Object
.
assign
(
{
order
:
order
},
searchParams
,
queryBase
))
searchApi
.
getProductList
(
Object
.
assign
(
searchParams
,
{
order
:
order
}
,
queryBase
))
];
...
...
@@ -304,16 +307,16 @@ const getBrandData = (params, extra, channel) => {
totalCount
:
result
[
2
].
data
.
total
,
footPager
:
searchHandler
.
handlePagerData
(
result
[
2
].
data
.
total
,
params
),
goods
:
productProcess
.
processProductList
(
result
[
2
].
data
.
product_list
,
Object
.
assign
({
showDiscount
:
false
},
params
)),
Object
.
assign
({
showDiscount
:
false
,
from
:
{
type
:
'brand'
,
params
:
params
}
},
params
)),
hasNextPage
:
searchHandler
.
handleNextPage
(
params
,
result
[
2
].
data
.
total
),
// 最近浏览记录
latestWalk
:
7
});
}
// 品牌页不显示品牌筛选项
delete
finalResult
.
brand
.
filters
.
brand
;
// 品牌页不显示品牌筛选项
_
.
unset
(
finalResult
,
'brand.filters.brand'
);
}
finalResult
.
criteo
=
{
skn
:
searchHandler
.
getCriteo
(
_
.
get
(
finalResult
.
brand
,
'goods'
))};
...
...
@@ -417,7 +420,7 @@ const getShopAbout = (shopId, uid, channel) => {
if
(
result
[
1
].
code
===
200
)
{
let
data
=
result
[
1
].
data
||
{},
decorator
=
shopHandler
.
getShopDecorator
(
data
,
{},
shopId
);
decorator
=
shopHandler
.
getShopDecorator
(
data
,
{},
shopId
,
true
);
Object
.
assign
(
decorator
.
shopTopBannerBase
,
{
shopId
:
shopId
,
...
...
@@ -639,7 +642,8 @@ const getShopData = (shopId, channel, params, shopInfo) => {
finalResult
.
leftContent
=
searchHandler
.
handleSortData
(
groupSort
,
params
);
if
(
finalResult
.
allGoods
)
{
Object
.
assign
(
finalResult
.
allGoods
,
searchHandler
.
setShopSort
(
groupSort
,
params
));
Object
.
assign
(
finalResult
.
allGoods
,
searchHandler
.
setShopSort
(
groupSort
,
Object
.
assign
({},
params
,
{
page
:
1
})));
}
}
...
...
@@ -654,7 +658,7 @@ const getShopData = (shopId, channel, params, shopInfo) => {
for
(
let
i
=
0
;
i
<
3
;
i
++
)
{
trendList
.
push
({
href
:
articleList
[
i
].
url
,
href
:
helpers
.
urlFormat
(
`
/
$
{
articleList
[
i
].
id
}.
html
`
,
''
,
'guang'
)
,
src
:
helpers
.
getForceSourceUrl
(
articleList
[
i
].
src
)
+
'?imageView/1/w/{width}/h/{height}'
,
mainTitle
:
articleList
[
i
].
title
,
...
...
@@ -714,7 +718,8 @@ const getShopGoodsData = (shopId, channel, params) => {
if
(
subRes
.
code
===
200
)
{
let
groupSort
=
_
.
get
(
subRes
,
'data.sort'
,
[]);
Object
.
assign
(
resData
,
searchHandler
.
setShopSort
(
groupSort
,
params
));
Object
.
assign
(
resData
,
searchHandler
.
setShopSort
(
groupSort
,
Object
.
assign
(
params
,
{
page
:
1
})));
}
return
resData
;
...
...
@@ -799,6 +804,9 @@ const getShopListData = (channel, params, uid) => {
}),
footPager
:
{
tip
:
tip
}
});
_
.
set
(
finalResult
,
'filters.checkedConditions.clearUrl'
,
`
?
navBar
=
$
{
params
.
navBar
}
&
shopId
=
$
{
params
.
shopId
}
`
);
}
else
{
finalResult
.
searchEmpty
=
true
;
...
...
@@ -894,6 +902,11 @@ const getBaseShopData = (params, extra, channel, shopId) => {
Object
.
assign
(
resData
,
shopHandler
.
setShopSeo
(
shopName
));
}
// 临时删除seo信息
_
.
unset
(
resData
,
'title'
);
_
.
unset
(
resData
,
'keywords'
);
_
.
unset
(
resData
,
'description'
);
return
resData
;
});
};
...
...
apps/product/models/sale-api.js
View file @
7c00abe
...
...
@@ -63,14 +63,14 @@ exports.getSalebreakingYardsSortList = (params) => {
* @return {[type]} [description]
*/
exports
.
getSaleActivityList
=
(
params
,
channel
)
=>
{
let
tempChannel
=
_
.
isEmpty
(
channel
)
?
'boys'
:
channel
;
let
tempChannel
=
yhChannel
[
channel
]
||
yhChannel
.
boys
;
return
api
.
get
(
''
,
{
id
:
params
.
id
||
null
,
method
:
'app.activity.get'
,
sort
:
'2'
,
plateform
:
'1'
,
yh_channel
:
yhChannel
[
tempChannel
]
.
channel
yh_channel
:
tempChannel
.
channel
});
};
...
...
apps/product/models/sale.js
View file @
7c00abe
...
...
@@ -529,7 +529,7 @@ exports.getSaleSpecialData = (id, params, channel) => {
limit
:
limit
,
attribute_not
:
2
});
let
banner
=
JSON
.
parse
(
data
.
banner_img
)
||
[];
let
banner
=
data
.
banner_img
?
JSON
.
parse
(
data
.
banner_img
)
:
[];
Object
.
assign
(
resData
,
{
mainBanner
:
{
...
...
@@ -581,7 +581,8 @@ exports.getSaleSpecialData = (id, params, channel) => {
Object
.
assign
(
resData
,
{
filters
:
searchHandler
.
handleFilterDataAll
(
_
.
get
(
result
[
2
],
'data'
,
{}),
params
),
opts
:
searchHandler
.
handleOptsData
(
params
,
tip
.
total
),
goods
:
productProcess
.
processProductList
(
_
.
get
(
result
[
2
],
'data.product_list'
,
[])),
goods
:
productProcess
.
processProductList
(
_
.
get
(
result
[
2
],
'data.product_list'
,
[]),
{
from
:
{
type
:
'saleSpecial'
,
params
:
params
}}),
footPager
:
{
tip
:
tip
}
});
...
...
apps/product/models/search-handler.js
View file @
7c00abe
...
...
@@ -311,7 +311,7 @@ exports.handleOptsData = (params, total, extra) => {
switch
(
i
)
{
case
0
:
opt
.
href
=
handleFilterUrl
(
params
,
{
order
:
''
},
{
page
:
true
});
opt
.
href
=
handleFilterUrl
(
params
,
{
},
{
page
:
true
,
order
:
true
});
if
(
extra
===
'discont'
)
{
// 如果是折扣专场
opt
.
name
=
'全部'
;
if
(
_
.
isEmpty
(
params
.
order
)
||
params
.
order
===
's_t_desc'
)
{
...
...
@@ -582,6 +582,9 @@ exports.handleFilterData = (origin, params, total) => {
if
(
params
.
price
===
key
)
{
priceRangechecked
=
true
;
}
if
(
_
.
isString
(
value
))
{
value
=
_
.
replace
(
value
,
'¥'
,
'¥'
);
}
let
price
=
{
checked
:
params
.
price
===
key
,
href
:
handleFilterUrl
(
params
,
{
price
:
key
}),
...
...
apps/product/models/search.js
View file @
7c00abe
...
...
@@ -68,7 +68,7 @@ exports.getSearchData = (params, channel) => {
totalCount
:
result
[
2
].
data
.
total
,
footPager
:
searchHandler
.
handlePagerData
(
result
[
2
].
data
.
total
,
params
),
goods
:
productProcess
.
processProductList
(
result
[
2
].
data
.
product_list
,
Object
.
assign
({
showDiscount
:
false
},
params
)),
Object
.
assign
({
showDiscount
:
false
,
from
:
{
type
:
'search'
,
params
:
params
}
},
params
)),
latestWalk
:
6
,
hasNextPage
:
searchHandler
.
handleNextPage
(
params
,
result
[
2
].
data
.
total
),
shopEntry
:
result
[
3
]
...
...
apps/product/views/action/product/detail.hbs
View file @
7c00abe
...
...
@@ -42,7 +42,7 @@
<span
class=
"good-tag new-festival-tag"
>
新品节
</span>
{{/
isNewFestival
}}
{{#
isLimit
}}
<span
class=
"good-tag limit-tag"
>
限量
商品
</span>
<span
class=
"good-tag limit-tag"
>
限量
</span>
{{/
isLimit
}}
{{#
isYearEndPromotion
}}
<span
class=
"good-tag yep-tag"
>
年终大促
</span>
...
...
apps/product/views/partial/product/detail-header.hbs
View file @
7c00abe
...
...
@@ -16,7 +16,7 @@
<span
class=
"good-tag new-festival-tag"
>
新品节
</span>
{{/
isNewFestival
}}
{{#
isLimit
}}
<span
class=
"good-tag limit-tag"
>
限量
商品
</span>
<span
class=
"good-tag limit-tag"
>
限量
</span>
{{/
isLimit
}}
{{#
isYearEndPromotion
}}
<span
class=
"good-tag yep-tag"
>
年终大促
</span>
...
...
@@ -319,4 +319,4 @@
</div>
</div>
</div>
{{/
goodsInfo
}}
\ No newline at end of file
{{/
goodsInfo
}}
...
...
doraemon/views/partial/product/good.hbs
View file @
7c00abe
...
...
@@ -17,7 +17,7 @@
<span
class=
"good-tag new-festival-tag"
>
新品节
</span>
{{/
is_new_festival
}}
{{#
is_limit
}}
<span
class=
"good-tag limit-tag"
>
限量
商品
</span>
<span
class=
"good-tag limit-tag"
>
限量
</span>
{{/
is_limit
}}
{{#
is_year_end_promotion
}}
<span
class=
"good-tag yep-tag"
>
年终大促
</span>
...
...
@@ -78,7 +78,7 @@
</p>
<div
class=
"hideList hide"
>
{{#
goods_list
}}
<li
data-src=
"
{{
image
images_url
280
3
74
}}
"
data-url=
"
{{
..
/
url
}}
"
data-status=
"
{{
status
}}
"
></li>
<li
data-src=
"
{{
image
images_url
280
3
82
}}
"
data-url=
"
{{
..
/
url
}}
"
data-status=
"
{{
status
}}
"
></li>
{{/
goods_list
}}
</div>
</div>
...
...
public/scss/product/_filter-box.css
View file @
7c00abe
...
...
@@ -300,6 +300,7 @@
.ud-price-range
{
margin-top
:
2px
;
display
:
inline-block
;
}
.limit
{
...
...
utils/product-process.js
View file @
7c00abe
...
...
@@ -7,6 +7,15 @@ const helpers = global.yoho.helpers;
// const images = require(`${global.utils}/images`);
const
itemFromBase
=
{
search
:
{
domain
:
'search'
,
module
:
's'
},
// 搜索页search.yohobuy.com
list
:
{
domain
:
'list'
,
module
:
'c'
},
// list.yohobuy.com
listSale
:
{
domain
:
'list'
,
module
:
's'
},
// list.yohobuy.com/sale
listNew
:
{
domain
:
'list'
,
module
:
'n'
},
// list.yohobuy.com/new
brand
:
{
domain
:
'brand'
,
module
:
'b'
},
// xxx.yohobuy.com[品牌域名]
saleSpecial
:
{
domain
:
'sale'
,
module
:
's'
}
// sale.yohobuy.com
};
// NOTE: 这里修改了图片质量的参数
helpers
.
image
=
_
.
flow
(
helpers
.
image
,
fp
.
replace
(
/
\/
quality
\/\d
*$/
,
'/quality/90'
));
...
...
@@ -105,6 +114,8 @@ const procProductImgs = (item, gender) => {
*/
exports
.
processProductList
=
(
list
,
options
)
=>
{
const
pruductList
=
[];
let
itemNum
=
0
,
itemFrom
;
options
=
Object
.
assign
({
showTags
:
true
,
...
...
@@ -118,11 +129,30 @@ exports.processProductList = (list, options) => {
height
:
388
,
isApp
:
false
,
showPoint
:
true
,
gender
:
'2,3'
gender
:
'2,3'
,
from
:
{}
// 来源
},
options
);
_
.
forEach
(
list
,
(
product
)
=>
{
// 处理item from
if
(
!
_
.
isEmpty
(
options
.
from
)
&&
itemFromBase
[
options
.
from
.
type
])
{
let
f
=
{
domain
:
''
,
module
:
''
,
key
:
''
};
let
params
=
options
.
from
.
params
||
{};
f
.
page
=
params
.
page
||
1
;
Object
.
assign
(
f
,
itemFromBase
[
options
.
from
.
type
],
{
page
:
params
.
page
||
1
,
key
:
params
.
misort
||
params
.
msort
||
''
});
if
(
options
.
from
.
type
===
'search'
)
{
f
.
key
=
params
.
query
||
''
;
}
itemFrom
=
`
from
=
$
{
f
.
domain
}
-
$
{
f
.
module
}
-
$
{
f
.
key
}
_$
{
f
.
page
}
_
`
;
}
_
.
forEach
(
list
,
(
product
)
=>
{
// 商品信息有问题,则不显示
if
(
!
product
||
!
product
.
product_skn
||
!
product
.
goods_list
.
length
)
{
...
...
@@ -166,7 +196,7 @@ exports.processProductList = (list, options) => {
});
product
.
is_few
=
product
.
is_soon_sold_out
===
'Y'
;
product
.
url
=
helpers
.
urlFormat
(
`
/
product
/
pro_$
{
product
.
product_id
}
_$
{
product
.
goods_list
[
0
].
goods_id
}
/${product.cn_alphabet}.html`
)
; // eslint-disable-lin
e
product
.
url
=
helpers
.
urlFormat
(
`
/
product
/
pro_$
{
product
.
product_id
}
_$
{
product
.
goods_list
[
0
].
goods_id
}
/${product.cn_alphabet}.html`
, '', 'item'
)
; // eslint-disable-lin
e
// tar add 1606071146 品牌链接处理
product
.
brandUrl
=
helpers
.
urlFormat
(
''
,
''
,
product
.
brand_domain
);
...
...
@@ -175,6 +205,10 @@ exports.processProductList = (list, options) => {
// 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护
if
(
options
.
isApp
)
{
product
.
url
+=
`
?
openby
:
yohobuy
=
{
"action"
:
"go.productDetail"
,
"params"
:{
"product_skn"
:
'${product.product_id}'
}}
`
;
// eslint-disable-line
}
else
if
(
itemFrom
)
{
// 累加商品数量
itemNum
++
;
product
.
url
+=
`
?
$
{
itemFrom
}
$
{
itemNum
}
`
;
}
if
(
options
.
showTags
)
{
...
...
Please
register
or
login
to post a comment