From 19df41c8d4497d08fb056f1fce3a3ca4bec14c41 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Wed, 20 Sep 2023 14:49:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=AE=A1=E9=87=8F=E5=8D=95=E4=BD=8D=E5=B9=B6=E4=B8=94=E5=9C=A8?= =?UTF-8?q?=E5=95=86=E5=93=81=E7=BB=84=E4=BB=B6=E5=92=8C=E5=95=86=E5=93=81?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E4=B8=AD=E6=98=BE=E7=A4=BA=E3=80=82=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=A4=9A=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- beike/Models/ProductDescription.php | 2 +- beike/Shop/Http/Resources/CartDetail.php | 4 +++ beike/Shop/Http/Resources/ProductDetail.php | 1 + beike/Shop/Http/Resources/ProductSimple.php | 3 +++ .../views/pages/products/form/form.blade.php | 9 +++---- resources/lang/en/product.php | 3 ++- resources/lang/zh_cn/product.php | 3 ++- themes/default/product/product.blade.php | 25 +++++++++--------- themes/default/shared/product.blade.php | 26 ++++++++++++------- 9 files changed, 46 insertions(+), 30 deletions(-) diff --git a/beike/Models/ProductDescription.php b/beike/Models/ProductDescription.php index 78c6f341..90bea26f 100644 --- a/beike/Models/ProductDescription.php +++ b/beike/Models/ProductDescription.php @@ -8,5 +8,5 @@ class ProductDescription extends Base { use HasFactory; - protected $fillable = ['locale', 'name', 'content', 'meta_title', 'meta_description', 'meta_keywords']; + protected $fillable = ['locale', 'name', 'content', 'meta_title', 'meta_description', 'meta_keywords', 'unit']; } diff --git a/beike/Shop/Http/Resources/CartDetail.php b/beike/Shop/Http/Resources/CartDetail.php index ceb00e35..bade6f77 100644 --- a/beike/Shop/Http/Resources/CartDetail.php +++ b/beike/Shop/Http/Resources/CartDetail.php @@ -26,7 +26,9 @@ class CartDetail extends JsonResource }; $skuCode = $sku->sku; $description = $product->description; + $productName = $description->name; + $unit = $description->unit ?? ''; $subTotal = $price * $this->quantity; $image = $sku->image ?: $product->image; @@ -37,6 +39,8 @@ class CartDetail extends JsonResource 'product_sku' => $skuCode, 'name' => $productName, 'name_format' => sub_string($productName), + 'unit' => $unit, + 'unit_format' => $unit, 'image' => $image, 'image_url' => image_resize($image), 'quantity' => $this->quantity, diff --git a/beike/Shop/Http/Resources/ProductDetail.php b/beike/Shop/Http/Resources/ProductDetail.php index 573279a9..183c8f5b 100644 --- a/beike/Shop/Http/Resources/ProductDetail.php +++ b/beike/Shop/Http/Resources/ProductDetail.php @@ -34,6 +34,7 @@ class ProductDetail extends JsonResource return [ 'id' => $this->id, 'name' => $this->description->name ?? '', + 'unit' => $this->description->unit ?? '', 'description' => $this->description->content ?? '', 'meta_title' => $this->description->meta_title ?? '', 'meta_keywords' => $this->description->meta_keywords ?? '', diff --git a/beike/Shop/Http/Resources/ProductSimple.php b/beike/Shop/Http/Resources/ProductSimple.php index 91fe4c18..b46f343d 100644 --- a/beike/Shop/Http/Resources/ProductSimple.php +++ b/beike/Shop/Http/Resources/ProductSimple.php @@ -31,6 +31,7 @@ class ProductSimple extends JsonResource } $name = $this->description->name ?? ''; + $unit = $this->description->unit ?? ''; $images = $this->images != NULL ? $this->images : []; $data = [ @@ -38,6 +39,8 @@ class ProductSimple extends JsonResource 'sku_id' => $masterSku->id, 'name' => $name, 'name_format' => $name, + 'unit' => $unit, + 'unit_format' => $unit, 'url' => $this->url, 'price' => $masterSku->price, 'origin_price' => $masterSku->origin_price, 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 f6f64b1d..2be41d44 100644 --- a/resources/beike/admin/views/pages/products/form/form.blade.php +++ b/resources/beike/admin/views/pages/products/form/form.blade.php @@ -136,7 +136,9 @@ - {{----}} + {{--计量单位--}} + + {{--状态--}}
@@ -149,11 +151,6 @@
- - - - - @hook('admin.product.edit.extra')
diff --git a/resources/lang/en/product.php b/resources/lang/en/product.php index c13bdb07..7b9bcf12 100644 --- a/resources/lang/en/product.php +++ b/resources/lang/en/product.php @@ -29,5 +29,6 @@ return [ 'inactive' => 'Inactive', 'has_been_inactive' => 'The product has been inactive', 'minimum_order' => 'Min Order', - 'minimum_order_error' => 'The purchase quantity must be greater than or equal to :num' + 'minimum_order_error' => 'The purchase quantity must be greater than or equal to :num', + 'unit_of_measurement' => 'Unit of measurement' ]; diff --git a/resources/lang/zh_cn/product.php b/resources/lang/zh_cn/product.php index 3efe739d..ea45a441 100644 --- a/resources/lang/zh_cn/product.php +++ b/resources/lang/zh_cn/product.php @@ -30,5 +30,6 @@ return [ 'inactive' => '下架', 'has_been_inactive' => '该商品已下架', 'minimum_order' => '起订量', - 'minimum_order_error' => '采购数量必须大于等于:num' + 'minimum_order_error' => '采购数量必须大于等于:num', + 'unit_of_measurement' => '计量单位' ]; diff --git a/themes/default/product/product.blade.php b/themes/default/product/product.blade.php index 798d9810..bcd554a6 100644 --- a/themes/default/product/product.blade.php +++ b/themes/default/product/product.blade.php @@ -203,7 +203,7 @@
@hookwrapper('product.detail.quantity')
- {{ __('product.quantity') }}: + {{ __('product.quantity') }}:
@@ -214,7 +214,7 @@ @if ($product['brand_id']) @hookwrapper('product.detail.brand')
- {{ __('product.brand') }}: + {{ __('product.brand') }}: {{ $product['brand_name'] }}
@endhookwrapper @@ -222,17 +222,25 @@ @hookwrapper('product.detail.sku')
- SKU:@{{ product.sku }} + SKU:@{{ product.sku }}
@endhookwrapper @hookwrapper('product.detail.model') -
{{ __('shop/products.model') }}: @{{ product.model }}
+
{{ __('shop/products.model') }}: @{{ product.model }}
@endhookwrapper
- {{__('product.minimum_order')}}: @{{ minimum_order }} + {{__('product.minimum_order')}}: @{{ minimum_order }}
+ + @if(!empty($product['unit'])) +
+ {{__('product.unit_of_measurement')}}: {{ $product['unit'] }} +
+ @endif + +
@if (0)
@@ -873,13 +881,6 @@ params.products_country_id = _this.country_id; params.change_logistics_id = _this.change_logistics_id; - - console.log(_this.minimum_order); - - - return false; - - // 提交内容 bk.addCart(params, null, () => { if (isIframe) { diff --git a/themes/default/shared/product.blade.php b/themes/default/shared/product.blade.php index 77ecaad5..3cd7b041 100644 --- a/themes/default/shared/product.blade.php +++ b/themes/default/shared/product.blade.php @@ -66,17 +66,25 @@ - {{ $product['price_format'] }} @endif - /pieces + + @if(!empty($product['unit_format'])) + /{{ $product['unit_format'] }} + @endif
-
- @if ($product['price_setting'] === 'num') - {{$product['numprices'] != [] ? $product['numprices'][0]['num'] : 1}} pieces - @else - {{$product['minimum_order'] ?? 0}} pieces - @endif - ({{__('admin/product.minimum_order')}}) -
+ + @if ((int)$product['minimum_order'] > 0 || ($product['numprices'] != [] ? $product['numprices'][0]['num'] : 0) > 0) +
+ @if ($product['price_setting'] === 'num') + {{$product['numprices'] != [] ? $product['numprices'][0]['num'] : 1}} {{ $product['unit_format'] ?? '' }} + @else + {{$product['minimum_order'] ?? 0}} {{ $product['unit_format'] ?? '' }} + @endif + ({{__('admin/product.minimum_order')}}) +
+ @endif + + @if (request('style_list') == 'list')