diff --git a/beike/Helpers.php b/beike/Helpers.php index 417a2c11..325e71ee 100644 --- a/beike/Helpers.php +++ b/beike/Helpers.php @@ -151,7 +151,11 @@ function type_route($type, $value): string } elseif ($type == 'static') { return shop_route($value); } elseif ($type == 'custom') { - return $value; + if (Str::startsWith($value, ['http://', 'https://'])) { + return $value; + } else { + return "//{$value}"; + } } return ''; diff --git a/beike/Repositories/ProductRepo.php b/beike/Repositories/ProductRepo.php index b7e0dd0d..4ad9d474 100644 --- a/beike/Repositories/ProductRepo.php +++ b/beike/Repositories/ProductRepo.php @@ -244,8 +244,8 @@ class ProductRepo public static function getFilterPrice($data) { $selectPrice = $data['price'] ?? '-'; - unset($data['price']); - $builder = self::getBuilder($data)->leftJoin('product_skus as ps', 'products.id', 'ps.product_id') + // unset($data['price']); + $builder = self::getBuilder(['category_id' => $data['category_id']])->leftJoin('product_skus as ps', 'products.id', 'ps.product_id') ->where('ps.is_default', 1); $min = $builder->min('ps.price'); $max = $builder->max('ps.price'); diff --git a/resources/beike/admin/css/_global.scss b/resources/beike/admin/css/_global.scss index 2383cdb0..87b1f944 100644 --- a/resources/beike/admin/css/_global.scss +++ b/resources/beike/admin/css/_global.scss @@ -80,6 +80,10 @@ } } +.max-h-100 { + max-height: 100%; +} + .col-form-label.required { &::before { content: "*"; diff --git a/resources/beike/admin/css/_page-product.scss b/resources/beike/admin/css/_page-product.scss index bd743dd5..b836e353 100644 --- a/resources/beike/admin/css/_page-product.scss +++ b/resources/beike/admin/css/_page-product.scss @@ -21,6 +21,12 @@ body.page-product-form { } } + .batch-setting { + .form-control { + max-width: 100px; + } + } + .variant-value-img { width: 22px; height: 22px; 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 72dd7040..c2c691e7 100644 --- a/resources/beike/admin/views/pages/products/form/form.blade.php +++ b/resources/beike/admin/views/pages/products/form/form.blade.php @@ -62,7 +62,7 @@ :list="form.images" :options="{animation: 200, handle: '.product-item'}" > -
+
@@ -168,7 +168,29 @@ {{ __('admin/product.add_variable') }}
-
+
+
+
+ +
+
+ + +
+ + + + + + + +
+
@@ -200,7 +222,7 @@ -
+
- + skus ?? []), }, + variablesBatch: { + variables: [], + model: '', + sku: '', + price: '', + origin_price: '', + cost_price: '', + quantity: '', + image: '', + status: false, + }, + relations: { keyword: '', products: @json($relations ?? []), @@ -491,6 +525,7 @@ rules: {} }, + computed: { // variant value 重复次数 variantValueRepetitions() { @@ -509,6 +544,13 @@ return (this.form.skus.length && this.form.skus[0].variants.length) || '' } }, + + beforeMount() { + if (this.form.variables.length) { + this.variablesBatch.variables = this.form.variables.map((v, i) => ''); + } + }, + watch: { 'source.variables': { deep: true, @@ -525,13 +567,27 @@ } this.form.variables = variants; + // 在 variablesBatch.variables 生成对应的 variants 的index + this.variablesBatch.variables = variants.map((v, i) => ''); if (this.isMove) return; this.remakeSkus(); } } }, + methods: { + // 表单提交,检测是否开启多规格 做处理 + productsSubmit() { + if (!this.editing.isVariable) { + this.source.variables = []; + } + + setTimeout(() => { + $('form#app').submit(); + }, 0); + }, + relationsQuerySearch(keyword, cb) { $http.get('products/autocomplete?name=' + encodeURIComponent(keyword), null, {hload:true}).then((res) => { cb(res.data); @@ -550,9 +606,9 @@ }, isVariableChange(e) { - if (!e) { - this.source.variables = []; - } + // if (!e) { + // this.source.variables = []; + // } }, variantIsImage(e, index) { @@ -563,6 +619,12 @@ } }, + batchSettingVariantImage() { + bk.fileManagerIframe(images => { + this.variablesBatch.image = images[0].path; + }) + }, + addProductImages(skuIndex) { bk.fileManagerIframe(images => { if (!isNaN(skuIndex)) { @@ -585,6 +647,61 @@ this.form.skus[variantIndex].images.splice(index, 1) }, + batchSettingVariant() { + // 要修改的 skuIndex 下标 + let setSkuIndex = []; + + this.form.skus.forEach((sku, skuIndex) => { + this.variablesBatch.variables.forEach((variantIndex, index) => { + if (variantIndex !== '') { + // 根据 variantIndex, index,修改 sku.variants[index] 的值 + if (sku.variants[index] == variantIndex) { + setSkuIndex.push(skuIndex); + } + + return; + } + + // 如果 variantIndex 全部为空,就把所有的 skuIndex 都加入到 setSkuIndex 中 + if (this.variablesBatch.variables.every(v => v === '')) { + setSkuIndex.push(skuIndex); + } + }) + + // 修改 skuIndex 下标对应的 sku + setSkuIndex.forEach((index) => { + if (this.variablesBatch.model) { + this.form.skus[index].model = this.variablesBatch.model + '-' + (index + 1); + } + if (this.variablesBatch.sku) { + this.form.skus[index].sku = this.variablesBatch.sku + '-' + (index + 1); + } + if (this.variablesBatch.image) { + this.form.skus[index].images = [this.variablesBatch.image]; + } + if (this.variablesBatch.price) { + this.form.skus[index].price = this.variablesBatch.price; + } + if (this.variablesBatch.origin_price) { + this.form.skus[index].origin_price = this.variablesBatch.origin_price; + } + if (this.variablesBatch.cost_price) { + this.form.skus[index].cost_price = this.variablesBatch.cost_price; + } + if (this.variablesBatch.quantity) { + this.form.skus[index].quantity = this.variablesBatch.quantity; + } + }) + }) + + // this.variablesBatch 对象内除了 variables 之外的值都清空 + for (let key in this.variablesBatch) { + if (key !== 'variables') { + this.variablesBatch[key] = ''; + } + } + }, + dialogVariablesFormSubmit(form) { const name = JSON.parse(JSON.stringify(this.dialogVariables.form.name)); const variantIndex = this.dialogVariables.variantIndex; diff --git a/resources/beike/shop/default/css/header.scss b/resources/beike/shop/default/css/header.scss index e2f1d18e..dc3b0f2c 100644 --- a/resources/beike/shop/default/css/header.scss +++ b/resources/beike/shop/default/css/header.scss @@ -267,7 +267,6 @@ header { #offcanvas-right-cart { .select-wrap { - flex: 1; margin-right: 10px; cursor: pointer; diff --git a/resources/beike/shop/default/css/page-categories.scss b/resources/beike/shop/default/css/page-categories.scss index b669437a..ba170687 100644 --- a/resources/beike/shop/default/css/page-categories.scss +++ b/resources/beike/shop/default/css/page-categories.scss @@ -151,7 +151,8 @@ body.page-categories { list-style: none; li { - margin-top: 0; + line-height: 1; + margin: 16px 0; ul { margin-top: 8px; diff --git a/resources/lang/en/common.php b/resources/lang/en/common.php index 78beeb94..e7c20c33 100644 --- a/resources/lang/en/common.php +++ b/resources/lang/en/common.php @@ -76,6 +76,7 @@ return [ 'text_list' => 'List', 'text_form' => 'From', 'text_to' => 'To', + 'batch_setting' => 'Batch setting', 'id' => 'ID', 'created_at' => 'Created At', diff --git a/resources/lang/zh_cn/common.php b/resources/lang/zh_cn/common.php index 0088ce1f..5d6c8a39 100644 --- a/resources/lang/zh_cn/common.php +++ b/resources/lang/zh_cn/common.php @@ -76,6 +76,7 @@ return [ 'text_list' => '列表', 'text_form' => '从', 'text_to' => '到', + 'batch_setting' => '批量设置', 'id' => 'ID', 'created_at' => '创建时间', diff --git a/resources/lang/zh_hk/common.php b/resources/lang/zh_hk/common.php index b3ba7d51..fbd1b881 100644 --- a/resources/lang/zh_hk/common.php +++ b/resources/lang/zh_hk/common.php @@ -75,6 +75,7 @@ return [ 'text_list' => '列表', 'text_form' => '從', 'text_to' => '到', + 'batch_setting' => '批量設置', 'id' => 'ID', 'created_at' => '創建時間', diff --git a/themes/default/product.blade.php b/themes/default/product.blade.php index d484a9ac..9a902691 100644 --- a/themes/default/product.blade.php +++ b/themes/default/product.blade.php @@ -55,7 +55,9 @@

{{ $product['name'] }}

@{{ product.price_format }}
-
@{{ product.origin_price_format }}
+
+ @{{ product.origin_price_format }} +