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
yyq
8 years ago
Commit
5a36538badba5ba1ef385f16195353863a0b883a
1 parent
181033e1
shop pjax
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
3 deletions
apps/product/controllers/list.js
apps/product/models/list.js
apps/product/views/action/list/goods-list.hbs
apps/product/controllers/list.js
View file @
5a36538
...
...
@@ -17,6 +17,16 @@ const shop = (shopId, req, res, next, brandInfo) => {
list
.
getShopInfo
(
shopId
,
req
.
user
.
id
).
then
(
shopInfo
=>
{
if
(
+
shopInfo
.
shopTemplateType
===
2
)
{
// 经典模板
let
pjax
=
req
.
query
.
_pjax
;
if
(
pjax
)
{
list
.
getShopGoodsData
(
shopId
,
req
.
yoho
.
channel
,
req
.
query
,
shopInfo
).
then
(
result
=>
{
Object
.
assign
(
result
,
{
layout
:
false
});
res
.
render
(
'list/goods-list'
,
result
);
}).
catch
(
next
);
return
;
}
list
.
getShopData
(
shopId
,
req
.
yoho
.
channel
,
req
.
query
,
shopInfo
).
then
(
result
=>
{
Object
.
assign
(
result
,
{
page
:
'shop'
,
...
...
@@ -27,9 +37,9 @@ const shop = (shopId, req, res, next, brandInfo) => {
}
else
{
// 基础模板
list
.
getBaseShopData
(
req
.
query
,
Object
.
assign
({
uid
:
req
.
user
.
uid
},
brandInfo
),
req
.
yoho
.
channel
,
shopId
).
then
(
result
=>
{
Object
.
assign
(
result
,
{
page
:
'list'
});
res
.
render
(
'list/brand'
,
result
);
}).
catch
(
next
);
Object
.
assign
(
result
,
{
page
:
'list'
});
res
.
render
(
'list/brand'
,
result
);
}).
catch
(
next
);
}
}).
catch
(
next
);
};
...
...
apps/product/models/list.js
View file @
5a36538
...
...
@@ -672,6 +672,54 @@ const getShopData = (shopId, channel, params, shopInfo) => {
});
};
/**
* 获取店铺商品数据
*/
const
getShopGoodsData
=
(
shopId
,
channel
,
params
)
=>
{
let
gender
=
_getGender
(
channel
);
let
resData
=
{};
_
.
unset
(
params
,
'_pjax'
);
return
Promise
.
all
([
searchApi
.
getProductList
(
Object
.
assign
({
shop_id
:
shopId
},
params
)),
// 搜索店铺商品
searchApi
.
getShopBrands
(
shopId
)
// 店铺品牌数据
]).
then
(
result
=>
{
// 获取商品数据和顶部筛选条件
if
(
result
[
0
].
code
===
200
)
{
Object
.
assign
(
resData
,
{
sort
:
searchHandler
.
handleOptsData
(
params
,
_
.
get
(
result
[
0
],
'data.total'
,
0
)),
list
:
productProcess
.
processProductList
(
_
.
get
(
result
[
0
],
'data.product_list'
,
[]),
{
newCoverSort
:
true
,
showDiscount
:
false
,
gender
:
gender
})
});
_
.
set
(
resData
,
'sort.newPage'
,
true
);
// 启用新的分页导航
}
let
shopBrandIds
=
[];
// 店铺的所有品牌id
if
(
result
[
1
].
code
===
200
&&
result
[
1
].
data
)
{
_
.
forEach
(
result
[
1
].
data
,
value
=>
{
shopBrandIds
.
push
(
value
.
brand_id
);
});
}
// 根据品牌获取分类 (腾讯云测试没有该接口,暂时不调用分类)
return
searchApi
.
getSortList
({
brand
:
shopBrandIds
}).
then
(
subRes
=>
{
if
(
subRes
.
code
===
200
)
{
let
groupSort
=
_
.
get
(
subRes
,
'data.sort'
,
[]);
Object
.
assign
(
resData
,
searchHandler
.
setShopSort
(
groupSort
,
params
));
}
return
resData
;
});
});
};
const
getShopListData
=
(
channel
,
params
,
uid
)
=>
{
let
gender
=
_getGender
(
channel
),
shopId
=
params
.
shopId
,
...
...
@@ -848,6 +896,7 @@ module.exports = {
getAdnav
,
getShopInfo
,
getShopData
,
getShopGoodsData
,
getShopListData
,
getBaseShopData
};
...
...
apps/product/views/action/list/goods-list.hbs
0 → 100644
View file @
5a36538
{{>
list
/
shop-list
}}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment