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
59bec87e2366d01d0f46f161d0a5e3baa5808253
1 parent
81dd34f8
调试数据
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
152 additions
and
56 deletions
apps/product/controllers/list.js
apps/product/models/list.js
apps/product/views/partial/list/filter-area.hbs
apps/product/views/partial/list/filter.hbs
config/common.js
public/js/product/list.page.js
public/scss/product/_list.css
apps/product/controllers/list.js
View file @
59bec87
'use strict'
;
const
_
=
require
(
'lodash'
);
const
Search
=
require
(
'../models/list'
);
const
camelCase
=
global
.
yoho
.
camelCase
;
...
...
@@ -22,53 +23,112 @@ function brandLetters() {
return
letters
;
}
function
peopleChoose
(
channel
)
{
function
peopleChoose
(
gender
)
{
return
[
{
name
:
'男士'
,
value
:
'0'
,
checked
:
channel
===
'men'
value
:
'1,3'
},
{
name
:
'女士'
,
value
:
'1'
,
checked
:
channel
===
'women'
value
:
'2,3'
}];
}
function
newFilter
(
key
,
value
,
name
)
{
return
{
key
:
key
,
value
:
value
,
name
:
name
};
}
const
list
=
{
index
:
(
req
,
res
,
next
)
=>
{
let
channel
=
req
.
query
.
channel
||
req
.
cookies
.
_Channel
;
let
sex
=
req
.
query
.
sex
;
let
page
=
req
.
query
.
page
||
1
;
let
brand
=
req
.
query
.
brand
||
0
;
let
sort
=
req
.
query
.
sort
||
''
;
let
gender
=
req
.
query
.
gender
||
''
;
let
price
=
req
.
query
.
price
||
''
;
let
size
=
req
.
query
.
size
||
''
;
if
(
sex
===
'0'
)
{
channel
=
'men'
;
}
else
if
(
sex
===
'1'
)
{
channel
=
'women'
;
}
Search
.
queryProduct
({
page
:
page
,
brand
:
brand
,
sort
:
sort
,
gender
:
gender
,
size
:
size
,
price
:
price
}).
then
(
result
=>
{
Search
.
queryProduct
({}).
then
(
result
=>
{
if
(
result
&&
result
.
code
===
200
&&
result
.
data
)
{
let
data
=
camelCase
(
result
.
data
);
let
priceRange
=
data
.
filter
.
priceRange
;
let
ret
=
{};
if
(
data
.
filter
)
{
let
priceRange
=
data
.
filter
.
priceRange
;
let
sizeInfo
=
data
.
filter
.
size
;
let
genders
=
peopleChoose
(
gender
);
let
brands
=
data
.
filter
.
brand
;
let
colors
=
data
.
filter
.
color
;
let
sorts
=
data
.
filter
.
groupSort
;
let
filters
=
[];
genders
.
forEach
(
g
=>
{
if
(
g
.
value
===
gender
)
{
filters
.
push
(
newFilter
(
'gender'
,
gender
,
g
.
name
));
}
});
priceRange
=
Object
.
keys
(
priceRange
).
map
((
k
)
=>
{
let
prices
=
k
.
split
(
','
);
if
(
k
===
price
)
{
filters
.
push
(
newFilter
(
'price'
,
price
,
`¥
$
{
prices
[
0
]}
-¥
$
{
prices
[
1
]}
`
));
}
return
{
lower
:
prices
[
0
],
higher
:
prices
[
1
]
};
}).
sort
((
a
,
b
)
=>
{
return
a
.
lower
-
b
.
lower
;
});
priceRange
=
Object
.
keys
(
priceRange
).
map
((
k
)
=>
{
let
prices
=
k
.
split
(
','
);
if
(
!
_
.
isArray
(
sizeInfo
))
{
sizeInfo
.
checked
=
true
;
sizeInfo
=
[
sizeInfo
];
}
return
{
lower
:
prices
[
0
],
higher
:
prices
[
1
]
if
(
size
)
{
sizeInfo
.
forEach
(
s
=>
{
if
(
s
.
sizeId
===
size
)
{
filters
.
push
(
newFilter
(
'size'
,
size
,
s
.
sizeName
));
}
});
}
if
(
brand
)
{
let
brandNames
=
brands
.
filter
(
b
=>
{
return
(
','
+
brand
+
','
).
index
(
','
+
b
.
id
+
','
)
>=
0
;
}).
map
(
b
=>
{
return
b
.
brandName
;
}).
join
(
'、'
);
filters
.
push
(
'brand'
,
brand
,
brandNames
);
}
ret
=
{
people
:
genders
,
sortData
:
sorts
,
brandData
:
brands
,
colors
:
colors
,
size
:
sizeInfo
,
priceRange
:
priceRange
,
filters
:
filters
};
}).
sort
((
a
,
b
)
=>
{
return
a
.
lower
-
b
.
lower
;
});
res
.
display
(
'list'
,
{
}
res
.
display
(
'list'
,
_
.
assign
(
ret
,
{
letters
:
brandLetters
(),
people
:
peopleChoose
(
channel
),
sortData
:
data
.
filter
.
groupSort
,
brandData
:
data
.
filter
.
brand
,
colors
:
data
.
filter
.
color
,
size
:
data
.
filter
.
size
,
priceRange
:
priceRange
,
total
:
data
.
total
,
pageTotal
:
data
.
pageTotal
,
pageNo
:
data
.
page
,
...
...
@@ -99,7 +159,7 @@ const list = {
module
:
'product'
,
page
:
'list'
,
title
:
'列表'
});
})
)
;
}
else
{
throw
'query product error'
;
}
...
...
apps/product/models/list.js
View file @
59bec87
...
...
@@ -7,6 +7,15 @@ const logger = global.yoho.logger;
const
camelCase
=
global
.
yoho
.
camelCase
;
const
_
=
require
(
'lodash'
);
function
clearEmptyVal
(
obj
)
{
_
.
keys
(
obj
).
forEach
(
k
=>
{
if
(
obj
[
k
]
===
null
||
obj
[
k
]
===
''
)
{
_
.
unset
(
obj
,
k
);
}
});
return
obj
;
}
const
Search
=
{
querySort
(
query
)
{
return
SearchAPI
.
get
(
'sortgroup.json'
,
_
.
assign
({
...
...
@@ -34,7 +43,7 @@ const Search = {
yh_channel
:
1
};
Object
.
assign
(
finalParams
,
params
);
Object
.
assign
(
finalParams
,
clearEmptyVal
(
params
)
);
return
api
.
get
(
''
,
finalParams
);
}
...
...
apps/product/views/partial/list/filter-area.hbs
View file @
59bec87
...
...
@@ -2,24 +2,24 @@
<label>
已选条件:
</label>
<div
class=
"filter-item"
>
<span
class=
"label"
>
男士
</span>
<span
class=
"iconfont cancel"
>
æ
08
;
</span>
<span
class=
"iconfont cancel"
>
æ
1d
;
</span>
</div>
<div
class=
"filter-item"
>
<span
class=
"label"
>
S'wdsft zBesd
</span>
<span
class=
"iconfont cancel"
>
æ
08
;
</span>
<span
class=
"iconfont cancel"
>
æ
1d
;
</span>
</div>
<div
class=
"filter-item"
>
<span
class=
"label"
>
¥2001-¥4001
</span>
<span
class=
"iconfont cancel"
>
æ
08
;
</span>
<span
class=
"iconfont cancel"
>
æ
1d
;
</span>
</div>
<div
class=
"filter-item"
>
<span
class=
"label"
>
XL
</span>
<span
class=
"iconfont cancel"
>
æ
08
;
</span>
<span
class=
"iconfont cancel"
>
æ
1d
;
</span>
</div>
<div
class=
"filter-item"
>
<span
class=
"iconfont c-red"
>

</span>
<span
class=
"label"
>
红色
</span>
<span
class=
"iconfont cancel"
>
æ
08
;
</span>
<span
class=
"iconfont cancel"
>
æ
1d
;
</span>
</div>
<label
class=
"cancel"
>
清空筛选条件
</label>
</div>
...
...
@@ -39,7 +39,7 @@
</label>
<label
class=
"page-info"
>
{{
pageNo
}}
/
{{
pageTotal
}}
</label>
<span
class=
"iconfont page disable page-pre"
>

</span>
<span
class=
"iconfont page page-next"
>
æ
06
;
</span>
<span
class=
"iconfont page page-next"
>
æ
1e
;
</span>
</div>
</div>
...
...
@@ -47,7 +47,7 @@
{{#
each
products
}}
<div
class=
"goods"
data-id=
"
{{
productId
}}
"
>
<div
class=
"goods-img"
>
<img
src=
"
{{
defaultImages
}}
"
width=
"265"
height=
"344"
alt=
""
>
<img
src=
"
{{
image
defaultImages
265
344
}}
"
width=
"265"
height=
"344"
alt=
""
>
</div>
<div
class=
"goods-brand"
>
{{
brandName
}}
...
...
@@ -63,7 +63,7 @@
</div>
<div
class=
"goods-list hide"
>
{{#
each
goodsList
}}
<i>
{{
image
sUrl
}}
</i>
<i>
{{
image
imagesUrl
265
344
}}
</i>
{{/
each
}}
</div>
</div>
...
...
apps/product/views/partial/list/filter.hbs
View file @
59bec87
...
...
@@ -16,10 +16,10 @@
<div
class=
"yoho-ui-accordion no-active"
>
{{#
each
sortData
}}
<h3>
{{
categoryName
}}
</h3>
<div
class=
"body"
data-
msort
=
"
{{
categoryId
}}
"
>
<div
class=
"body"
data-
value
=
"
{{
categoryId
}}
"
>
<div
class=
"list-body"
>
{{#
each
sub
}}
<div
class=
"input-radio"
data-
misort
=
"
{{
categoryId
}}
"
>
<div
class=
"input-radio"
data-
value
=
"
{{
categoryId
}}
"
>
{{>
icon
/
radio
}}
<label>
{{
categoryName
}}
</label>
</div>
...
...
@@ -63,7 +63,7 @@
<div
class=
"yoho-ui-accordion"
>
<h3>
价格
</h3>
<div
class=
"body"
>
<div
class=
"body
price-body
"
>
{{#
each
priceRange
}}
<div
class=
"input-radio"
data-value=
"
{{
lower
}}
,
{{
higher
}}
"
>
{{>
icon
/
radio
}}
...
...
config/common.js
View file @
59bec87
...
...
@@ -18,7 +18,7 @@ module.exports = {
default
:
'//www.yohoblk.com'
},
domains
:
{
api
:
'http://
devapi.yoho.cn:58078
/'
,
// devapi.yoho.cn:58078 testapi.yoho.cn:28078 devapi.yoho.cn:58078
api
:
'http://
api.yoho.yohoops.org
/'
,
// devapi.yoho.cn:58078 testapi.yoho.cn:28078 devapi.yoho.cn:58078
service
:
'http://devservice.yoho.cn:28077/'
,
// testservice.yoho.cn:28077 devservice.yoho.cn:58077
search
:
'http://192.168.102.216:8080/yohosearch/'
},
...
...
public/js/product/list.page.js
View file @
59bec87
var
$
=
require
(
'yoho-jquery'
);
var
common
=
require
(
'../common'
);
var
YohoListPage
=
{
rootDoc
:
$
(
'.yoho-product-list'
),
...
...
@@ -9,7 +10,6 @@ var YohoListPage = {
goodsWrapperState
:
false
,
init
:
function
()
{
require
(
'yoho-jquery-accordion'
);
require
(
'../common'
);
require
(
'../plugins/check'
);
$
(
'.yoho-ui-accordion'
,
this
.
rootDoc
).
each
(
function
()
{
var
opts
=
{
...
...
@@ -27,7 +27,34 @@ var YohoListPage = {
type
:
'radio'
,
onChange
:
function
(
ele
,
checked
,
value
)
{
YohoListPage
.
go
({
sex
:
checked
?
value
:
''
gender
:
checked
?
value
:
''
});
}
});
$
(
'.yoho-product-list .list-body .input-radio'
).
check
({
type
:
'radio'
,
onChange
:
function
(
ele
,
checked
,
value
)
{
YohoListPage
.
go
({
sort
:
checked
?
value
:
''
});
}
});
$
(
'.yoho-product-list .price-body .input-radio'
).
check
({
type
:
'radio'
,
onChange
:
function
(
ele
,
checked
,
value
)
{
YohoListPage
.
go
({
price
:
checked
?
value
:
''
});
}
});
$
(
'.yoho-product-list .size-body .input-radio'
).
check
({
type
:
'radio'
,
onChange
:
function
(
ele
,
checked
,
value
)
{
YohoListPage
.
go
({
size
:
checked
?
value
:
''
});
}
});
...
...
@@ -36,7 +63,7 @@ var YohoListPage = {
type
:
'radio'
,
onChange
:
function
(
ele
,
checked
,
value
)
{
if
(
!
YohoListPage
.
mulitBrand
)
{
YohoListPage
.
go
({
brand
s
:
value
});
YohoListPage
.
go
({
brand
:
value
});
}
else
{
YohoListPage
.
showBrandMulitBtn
();
}
...
...
@@ -57,7 +84,7 @@ var YohoListPage = {
$
(
'.yoho-product-list .brand-btns .confirm'
).
click
(
function
()
{
if
(
!
$
(
this
).
hasClass
(
'disable'
))
{
YohoListPage
.
go
({
brand
s
:
YohoListPage
.
getSelectBrands
().
join
(
','
)
brand
:
YohoListPage
.
getSelectBrands
().
join
(
','
)
});
}
});
...
...
@@ -151,7 +178,7 @@ var YohoListPage = {
},
go
:
function
(
q
)
{
var
qs
=
$
.
extend
(
window
.
queryString
(),
q
);
var
qs
=
$
.
extend
(
common
.
queryString
(),
q
);
location
.
search
=
$
.
param
(
qs
);
}
...
...
public/scss/product/_list.css
View file @
59bec87
...
...
@@ -62,11 +62,11 @@
}
.select
{
color
:
cornflowerblue
;
color
:
#379ed6
;
}
.mulit-choose
{
border
:
1px
solid
#
000
;
border
:
1px
solid
#
1b1b1b
;
padding
:
5px
10px
;
}
}
...
...
@@ -186,7 +186,7 @@
}
span
.cancel
{
font-size
:
8
px
;
font-size
:
14
px
;
}
}
}
...
...
@@ -224,7 +224,7 @@
}
.iconfont.selected
{
color
:
#
000
;
color
:
#
1b1b1b
;
}
.iconfont.up
{
...
...
@@ -236,7 +236,7 @@
}
.order.selected
{
color
:
#
000
;
color
:
#
1b1b1b
;
}
.right
{
...
...
@@ -246,7 +246,7 @@
margin-top
:
12px
;
label
{
color
:
#
000
;
color
:
#
1b1b1b
;
font-weight
:
700
;
display
:
inline-block
;
}
...
...
@@ -256,9 +256,9 @@
}
.page
{
color
:
#
000
;
color
:
#
1b1b1b
;
font-weight
:
700
;
border
:
2px
solid
#
000
;
border
:
2px
solid
#
1b1b1b
;
width
:
24px
;
height
:
24px
;
line-height
:
24px
;
...
...
Please
register
or
login
to post a comment