Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohoblk-wap
·
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
郭成尧
9 years ago
Commit
a7fcfe18509e1ab8187debebe3492ccbd75de298
2 parents
cf14daed
a134de23
Merge branch 'feature/brand' into develop
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
38 deletions
apps/product/controllers/shop.js
apps/product/models/shop-api.js
apps/product/models/shop.js
config/common.js
public/vue/product/shop/shop-box.vue
apps/product/controllers/shop.js
View file @
a7fcfe1
...
...
@@ -31,20 +31,23 @@ module.exports = {
/* 获取商品列表 */
getBrandShopGoods
:
(
req
,
res
)
=>
{
let
filter
=
req
.
body
.
filter
||
{};
shopModel
.
getBrandShopGoodsData
({
domain
:
filter
.
domain
,
sort
:
req
.
body
.
sort
,
page
:
req
.
body
.
page
,
channel
:
req
.
body
.
filter
.
channel
||
'men'
,
gender
:
req
.
body
.
filter
.
gender
||
'1,2,3'
,
brand
:
req
.
body
.
filter
.
brand
,
shopId
:
req
.
body
.
filter
.
shopId
,
order
:
req
.
body
.
filter
.
order
||
's_t_desc'
,
limit
:
req
.
body
.
filter
.
limit
||
'60'
,
color
:
req
.
body
.
filter
.
color
,
price
:
req
.
body
.
filter
.
price
,
size
:
req
.
body
.
filter
.
size
,
pd
:
req
.
body
.
filter
.
pd
,
tagsFilter
:
req
.
body
.
filter
.
tagsFilter
channel
:
filter
.
channel
||
'men'
,
gender
:
filter
.
gender
||
'1,2,3'
,
brand
:
filter
.
brand
,
shopId
:
filter
.
shopId
,
order
:
filter
.
order
||
's_t_desc'
,
limit
:
filter
.
limit
||
'60'
,
color
:
filter
.
color
,
price
:
filter
.
price
,
size
:
filter
.
size
,
pd
:
filter
.
pd
,
tagsFilter
:
filter
.
tagsFilter
}).
then
(
result
=>
{
res
.
json
(
result
);
});
...
...
apps/product/models/shop-api.js
View file @
a7fcfe1
...
...
@@ -7,6 +7,8 @@
'use strict'
;
const
api
=
global
.
yoho
.
API
;
const
_
=
require
(
'lodash'
);
const
yhChannel
=
{
men
:
{
channel
:
'1'
...
...
@@ -67,7 +69,7 @@ module.exports = {
* @returns {*}
*/
getBrandShopGoodsOriginData
(
params
)
{
return
api
.
get
(
''
,
{
let
finalParams
=
{
method
:
'app.search.brand'
,
yh_channel
:
params
.
channel
?
yhChannel
[
params
.
channel
].
channel
:
'1'
,
brand
:
params
.
brand
,
...
...
@@ -82,7 +84,16 @@ module.exports = {
p_d
:
params
.
pd
,
sort
:
params
.
sort
,
tags_filter
:
params
.
tagsFilter
};
/* 删除没有参数的条件 */
_
.
forEach
(
finalParams
,
(
value
,
key
)
=>
{
if
(
!
value
)
{
delete
finalParams
[
key
];
}
});
return
api
.
get
(
''
,
finalParams
);
},
/**
...
...
apps/product/models/shop.js
View file @
a7fcfe1
...
...
@@ -8,8 +8,7 @@
const
logger
=
global
.
yoho
.
logger
;
const
api
=
global
.
yoho
.
API
;
const
shopApi
=
require
(
'./shop-api'
);
const
path
=
require
(
'path'
);
const
processProductList
=
require
(
path
.
join
(
global
.
utils
,
'/beautify/product'
)).
processProductList
;
const
processProductList
=
require
(
`
$
{
global
.
utils
}
/beautify/
product
`
);
const
camelCase
=
global
.
yoho
.
camelCase
;
const
_
=
require
(
'lodash'
);
...
...
@@ -109,15 +108,26 @@ const getShopData = params => {
const
getBrandShopGoodsData
=
params
=>
{
let
finalResult
=
{};
return
api
.
all
([
shopApi
.
getBrandShopGoodsOriginData
(
params
)]).
then
(
result
=>
{
return
api
.
all
([
shopApi
.
getBrandInfoByDomain
({
domain
:
params
.
domain
})
]).
then
(
result
=>
{
if
(
result
[
0
].
code
===
200
)
{
Object
.
assign
(
finalResult
,
{
data
:
{
productList
:
processProductList
(
result
[
0
].
data
.
productList
)
return
api
.
all
([
shopApi
.
getBrandShopGoodsOriginData
(
Object
.
assign
(
params
,
{
brand
:
result
[
0
].
data
.
id
,
shopId
:
result
[
0
].
data
.
shop_id
}))
]).
then
(
subResult
=>
{
if
(
subResult
[
0
].
code
===
200
)
{
finalResult
.
data
=
{
productList
:
processProductList
(
subResult
[
0
].
data
.
product_list
)
};
}
else
{
logger
.
error
(
'getBrandShopGoodsOriginData api code no 200'
);
}
return
camelCase
(
finalResult
);
});
}
else
{
logger
.
error
(
'getBrand
ShopGoodsOriginData
api code no 200'
);
logger
.
error
(
'getBrand
InfoByDomain
api code no 200'
);
}
return
camelCase
(
finalResult
);
...
...
config/common.js
View file @
a7fcfe1
...
...
@@ -15,7 +15,7 @@ module.exports = {
port
:
6004
,
siteUrl
:
'//m.yohoblk.com'
,
domains
:
{
api
:
'http://
devapi.yoho.cn:58078
/'
,
api
:
'http://
192.168.102.202:8080/gateway
/'
,
service
:
'http://devservice.yoho.cn:58077/'
},
subDomains
:
{
...
...
public/vue/product/shop/shop-box.vue
View file @
a7fcfe1
...
...
@@ -34,7 +34,9 @@
// query
url: '/product/get-brand-shop-goods',
sort: '',
filter: {},
filter: {
domain: qs.domain
},
page: 0, // page= 0 未搜索, 1 并且productList.length =0 没有数据, page = page_total 全部加载完
totalPage: 3,
...
...
@@ -46,9 +48,6 @@
};
},
watch: {
domain: function() {
this.getShopInfo();
},
/* sort 和 filter 改变 都会触发 重新搜索 (想象成清空所有分页) */
sort: function() {
...
...
@@ -81,18 +80,6 @@
tip('网络错误');
});
},
getProductList() {
let data = {};
$.ajax({
url: this.url,
data: data
}).done(result => {
this.productList = result.data.productList;
}).fail(() => {
tip('网络错误');
});
},
search: function() {
const self = this;
...
...
@@ -141,8 +128,7 @@
},
created() {
this.getShopInfo();
// this.search();
this.search();
bus.$on('list.paging', function() {
this.search();
});
...
...
Please
register
or
login
to post a comment