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
Email Patches
Plain Diff
Browse Files
Authored by
郭成尧
9 years ago
Commit
bf655446b0c1ab2e16dabaf6d4bf7cd1999184f8
1 parent
a23c20f9
'排序优化'
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
14 deletions
apps/channel/models/brand.js
apps/channel/models/brand.js
View file @
bf65544
...
...
@@ -21,35 +21,69 @@ const handleBrandList = origin => {
indexList
:
[]
};
// 标记是否有数字,有数字先暂存
let
hasNum
=
false
;
let
numTemp
=
{};
_
.
forEach
(
origin
,
(
value
,
key
)
=>
{
let
brands
=
[];
_
.
forEach
(
value
,
(
subValue
)
=>
{
if
(
key
===
'0~9'
)
{
hasNum
=
true
;
numTemp
=
origin
[
key
];
}
else
{
_
.
forEach
(
value
,
(
subValue
)
=>
{
brands
.
push
({
name
:
subValue
.
brand_name_en
||
subValue
.
brand_name_cn
||
subValue
.
brand_name
,
logo
:
subValue
.
brand_ico
,
domain
:
subValue
.
brand_domain
});
});
dest
.
brandList
.
push
({
index
:
key
,
brands
:
brands
});
dest
.
indexList
.
push
({
index
:
key
,
name
:
key
===
'0~9'
?
'0'
:
key
});
}
});
// 商品列表排序一次
_
.
sortBy
(
dest
.
brandList
,
o
=>
{
return
o
.
index
.
charCodeAt
();
});
// 字母列表排序一次
_
.
sortBy
(
dest
.
indexList
,
o
=>
{
return
o
.
index
.
charCodeAt
();
});
// 如果有数字,单独处理
if
(
hasNum
)
{
let
brands
=
{};
_
.
forEach
(
numTemp
,
(
subValue
)
=>
{
brands
.
push
({
name
:
subValue
.
brand_name_en
||
subValue
.
brand_name_cn
||
subValue
.
brand_name
,
logo
:
subValue
.
brand_ico
,
domain
:
subValue
.
brand_domain
});
});
dest
.
brandList
.
push
({
index
:
key
,
index
:
'0~9'
,
brands
:
brands
});
_
.
sortBy
(
dest
.
brandList
,
o
=>
{
return
o
.
index
;
});
dest
.
indexList
.
push
({
index
:
key
,
name
:
key
===
'0~9'
?
'0'
:
key
index
:
'0_9'
,
name
:
'0'
});
_
.
sortBy
(
dest
.
indexList
,
o
=>
{
return
o
.
index
;
});
});
}
return
dest
;
};
...
...
Please
register
or
login
to post a comment