优化搜索无数据显示

This commit is contained in:
pushuo 2022-09-01 21:01:33 +08:00 committed by Edward Yang
parent 3b4f3b1e8c
commit cfebf09a74
5 changed files with 43 additions and 8 deletions

View File

@ -11,6 +11,7 @@ use Illuminate\Support\Facades\Config;
use Illuminate\Support\ServiceProvider;
use Beike\Shop\View\Components\Breadcrumb;
use Beike\Shop\View\Components\AccountSidebar;
use Beike\Shop\View\Components\NoData;
class ShopServiceProvider extends ServiceProvider
{
@ -85,6 +86,7 @@ class ShopServiceProvider extends ServiceProvider
{
$this->loadViewComponentsAs('shop', [
'sidebar' => AccountSidebar::class,
'no-data' => NoData::class,
'alert' => Alert::class,
'breadcrumb' => Breadcrumb::class
]);

View File

@ -0,0 +1,21 @@
<?php
namespace Beike\Shop\View\Components;
use Illuminate\View\Component;
use Illuminate\Contracts\View\View;
class NoData extends Component
{
public string $text;
public function __construct(?string $text = '')
{
$this->text = $text ?: trans('common.no_data');
}
public function render()
{
return view('components.no-data');
}
}

View File

@ -2,15 +2,19 @@
@section('body-class', 'page-categories')
@section('content')
<div class="container">
<div class="container">
<x-shop-breadcrumb type="category" :value="$category" />
<div class="row">
@foreach ($products as $product)
<div class="col-6 col-md-3">@include('shared.product')</div>
@endforeach
@if (count($products))
@foreach ($products as $product)
<div class="col-6 col-md-3">@include('shared.product')</div>
@endforeach
@else
<x-shop-no-data />
@endif
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,4 @@
<div class="d-flex flex-column align-center align-items-center mb-4">
<img src="{{ asset('image/no-data.svg') }}" class="img-fluid wp-400">
<div class="text-secondary fs-4">{{ $text }}</div>
</div>

View File

@ -7,9 +7,13 @@
<x-shop-breadcrumb type="static" value="products.search" />
<div class="row">
@foreach ($items as $product)
<div class="col-6 col-md-3">@include('shared.product')</div>
@endforeach
@if (count($products))
@foreach ($products as $product)
<div class="col-6 col-md-3">@include('shared.product')</div>
@endforeach
@else
<x-shop-no-data />
@endif
</div>
{{ $products->links('shared/pagination/bootstrap-4') }}