From b0f1472d2bb96ac039b1f6e3d364b788e40560fa Mon Sep 17 00:00:00 2001 From: pushuo <229102104@qq.com> Date: Tue, 16 Aug 2022 18:57:37 +0800 Subject: [PATCH] wip --- beike/Helpers.php | 3 +- .../Http/Controllers/ProductController.php | 10 ++- beike/Shop/Http/Resources/ProductSimple.php | 5 +- beike/Shop/Services/CartService.php | 1 + public/build/beike/shop/default/js/app.js | 5 +- .../views/pages/languages/index.blade.php | 4 +- resources/beike/shop/default/js/header.js | 1 - themes/default/account/order_info.blade.php | 85 +++++++++++++------ themes/default/search.blade.php | 18 ++++ themes/default/shared/product.blade.php | 2 +- 10 files changed, 95 insertions(+), 39 deletions(-) create mode 100644 themes/default/search.blade.php diff --git a/beike/Helpers.php b/beike/Helpers.php index 545fcdd0..7962f34e 100644 --- a/beike/Helpers.php +++ b/beike/Helpers.php @@ -469,12 +469,13 @@ if (!function_exists('sub_string')) { */ function sub_string($string, int $length = 16, string $dot = '...'): string { - $strLength = strlen($string); + $strLength = mb_strlen($string); if ($length <= 0) { return $string; } elseif ($strLength <= $length) { return $string; } + return mb_substr($string, 0, $length) . $dot; } } diff --git a/beike/Shop/Http/Controllers/ProductController.php b/beike/Shop/Http/Controllers/ProductController.php index 2a50f3db..3527a1de 100644 --- a/beike/Shop/Http/Controllers/ProductController.php +++ b/beike/Shop/Http/Controllers/ProductController.php @@ -33,10 +33,16 @@ class ProductController extends Controller * @param Request $request * @return AnonymousResourceCollection */ - public function search(Request $request): AnonymousResourceCollection + public function search(Request $request) { $keyword = $request->get('keyword'); $products = ProductRepo::getBuilder(['name' => $keyword])->where('active', true)->paginate(); - return ProductSimple::collection($products); + + $data = [ + 'products' => $products, + 'items' => ProductSimple::collection($products)->jsonSerialize(), + ]; + + return view('search', $data); } } diff --git a/beike/Shop/Http/Resources/ProductSimple.php b/beike/Shop/Http/Resources/ProductSimple.php index b35c0e0e..8635fcfd 100644 --- a/beike/Shop/Http/Resources/ProductSimple.php +++ b/beike/Shop/Http/Resources/ProductSimple.php @@ -30,10 +30,13 @@ class ProductSimple extends JsonResource throw new \Exception("invalid master sku for product {$this->id}"); } + $name = $this->description->name ?? ''; + return [ 'id' => $this->id, 'sku_id' => $masterSku->id, - 'name' => $this->description->name ?? '', + 'name' => $name, + 'name_format' => sub_string($name, 50), 'url' => shop_route('products.show', ['product' => $this]), 'price' => $masterSku->price, 'origin_price' => $masterSku->origin_price, diff --git a/beike/Shop/Services/CartService.php b/beike/Shop/Services/CartService.php index a5679152..f950547c 100644 --- a/beike/Shop/Services/CartService.php +++ b/beike/Shop/Services/CartService.php @@ -140,6 +140,7 @@ class CartService if (empty($carts)) { $carts = CartService::list(current_customer()); } + $selected = collect($carts)->where('selected', 1); $quantity = $selected->sum('quantity'); $amount = $selected->sum('subtotal'); diff --git a/public/build/beike/shop/default/js/app.js b/public/build/beike/shop/default/js/app.js index 16baa641..aeb04d1d 100644 --- a/public/build/beike/shop/default/js/app.js +++ b/public/build/beike/shop/default/js/app.js @@ -2213,9 +2213,8 @@ $(function () { $('#offcanvas-search-top input').keydown(function (e) { if (e.keyCode == 13) { if ($(this).val() != '') { - location.href = 'products/keyword?name=' + $(this).val(); - } // $('#offcanvas-search-top .btn-search').click(); - + location.href = 'products/search?keyword=' + $(this).val(); + } } }); }); diff --git a/resources/beike/admin/views/pages/languages/index.blade.php b/resources/beike/admin/views/pages/languages/index.blade.php index 5bb2f5ca..1d150882 100644 --- a/resources/beike/admin/views/pages/languages/index.blade.php +++ b/resources/beike/admin/views/pages/languages/index.blade.php @@ -43,8 +43,8 @@ @close="closeCustomersDialog('form')" :close-on-click-modal="false"> - - + + diff --git a/resources/beike/shop/default/js/header.js b/resources/beike/shop/default/js/header.js index 1434fbf8..1b2e83c6 100644 --- a/resources/beike/shop/default/js/header.js +++ b/resources/beike/shop/default/js/header.js @@ -8,7 +8,6 @@ $(function() { if ($(this).val() != '') { location.href = 'products/search?keyword=' + $(this).val(); } - // $('#offcanvas-search-top .btn-search').click(); } }) }) diff --git a/themes/default/account/order_info.blade.php b/themes/default/account/order_info.blade.php index 1f39b0b7..6a964188 100644 --- a/themes/default/account/order_info.blade.php +++ b/themes/default/account/order_info.blade.php @@ -12,12 +12,23 @@
+ -
-
订单详情
+
+
订单详情
+
+ @if ($order->status == 'unpaid') + 去支付 + @endif + @if ($order->status == 'shipped') + + @endif +
+
+
@@ -34,9 +45,6 @@ @@ -47,37 +55,42 @@
-
订购商品
+
+
订购商品
+
@foreach ($order->orderProducts as $product) -
-
-
-
-
{{ $product->name }} x {{ $product->quantity }}
-
{{ $product->price }}
+
+
+
+
+
{{ $product->name }} x {{ $product->quantity }}
+
{{ $product->price }}
+
+ @if ($order->status == 'completed') + 申请售后 + @endif
- @if ($order->status == 'completed') - 申请售后 - @endif -
@endforeach
-
Order Total
+
+
Order Total
+
{{ $order->created_at }} {{ $order->status }} - @if ($order->status == 'unpaid') - 去支付 - @endif {{ $order->total }}
@foreach (array_chunk($order->orderTotals->all(), 2) as $totals) - - @foreach ($totals as $total) - - - @endforeach - + + @foreach ($totals as $total) + + + @endforeach + @endforeach
{{ $total->title }}{{ $total->value }}
{{ $total->title }}{{ $total->value }}
@@ -85,17 +98,21 @@
@if (0) -
-
物流状态
-
+
+
+
物流状态
+
+
+
-
@endif @if ($order->orderHistories->count())
-
订单状态
+
+
订单状态
+
@@ -122,3 +139,15 @@ @endsection + + +@push('add-scripts') + +@endpush \ No newline at end of file diff --git a/themes/default/search.blade.php b/themes/default/search.blade.php new file mode 100644 index 00000000..86d53c04 --- /dev/null +++ b/themes/default/search.blade.php @@ -0,0 +1,18 @@ +@extends('layout.master') +@section('body-class', 'page-categories') + +@section('content') +
+ + {{-- {{ Diglactic\Breadcrumbs\Breadcrumbs::render('category', $category) }} --}} + +
+ @foreach ($items as $product) +
@include('shared.product')
+ @endforeach +
+ + {{ $products->links('shared/pagination/bootstrap-4') }} +
+ +@endsection diff --git a/themes/default/shared/product.blade.php b/themes/default/shared/product.blade.php index 6a9f5a68..b739fa79 100644 --- a/themes/default/shared/product.blade.php +++ b/themes/default/shared/product.blade.php @@ -28,7 +28,7 @@ -
{{ $product['name'] }}
+
{{ $product['name_format'] }}
{{ $product['price_format'] }} {{ $product['origin_price_format'] }}