refactor: 系统其他urls回显
This commit is contained in:
@@ -158,119 +158,7 @@ class System
|
|||||||
[
|
[
|
||||||
'name' => '其他内页',
|
'name' => '其他内页',
|
||||||
'link_to' => 'system_page',
|
'link_to' => 'system_page',
|
||||||
'data' => [
|
'data' => self::getSystemOtherPages()
|
||||||
[
|
|
||||||
'id' => 1,
|
|
||||||
'name' => '首页',
|
|
||||||
'url' => (string)url('/index/index/index')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 2,
|
|
||||||
'name' => '新品上市',
|
|
||||||
'url' => (string)url('/index/product/newpro')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 3,
|
|
||||||
'name' => '附件下载',
|
|
||||||
'url' => (string)url('/index/attachment/index')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 4,
|
|
||||||
'name' => '问答中心',
|
|
||||||
'url' => (string)url('/index/faq/index')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 5,
|
|
||||||
'name' => '关于我们',
|
|
||||||
'url' => '',
|
|
||||||
'children' => [
|
|
||||||
[
|
|
||||||
'id' => 51,
|
|
||||||
'name' => '品牌介绍',
|
|
||||||
'url' => (string)url('/index/aboutus/introduction')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 52,
|
|
||||||
'name' => '品牌故事',
|
|
||||||
'url' => (string)url('/index/aboutus/story')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 53,
|
|
||||||
'name' => '品牌历程',
|
|
||||||
'url' => (string)url('/index/aboutus/mileage')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 54,
|
|
||||||
'name' => '文化介绍',
|
|
||||||
'url' => (string)url('/index/aboutus/culture')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 55,
|
|
||||||
'name' => '售后政策',
|
|
||||||
'url' => (string)url('/index/aboutus/policy')
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 6,
|
|
||||||
'name' => '联系我们',
|
|
||||||
'url' => '',
|
|
||||||
'children' => [
|
|
||||||
[
|
|
||||||
'id' => 61,
|
|
||||||
'name' => '联系我们',
|
|
||||||
'url' => (string)url('/index/contactus/index')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 62,
|
|
||||||
'name' => '留言联系我们',
|
|
||||||
'url' => (string)url('/index/contactus/message')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 63,
|
|
||||||
'name' => '留言成为分销商',
|
|
||||||
'url' => (string)url('/index/contactus/distributor')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 64,
|
|
||||||
'name' => '留言批量购买',
|
|
||||||
'url' => (string)url('/index/contactus/bulkbuy')
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 7,
|
|
||||||
'name' => 'NAS专题',
|
|
||||||
'url' => '',
|
|
||||||
'children' => [
|
|
||||||
[
|
|
||||||
'id' => 71,
|
|
||||||
'name' => '首页',
|
|
||||||
'url' => (string)url('/index/topic/nas/index')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 72,
|
|
||||||
'name' => '产品体验',
|
|
||||||
'url' => (string)url('/index/topic/nas/product')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 73,
|
|
||||||
'name' => '客户合作',
|
|
||||||
'url' => (string)url('/index/topic/nas/cooperation')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 74,
|
|
||||||
'name' => '帮助中心',
|
|
||||||
'url' => (string)url('/index/topic/nas/help')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 75,
|
|
||||||
'name' => '软件下载',
|
|
||||||
'url' => (string)url('/index/topic/nas/download')
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -336,6 +224,124 @@ class System
|
|||||||
return $data->toArray();
|
return $data->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取系统其他内页
|
||||||
|
static private function getSystemOtherPages()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'id' => 1,
|
||||||
|
'name' => '首页',
|
||||||
|
'url' => (string)url('/index/index/index')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 2,
|
||||||
|
'name' => '新品上市',
|
||||||
|
'url' => (string)url('/index/product/newpro')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 3,
|
||||||
|
'name' => '附件下载',
|
||||||
|
'url' => (string)url('/index/attachment/index')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 4,
|
||||||
|
'name' => '问答中心',
|
||||||
|
'url' => (string)url('/index/faq/index')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 5,
|
||||||
|
'name' => '关于我们',
|
||||||
|
'url' => '',
|
||||||
|
'children' => [
|
||||||
|
[
|
||||||
|
'id' => 51,
|
||||||
|
'name' => '品牌介绍',
|
||||||
|
'url' => (string)url('/index/aboutus/introduction')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 52,
|
||||||
|
'name' => '品牌故事',
|
||||||
|
'url' => (string)url('/index/aboutus/story')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 53,
|
||||||
|
'name' => '品牌历程',
|
||||||
|
'url' => (string)url('/index/aboutus/mileage')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 54,
|
||||||
|
'name' => '文化介绍',
|
||||||
|
'url' => (string)url('/index/aboutus/culture')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 55,
|
||||||
|
'name' => '售后政策',
|
||||||
|
'url' => (string)url('/index/aboutus/policy')
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 6,
|
||||||
|
'name' => '联系我们',
|
||||||
|
'url' => '',
|
||||||
|
'children' => [
|
||||||
|
[
|
||||||
|
'id' => 61,
|
||||||
|
'name' => '联系我们',
|
||||||
|
'url' => (string)url('/index/contactus/index')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 62,
|
||||||
|
'name' => '留言联系我们',
|
||||||
|
'url' => (string)url('/index/contactus/message')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 63,
|
||||||
|
'name' => '留言成为分销商',
|
||||||
|
'url' => (string)url('/index/contactus/distributor')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 64,
|
||||||
|
'name' => '留言批量购买',
|
||||||
|
'url' => (string)url('/index/contactus/bulkbuy')
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 7,
|
||||||
|
'name' => 'NAS专题',
|
||||||
|
'url' => '',
|
||||||
|
'children' => [
|
||||||
|
[
|
||||||
|
'id' => 71,
|
||||||
|
'name' => '首页',
|
||||||
|
'url' => (string)url('/index/topic/nas/index')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 72,
|
||||||
|
'name' => '产品体验',
|
||||||
|
'url' => (string)url('/index/topic/nas/product')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 73,
|
||||||
|
'name' => '客户合作',
|
||||||
|
'url' => (string)url('/index/topic/nas/cooperation')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 74,
|
||||||
|
'name' => '帮助中心',
|
||||||
|
'url' => (string)url('/index/topic/nas/help')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 75,
|
||||||
|
'name' => '软件下载',
|
||||||
|
'url' => (string)url('/index/topic/nas/download')
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
// 根据系统页面url获取回显数据项
|
// 根据系统页面url获取回显数据项
|
||||||
static public function getEchoDataBySystemPageUrl($link_to, $link)
|
static public function getEchoDataBySystemPageUrl($link_to, $link)
|
||||||
{
|
{
|
||||||
@@ -351,21 +357,29 @@ class System
|
|||||||
parse_str($url, $params);
|
parse_str($url, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($params['id'])) return [];
|
|
||||||
|
|
||||||
switch ($link_to) {
|
switch ($link_to) {
|
||||||
case 'article_category':
|
case 'article_category':
|
||||||
|
if (empty($params['id'])) return [];
|
||||||
$data = ArticleCategoryModel::field(['id', 'name'])->bypk($params['id'])->find();
|
$data = ArticleCategoryModel::field(['id', 'name'])->bypk($params['id'])->find();
|
||||||
break;
|
break;
|
||||||
case 'article':
|
case 'article':
|
||||||
|
if (empty($params['id'])) return [];
|
||||||
$data = ArticleModel::field(['id', 'title' => 'name'])->bypk($params['id'])->find();
|
$data = ArticleModel::field(['id', 'title' => 'name'])->bypk($params['id'])->find();
|
||||||
break;
|
break;
|
||||||
case 'product_category':
|
case 'product_category':
|
||||||
|
if (empty($params['id'])) return [];
|
||||||
$data = ProductCategoryModel::field(['id', 'name'])->bypk($params['id'])->find();
|
$data = ProductCategoryModel::field(['id', 'name'])->bypk($params['id'])->find();
|
||||||
break;
|
break;
|
||||||
case 'product':
|
case 'product':
|
||||||
|
if (empty($params['id'])) return [];
|
||||||
$data = ProductModel::field(['id', 'name'])->bypk($params['id'])->find();
|
$data = ProductModel::field(['id', 'name'])->bypk($params['id'])->find();
|
||||||
break;
|
break;
|
||||||
|
case 'system_page':
|
||||||
|
$data = self::filterSystemOtherPage(self::getSystemOtherPages(), function($item) use ($params, $link) {
|
||||||
|
if (empty($params['id'])) return $item['url'] == $link;
|
||||||
|
return $item['id'] == $params['id'];
|
||||||
|
});
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return [];
|
return [];
|
||||||
break;
|
break;
|
||||||
@@ -378,4 +392,22 @@ class System
|
|||||||
'link' => $link
|
'link' => $link
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据条件过滤结果
|
||||||
|
static private function filterSystemOtherPage(array $data, callable $callback): array
|
||||||
|
{
|
||||||
|
foreach ($data as $it) {
|
||||||
|
if ($callback($it)) {
|
||||||
|
return $it;
|
||||||
|
}
|
||||||
|
if (isset($it['children'])) {
|
||||||
|
$child = self::filterSystemOtherPage($it['children'], $callback);
|
||||||
|
if (!empty($child)) {
|
||||||
|
return $child;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user