修复订单详情页面包屑
This commit is contained in:
parent
a350b867cd
commit
b512f6260d
|
|
@ -82,7 +82,7 @@ function load_settings()
|
|||
* @param mixed $params
|
||||
* @return string
|
||||
*/
|
||||
function admin_route($route, $params = []): string
|
||||
function admin_route($route, array $params = []): string
|
||||
{
|
||||
$adminName = admin_name();
|
||||
return route("{$adminName}.{$route}", $params);
|
||||
|
|
@ -95,7 +95,7 @@ function admin_route($route, $params = []): string
|
|||
* @param mixed $params
|
||||
* @return string
|
||||
*/
|
||||
function shop_route($route, $params = []): string
|
||||
function shop_route($route, array $params = []): string
|
||||
{
|
||||
return route('shop.' . $route, $params);
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@ function shop_route($route, $params = []): string
|
|||
* @param mixed $params
|
||||
* @return string
|
||||
*/
|
||||
function plugin_route($route, $params = []): string
|
||||
function plugin_route($route, array $params = []): string
|
||||
{
|
||||
return route('plugin.' . $route, $params);
|
||||
}
|
||||
|
|
@ -122,7 +122,7 @@ function plugin_route($route, $params = []): string
|
|||
*/
|
||||
function type_route($type, $value): string
|
||||
{
|
||||
$types = ['category', 'product', 'brand', 'page', 'static', 'custom'];
|
||||
$types = ['category', 'product', 'brand', 'page', 'order', 'static', 'custom'];
|
||||
if (empty($type) || empty($value) || !in_array($type, $types)) {
|
||||
return '';
|
||||
}
|
||||
|
|
@ -138,6 +138,8 @@ function type_route($type, $value): string
|
|||
return shop_route('brands.show', [$value]);
|
||||
} elseif ($type == 'page') {
|
||||
return shop_route('pages.show', ['page' => $value]);
|
||||
} elseif ($type == 'order') {
|
||||
return shop_route('account.order.show', ['number' => $value]);
|
||||
} elseif ($type == 'static') {
|
||||
return shop_route($value);
|
||||
} elseif ($type == 'custom') {
|
||||
|
|
@ -190,6 +192,7 @@ function type_label($type, $value, array $texts = []): string
|
|||
*
|
||||
* @param $link
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
function handle_link($link): array
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ class Breadcrumb extends Component
|
|||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct($type, $value, array $text = [])
|
||||
{
|
||||
|
|
@ -37,6 +38,8 @@ class Breadcrumb extends Component
|
|||
$breadcrumbs = array_merge($breadcrumbs, $this->handleCategoryLinks($value));
|
||||
} elseif ($type == 'product') {
|
||||
$breadcrumbs = array_merge($breadcrumbs, $this->handleProductLinks($value));
|
||||
} elseif ($type == 'order') {
|
||||
$breadcrumbs = array_merge($breadcrumbs, $this->handleOrderLinks($value));
|
||||
} elseif (Str::startsWith($value, 'account')) {
|
||||
$breadcrumbs = array_merge($breadcrumbs, $this->handleAccountLinks($value));
|
||||
} else {
|
||||
|
|
@ -62,6 +65,7 @@ class Breadcrumb extends Component
|
|||
*
|
||||
* @param $value
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function handleCategoryLinks($value): array
|
||||
{
|
||||
|
|
@ -79,6 +83,7 @@ class Breadcrumb extends Component
|
|||
*
|
||||
* @param $value
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function handleProductLinks($value): array
|
||||
{
|
||||
|
|
@ -103,11 +108,45 @@ class Breadcrumb extends Component
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取订单详情页面包屑
|
||||
*
|
||||
* @param $value
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function handleOrderLinks($value): array
|
||||
{
|
||||
$links = [];
|
||||
|
||||
$link = handle_link(['type' => 'static', 'value' => 'account.index']);
|
||||
$links[] = [
|
||||
'title' => $link['text'],
|
||||
'url' => $link['link'],
|
||||
];
|
||||
|
||||
$link = handle_link(['type' => 'static', 'value' => 'account.order.index']);
|
||||
$links[] = [
|
||||
'title' => $link['text'],
|
||||
'url' => $link['link'],
|
||||
];
|
||||
|
||||
$link = handle_link(['type' => 'order', 'value' => $value]);
|
||||
$links[] = [
|
||||
'title' => $value,
|
||||
'url' => $link['link'],
|
||||
];
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理个人中心面包屑
|
||||
*
|
||||
* @param $value
|
||||
* @return array[]
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function handleAccountLinks($value): array
|
||||
{
|
||||
|
|
@ -138,6 +177,7 @@ class Breadcrumb extends Component
|
|||
* @param $value
|
||||
* @param array $text
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function handleLinks($type, $value, array $text = []): array
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,14 +5,7 @@
|
|||
@section('content')
|
||||
<div class="container">
|
||||
|
||||
<x-shop-breadcrumb type="static" value="account.order.index" />
|
||||
|
||||
{{-- <nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Library</li>
|
||||
</ol>
|
||||
</nav> --}}
|
||||
<x-shop-breadcrumb type="order" value="{{ $order->number }}" />
|
||||
|
||||
<div class="row">
|
||||
<x-shop-sidebar />
|
||||
|
|
@ -153,4 +146,4 @@
|
|||
})
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@endpush
|
||||
|
|
|
|||
Loading…
Reference in New Issue