Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-blk
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
1
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
姜枫
9 years ago
Commit
5d53bc3720250201729100088f698f9bd950065e
1 parent
58d1ebff
fix bug
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
79 additions
and
35 deletions
apps/product/controllers/list.js
apps/product/controllers/query.js
apps/product/controllers/shop.js
apps/product/models/helpers.js
apps/product/models/search.js
apps/product/views/action/shop-list.hbs
apps/product/views/partial/list/filter.hbs
config/common.js
public/js/product/list/list-search.js
public/scss/product/_list.css
public/scss/product/_shop.css
apps/product/controllers/list.js
View file @
5d53bc3
...
...
@@ -27,13 +27,16 @@ const list = {
title
:
'列表'
};
Search
.
queryProduct
(
q
).
then
(
result
=>
{
Promise
.
all
([
Search
.
queryAllSort
(),
Search
.
queryProduct
(
q
)]).
then
(
allResult
=>
{
let
allSort
=
camelCase
(
allResult
[
0
]);
let
result
=
allResult
[
1
];
if
(
result
&&
result
.
code
===
200
&&
result
.
data
)
{
let
data
=
camelCase
(
result
.
data
);
let
nav
=
[
DataHelper
.
getChannelNav
()];
if
(
data
.
filter
)
{
data
.
filter
.
groupSort
=
DataHelper
.
sortConvert
(
allSort
.
data
.
sort
);
retData
.
filter
=
DataHelper
.
filterHandle
(
data
.
filter
,
q
);
retData
.
filter
.
showPrice
=
data
.
total
>
10
;
nav
=
_
.
concat
(
nav
,
retData
.
filter
.
nav
);
...
...
@@ -74,9 +77,10 @@ const list = {
title
:
'列表'
};
Promise
.
all
([
Resouces
.
newProductBanner
(),
Search
.
queryNewProduct
(
q
)]).
then
(
result
=>
{
Promise
.
all
([
Resouces
.
newProductBanner
(),
Search
.
query
AllSort
(),
Search
.
query
NewProduct
(
q
)]).
then
(
result
=>
{
let
banner
=
result
[
0
];
let
listData
=
result
[
1
];
let
sortData
=
camelCase
(
result
[
1
]);
let
listData
=
result
[
2
];
let
nav
=
[
DataHelper
.
getChannelNav
(),
{
name
:
'新品'
}];
...
...
@@ -87,6 +91,7 @@ const list = {
let
data
=
camelCase
(
listData
.
data
);
if
(
data
.
filter
)
{
data
.
filter
.
groupSort
=
DataHelper
.
sortConvert
(
sortData
.
data
.
sort
);
retData
.
filter
=
DataHelper
.
filterHandle
(
data
.
filter
,
q
);
retData
.
filter
.
showPrice
=
data
.
total
>
10
;
}
...
...
apps/product/controllers/query.js
View file @
5d53bc3
...
...
@@ -28,7 +28,9 @@ const Query = {
query
:
query
};
Search
.
queryProduct
(
q
).
then
(
result
=>
{
Promise
.
all
([
Search
.
queryAllSort
(),
Search
.
queryProduct
(
q
)]).
then
(
allResult
=>
{
let
allSort
=
camelCase
(
allResult
[
0
]);
let
result
=
allResult
[
1
];
if
(
result
&&
result
.
code
===
200
&&
result
.
data
)
{
let
data
=
camelCase
(
result
.
data
);
...
...
@@ -39,6 +41,7 @@ const Query = {
});
if
(
data
.
filter
)
{
data
.
filter
.
groupSort
=
DataHelper
.
sortConvert
(
allSort
.
data
.
sort
);
retData
.
filter
=
DataHelper
.
filterHandle
(
data
.
filter
,
q
);
retData
.
filter
.
showPrice
=
data
.
total
>
10
;
}
...
...
apps/product/controllers/shop.js
View file @
5d53bc3
...
...
@@ -111,15 +111,23 @@ const shop = {
});
}
else
{
res
.
status
(
404
);
return
Promise
.
reject
(
'brand
not
found'
);
return
Promise
.
reject
(
'brand
-not-
found'
);
}
}).
then
(()
=>
{
return
Search
.
queryProductOfBrand
(
q
).
then
(
result
=>
{
return
Promise
.
all
([
Search
.
queryAllSort
({
brand
:
q
.
brand
,
shop
:
q
.
shop_id
,
small_sort
:
1
}),
Search
.
queryProductOfBrand
(
q
)]).
then
(
allResult
=>
{
let
allSort
=
camelCase
(
allResult
[
0
]);
let
result
=
allResult
[
1
];
if
(
result
&&
result
.
code
===
200
&&
result
.
data
)
{
let
ret
=
camelCase
(
result
.
data
);
if
(
ret
.
filter
)
{
delete
q
.
brand
;
ret
.
filter
.
groupSort
=
DataHelper
.
sortConvert
(
allSort
.
data
.
sort
);
data
.
filter
=
DataHelper
.
filterHandle
(
ret
.
filter
,
req
.
query
);
data
.
filter
.
showPrice
=
ret
.
total
>
10
;
}
...
...
apps/product/models/helpers.js
View file @
5d53bc3
...
...
@@ -96,27 +96,28 @@ const helpers = {
* @param sorts
* @returns {Array}
*/
getSortNav
(
sort
,
sorts
)
{
getSortNav
(
msort
,
mi
sort
,
sorts
)
{
let
nav
=
[];
let
sortQuery
=
'?'
;
if
(
sort
&&
sorts
)
{
if
(
m
sort
&&
sorts
)
{
sorts
.
forEach
(
s
=>
{
if
(
s
.
relationParameter
.
sort
===
sort
)
{
if
(
s
.
categoryId
===
msort
)
{
sortQuery
+=
'msort='
+
msort
;
s
.
checked
=
true
;
nav
.
push
({
link
:
'#'
,
link
:
sortQuery
,
pathTitle
:
''
,
name
:
s
.
categoryName
});
}
else
if
(
s
.
sub
)
{
}
if
(
s
.
sub
&&
misort
)
{
s
.
sub
.
forEach
(
m
=>
{
if
(
m
.
relationParameter
.
sort
===
sort
)
{
nav
.
push
({
link
:
'#'
,
pathTitle
:
''
,
name
:
s
.
categoryName
});
if
(
m
.
categoryId
===
misort
)
{
sortQuery
+=
'&misort='
+
misort
;
m
.
checked
=
true
;
nav
.
push
({
link
:
'#'
,
link
:
sortQuery
,
pathTitle
:
''
,
name
:
m
.
categoryName
});
...
...
@@ -143,6 +144,16 @@ const helpers = {
};
},
sortConvert
(
sorts
)
{
return
_
.
map
(
sorts
,
s
=>
{
return
{
categoryId
:
s
.
sortId
,
categoryName
:
s
.
sortName
,
sub
:
helpers
.
sortConvert
(
s
.
sub
)
};
});
},
/**
* 筛选器数据处理
* @param filter
...
...
@@ -160,6 +171,7 @@ const helpers = {
let
filters
=
[];
let
customPriceLow
=
''
;
let
customPriceHigh
=
''
;
let
showSize
=
(
!!
q
.
sort
||
!!
q
.
misort
);
genders
.
forEach
(
g
=>
{
if
(
g
.
value
===
q
.
gender
)
{
...
...
@@ -222,6 +234,7 @@ const helpers = {
}
if
(
q
.
size
)
{
showSize
=
false
;
sizeInfo
.
forEach
(
s
=>
{
if
(
s
.
sizeId
===
parseInt
(
q
.
size
,
10
))
{
s
.
checked
=
true
;
...
...
@@ -270,9 +283,9 @@ const helpers = {
letters
:
this
.
brandLetters
(),
customPriceLow
:
customPriceLow
,
customPriceHigh
:
customPriceHigh
,
showSize
:
!!
q
.
sort
,
showSize
:
showSize
,
showPrice
:
true
,
nav
:
this
.
getSortNav
(
q
.
sort
,
sorts
)
nav
:
this
.
getSortNav
(
q
.
msort
,
q
.
mi
sort
,
sorts
)
};
},
...
...
apps/product/models/search.js
View file @
5d53bc3
...
...
@@ -47,7 +47,7 @@ const Search = {
},
queryProductOfBrand
(
params
)
{
let
finalParams
=
{
method
:
'app.search.
brand
'
,
method
:
'app.search.
li
'
,
limit
:
45
,
app_type
:
1
};
...
...
@@ -67,11 +67,11 @@ const Search = {
return
api
.
get
(
''
,
finalParams
);
},
queryAllSort
()
{
return
api
.
get
(
''
,
{
method
:
'app.sort.get'
,
queryAllSort
(
params
)
{
return
api
.
get
(
''
,
_
.
assign
({
method
:
'web.regular.groupsort'
,
app_type
:
1
});
}
,
params
),
{
code
:
200
}
);
}
};
...
...
apps/product/views/action/shop-list.hbs
View file @
5d53bc3
...
...
@@ -10,7 +10,7 @@
{{>
list
/
banner-info
}}
</div>
<div
class=
"center-content clearfix"
>
<div
class=
"
yoho-product-list-content
center-content clearfix"
>
<div
class=
"left"
>
{{!-- 筛选区域 --}}
{{#
filter
}}
...
...
apps/product/views/partial/list/filter.hbs
View file @
5d53bc3
...
...
@@ -34,7 +34,7 @@
<div
class=
"title"
>
全部品类
</div>
<div
class=
"yoho-ui-accordion no-active"
>
{{#
each
sortData
}}
<h3>
{{
categoryName
}}
</h3>
<h3
{{#if
checked
}}
class=
"active"
{{/if}}
>
{{
categoryName
}}
</h3>
<div
class=
"body"
data-value=
"
{{
categoryId
}}
"
>
<div
class=
"list-body nano"
>
<div
class=
"nano-content"
>
...
...
config/common.js
View file @
5d53bc3
...
...
@@ -19,8 +19,10 @@ module.exports = {
},
cookieDomain
:
'yohobuy.com'
,
domains
:
{
api
:
'http://testapi.yoho.cn:28078/'
,
// devapi.yoho.cn:58078 testapi.yoho.cn:28078 devapi.yoho.cn:58078
service
:
'http://testservice.yoho.cn:28077/'
,
// testservice.yoho.cn:28077 devservice.yoho.cn:58077
api
:
'http://devapi.yoho.cn:58078/'
,
// devapi.yoho.cn:58078 testapi.yoho.cn:28078 devapi.yoho.cn:58078
service
:
'http://devservice.yoho.cn:58077/'
,
// testservice.yoho.cn:28077 devservice.yoho.cn:58077
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
search
:
'http://192.168.102.216:8080/yohosearch/'
},
useOneapm
:
false
,
...
...
public/js/product/list/list-search.js
View file @
5d53bc3
...
...
@@ -23,12 +23,18 @@ var YohoListPage = {
$
(
'.yoho-ui-accordion'
,
this
.
rootDoc
).
each
(
function
()
{
var
opts
=
{
collapsible
:
true
,
heightStyle
:
'content'
heightStyle
:
'content'
,
active
:
0
};
if
(
$
(
this
).
hasClass
(
'no-active'
))
{
opts
.
active
=
false
;
}
$
(
this
).
find
(
'h3'
).
each
(
function
(
index
)
{
if
(
$
(
this
).
hasClass
(
'active'
))
{
opts
.
active
=
index
;
}
});
$
(
this
).
accordion
(
opts
);
});
...
...
@@ -45,14 +51,13 @@ var YohoListPage = {
$
(
'.list-body .input-radio'
,
this
.
rootDoc
).
check
({
type
:
'radio'
,
group
:
'sort'
,
onChange
:
function
(
ele
,
checked
,
value
)
{
onChange
:
function
(
ele
)
{
var
subCategoryId
=
$
(
ele
).
data
(
'category'
);
var
categoryId
=
$
(
ele
).
parents
(
'.body'
).
data
(
'value'
);
YohoListPage
.
go
({
categoryId
:
categoryId
,
subCategoryId
:
subCategoryId
,
sort
:
checked
?
value
:
''
msort
:
categoryId
,
misort
:
subCategoryId
});
}
});
...
...
public/scss/product/_list.css
View file @
5d53bc3
...
...
@@ -340,6 +340,11 @@
text-align
:
center
;
margin
:
20px
0
40px
;
li
{
width
:
auto
;
margin
:
0
4px
;
}
li
:first-child
,
li
:last-child
{
border-width
:
2px
;
...
...
public/scss/product/_shop.css
View file @
5d53bc3
.yoho-product-list
,
.yoho-shop-index
{
.yoho-product-list-content
{
margin-top
:
30px
;
}
.brand-banner
{
width
:
100%
;
height
:
150px
;
...
...
@@ -37,7 +41,6 @@
.shop-menu
{
border-bottom
:
1px
solid
#eee
;
margin-bottom
:
30px
;
li
{
display
:
inline-block
;
...
...
Please
register
or
login
to post a comment