diff --git a/beike/Models/Product.php b/beike/Models/Product.php index a6be47e9..238d7b0e 100644 --- a/beike/Models/Product.php +++ b/beike/Models/Product.php @@ -50,11 +50,6 @@ class Product extends Model return '$' . $this->price; } - public function getVariablesDecodedAttribute() - { - return json_decode($this->variables, true); - } - public function getUrlAttribute() { return shop_route('products.show', ['product' => $this]); diff --git a/public/build/beike/shop/default/css/app.css b/public/build/beike/shop/default/css/app.css index c4816e1a..8da689a5 100644 --- a/public/build/beike/shop/default/css/app.css +++ b/public/build/beike/shop/default/css/app.css @@ -381,6 +381,23 @@ body.page-product .product-image .left { body.page-product .product-image .left > div { margin-bottom: 1rem; } +body.page-product .variables-wrap .variable-info > div { + display: inline-flex; + align-items: center; + justify-content: center; + margin-right: 0.5rem; + margin-bottom: 0.5rem; + border: 1px solid #ddd; + margin-left: 0; + min-width: 3rem; + padding: 0.5rem; + cursor: pointer; + text-align: center; + transition: all 0.1s ease-in-out; +} +body.page-product .variables-wrap .variable-info > div:hover, body.page-product .variables-wrap .variable-info > div.active { + border-color: #222; +} body.page-product .peoduct-info .rating-wrap { margin-bottom: 2rem; } diff --git a/resources/beike/admin/views/pages/products/form/form.blade.php b/resources/beike/admin/views/pages/products/form/form.blade.php index c503db37..f2f6b499 100644 --- a/resources/beike/admin/views/pages/products/form/form.blade.php +++ b/resources/beike/admin/views/pages/products/form/form.blade.php @@ -140,11 +140,11 @@ el: '#app', data: { form: { - variables: @json($product->variables_decoded ?? []), + variables: @json($product->variables ?? []), skus: @json($product->skus ?? []), }, source: { - variables: @json($product->variables_decoded ?? []), + variables: @json($product->variables ?? []), }, editing: { isVariable: @json(($product->variables ?? null) != null), diff --git a/resources/beike/shop/default/css/product.scss b/resources/beike/shop/default/css/product.scss index bad10638..3b6505a3 100644 --- a/resources/beike/shop/default/css/product.scss +++ b/resources/beike/shop/default/css/product.scss @@ -11,6 +11,28 @@ body.page-product { } } + .variables-wrap { + .variable-info { + > div { + display: inline-flex; + align-items: center; + justify-content: center; + margin-right: 0.5rem; + margin-bottom: 0.5rem; + border: 1px solid #ddd; + margin-left: 0; + min-width: 3rem; + padding: 0.5rem; + cursor: pointer; + text-align: center; + transition: all .1s ease-in-out; + &:hover, &.active { + border-color: #222; + } + } + } + } + .peoduct-info { .rating-wrap { margin-bottom: 2rem; diff --git a/themes/default/product.blade.php b/themes/default/product.blade.php index 4be1d3a4..ae9c7cdd 100644 --- a/themes/default/product.blade.php +++ b/themes/default/product.blade.php @@ -2,9 +2,15 @@ @section('body-class', 'page-product') +@push('header') + + {{-- --}} + {{-- --}} +@endpush + @section('content') -
+
-
+
@@ -20,13 +26,13 @@
@endfor
-
+
-

{{ $product->description->name }}

+

{{ $product['name'] }}

@for ($i = 0; $i < 5; $i++) @@ -36,19 +42,35 @@ 132 reviews
-
{{ $product->master_sku->price }}
-
{{ $product->master_sku->origin_price }}
+
+
+ +
+
+

@{{ variable.name }}

+
+
+ @{{ value.name }} +
+
+
+
+
- + - +
型号{{ $product->master_sku->model }}
Sku{{ $product->master_sku->sku }}
@@ -87,17 +109,56 @@
@endsection +@push('add-scripts') + +@endpush \ No newline at end of file