Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
Rock Zhang
9 years ago
Commit
652eda17daf93f0f4648cb908643758d62291f4e
1 parent
417380d8
修复侧边栏数据的数据格式,方便从后来获取配置
Code Review By Rock Zhang
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
8 deletions
library/LibModels/Wap/Home/SideData.php
template/m.yohobuy.com/partials/home/side_nav.phtml
yohobuy/m.yohobuy.com/application/models/Index/Side.php
library/LibModels/Wap/Home/SideData.php
View file @
652eda1
...
...
@@ -18,7 +18,7 @@ class SideData
{
const
URI_LEFTNAV_ENTRANCE
=
'operations/api/v5/entrance/getEntrance'
;
const
URI_LEFTNAV_CATEGORY
=
'operations/api/v
5
/category/getCategory'
;
const
URI_LEFTNAV_CATEGORY
=
'operations/api/v
6
/category/getCategory'
;
/**
* 左侧边栏的分类和图标数据
...
...
template/m.yohobuy.com/partials/home/side_nav.phtml
View file @
652eda1
<div class="side-nav">
{{# sideNav}}
<ul>
{{#
sideNav
}}
{{#
this
}}
<li class="{{styleClass}}">
{{# url}}
<a href="{{.}}">
...
...
@@ -43,6 +44,7 @@
</ul>
{{/ subNav}}
</li>
{{/
sideNav
}}
{{/
this
}}
</ul>
{{/sideNav}}
</div>
\ No newline at end of file
...
...
yohobuy/m.yohobuy.com/application/models/Index/Side.php
View file @
652eda1
...
...
@@ -39,16 +39,38 @@ class SideModel
// 调用接口获取后台配置的侧边栏数据
$side
=
SideData
::
leftNav
();
if
(
!
empty
(
$side
[
'data'
]))
{
$group
=
array
();
$num
=
0
;
$groupKey
=
0
;
$count
=
count
((
$side
[
'data'
]));
foreach
(
$side
[
'data'
]
as
$key
=>
$value
)
{
if
(
$value
[
'separative_sign'
]
===
'Y'
)
{
$result
[
$num
]
=
$group
;
$num
++
;
$groupKey
=
0
;
$group
=
array
();
}
// 逛的按照原来的做法,使用配置
if
(
$value
[
'sort_name_en'
]
===
'TRENDFINDER'
)
{
continue
;
}
$result
[
$key
][
'textCn'
]
=
$value
[
'sort_name'
];
$result
[
$key
][
'textEn'
]
=
$value
[
'sort_name_en'
];
$result
[
$key
][
'styleClass'
]
=
strtolower
(
$value
[
'sort_name_en'
]);
$result
[
$key
][
'url'
]
=
Helpers
::
getFilterUrl
(
$value
[
'sort_url'
]);
$result
[
$key
][
'img'
]
=
Helpers
::
getImageUrl
(
$value
[
'sort_ico'
],
60
,
60
,
1
);
$group
[
$groupKey
]
=
self
::
formatSideItem
(
$value
);
// 如果存在子菜单,就输出子菜单
if
(
isset
(
$value
[
'sub'
])
&&
!
empty
(
$value
[
'sub'
]))
{
$subs
=
array
();
foreach
(
$value
[
'sub'
]
as
$oneSub
)
{
$subs
[]
=
self
::
formatSideItem
(
$oneSub
);
}
$group
[
$groupKey
][
'subNav'
]
=
$subs
;
}
$groupKey
++
;
if
(
$count
===
$key
+
1
)
{
$result
[
$num
]
=
$group
;
}
}
}
...
...
@@ -126,4 +148,24 @@ class SideModel
);
}
/**
* 格式化侧边栏数据
*
* @param array $data 要格式化的侧边栏数据
* @return array
*/
private
static
function
formatSideItem
(
$data
)
{
$result
=
array
();
$result
[
'textCn'
]
=
$data
[
'sort_name'
];
$result
[
'textEn'
]
=
$data
[
'sort_name_en'
];
$result
[
'styleClass'
]
=
strtolower
(
$data
[
'sort_name_en'
]);
$result
[
'url'
]
=
Helpers
::
getFilterUrl
(
$data
[
'sort_url'
]);
$result
[
'img'
]
=
Helpers
::
getImageUrl
(
$data
[
'sort_ico'
],
60
,
60
,
1
);
return
$result
;
}
}
...
...
Please
register
or
login
to post a comment