diff --git a/beike/Helpers.php b/beike/Helpers.php index ede6b668..f9a5fba4 100644 --- a/beike/Helpers.php +++ b/beike/Helpers.php @@ -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 { diff --git a/beike/Shop/View/Components/Breadcrumb.php b/beike/Shop/View/Components/Breadcrumb.php index e3609b45..e254cb70 100644 --- a/beike/Shop/View/Components/Breadcrumb.php +++ b/beike/Shop/View/Components/Breadcrumb.php @@ -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 { diff --git a/themes/default/account/order_info.blade.php b/themes/default/account/order_info.blade.php index a26a067e..c01817f2 100644 --- a/themes/default/account/order_info.blade.php +++ b/themes/default/account/order_info.blade.php @@ -5,14 +5,7 @@ @section('content')
- - - {{-- --}} +
@@ -153,4 +146,4 @@ }) }); -@endpush \ No newline at end of file +@endpush