From 2e36e35e17cdf9e2c4f29d30db6af95f19e711a2 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Wed, 20 Sep 2023 14:05:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E5=AE=A2=E6=9C=8D?= =?UTF-8?q?=E7=AB=AF=20-=20=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=98=BE=E7=A4=BA=E5=BD=93=E5=89=8D=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=9A=84=E6=9C=80=E5=B0=8F=E8=B5=B7=E8=AE=A2=E9=87=8F=E3=80=81?= =?UTF-8?q?=E5=B9=B6=E4=B8=94=E5=A6=82=E6=9E=9C=E8=B4=AD=E4=B9=B0=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E4=BD=8E=E4=BA=8E=E6=9C=80=E5=B0=8F=E8=B5=B7=E8=B4=AD?= =?UTF-8?q?=E9=87=8F=E6=97=B6=E7=A6=81=E6=AD=A2=E4=B8=8B=E5=8D=95=E5=92=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B4=AD=E7=89=A9=E8=BD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- beike/Shop/Http/Resources/ProductDetail.php | 1 + resources/lang/en/product.php | 3 ++- resources/lang/zh_cn/product.php | 3 ++- themes/default/product/product.blade.php | 26 ++++++++++++++++++++- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/beike/Shop/Http/Resources/ProductDetail.php b/beike/Shop/Http/Resources/ProductDetail.php index 97e2f851..573279a9 100644 --- a/beike/Shop/Http/Resources/ProductDetail.php +++ b/beike/Shop/Http/Resources/ProductDetail.php @@ -54,6 +54,7 @@ class ProductDetail extends JsonResource 'in_wishlist' => $this->inCurrentWishlist->id ?? 0, 'active' => (bool) $this->active, 'price_setting' => $this->price_setting ?? '', + 'minimum_order' => $this->minimum_order ?? 0, 'numPrices' => NumPricesDetail::collection($this->numprices)->jsonSerialize() ?? '', ]; } diff --git a/resources/lang/en/product.php b/resources/lang/en/product.php index 327bba35..c13bdb07 100644 --- a/resources/lang/en/product.php +++ b/resources/lang/en/product.php @@ -28,5 +28,6 @@ return [ 'active' => 'Active', 'inactive' => 'Inactive', 'has_been_inactive' => 'The product has been inactive', - 'minimum_order' => 'Min Order' + 'minimum_order' => 'Min Order', + 'minimum_order_error' => 'The purchase quantity must be greater than or equal to :num' ]; diff --git a/resources/lang/zh_cn/product.php b/resources/lang/zh_cn/product.php index b2a31e65..3efe739d 100644 --- a/resources/lang/zh_cn/product.php +++ b/resources/lang/zh_cn/product.php @@ -29,5 +29,6 @@ return [ 'active' => '上架', 'inactive' => '下架', 'has_been_inactive' => '该商品已下架', - 'minimum_order' => '起订量' + 'minimum_order' => '起订量', + 'minimum_order_error' => '采购数量必须大于等于:num' ]; diff --git a/themes/default/product/product.blade.php b/themes/default/product/product.blade.php index 55138725..798d9810 100644 --- a/themes/default/product/product.blade.php +++ b/themes/default/product/product.blade.php @@ -221,12 +221,18 @@ @endif @hookwrapper('product.detail.sku') -
SKU:@{{ product.sku }}
+
+ SKU:@{{ product.sku }} +
@endhookwrapper @hookwrapper('product.detail.model')
{{ __('shop/products.model') }}: @{{ product.model }}
@endhookwrapper + +
+ {{__('product.minimum_order')}}: @{{ minimum_order }} +
@if (0)
@@ -589,6 +595,7 @@ product_id: "{{$product_id}}", price_setting: @json($product['price_setting'] ?? 'sku'), numPrices: @json($product['numPrices'] ?? []), + minimum_order: @json($product['minimum_order'] ?? 0), centerDialogVisable: false, // 设置显示框的状态 registerForm: { // 添加的信息 contacts: '', @@ -833,6 +840,11 @@ layer.msg('{{ __('shop/products.quantity_error') }}'); return; } + // 判断:当前商品购买数量是否大于等于最小起订量 + if(_this.minimum_order > total){ + layer.msg('{{ __('product.minimum_order_error',['num'=>$product['minimum_order']]) }}'); + return; + } // 请求参数 params = { isBuyNow, @@ -845,6 +857,11 @@ layer.msg('{{ __('shop/products.quantity_error') }}'); return; } + // 判断:当前商品购买数量是否大于等于最小起订量 + if(_this.minimum_order > _this.quantity){ + layer.msg('{{ __('product.minimum_order_error',['num'=>$product['minimum_order']]) }}'); + return; + } // 请求参数 params = { sku_id: _this.product.id, @@ -856,6 +873,13 @@ 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) {