From 16b7519258d7d817f2ec1e75f37bf9f7ad92982d Mon Sep 17 00:00:00 2001 From: pushuo <229102104@qq.com> Date: Wed, 10 Aug 2022 19:08:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A1=B5=E5=B0=BE=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Middleware/ShareViewData.php | 7 ++ .../Http/Controllers/BrandController.php | 9 +- beike/Repositories/BrandRepo.php | 14 +-- public/build/beike/admin/js/app.js | 22 +++-- resources/beike/admin/js/common.js | 20 +++-- .../builder/component/link_selector.blade.php | 32 +++++-- .../pages/design/builder/footer.blade.php | 12 +-- .../pages/design/builder/index.blade.php | 2 +- .../beike/admin/views/pages/setting.blade.php | 2 +- themes/default/layout/footer.blade.php | 90 +++++++++---------- 10 files changed, 126 insertions(+), 84 deletions(-) diff --git a/app/Http/Middleware/ShareViewData.php b/app/Http/Middleware/ShareViewData.php index af77a8f5..cef1a048 100644 --- a/app/Http/Middleware/ShareViewData.php +++ b/app/Http/Middleware/ShareViewData.php @@ -1,4 +1,11 @@ + * @Date 2022-08-10 16:45:58 + * @LastEditTime 2022-08-10 17:03:40 + */ /** * ShareViewData.php * diff --git a/beike/Admin/Http/Controllers/BrandController.php b/beike/Admin/Http/Controllers/BrandController.php index 3482fe84..85eb1c83 100644 --- a/beike/Admin/Http/Controllers/BrandController.php +++ b/beike/Admin/Http/Controllers/BrandController.php @@ -1,4 +1,11 @@ + * @Date 2022-08-02 19:19:52 + * @LastEditTime 2022-08-10 19:07:07 + */ /** * BrandController.php * @@ -56,7 +63,7 @@ class BrandController extends Controller public function autocomplete(Request $request): array { - $brands = BrandRepo::autocomplete($request->get('name') ?? ''); + $brands = BrandRepo::autocomplete($request->get('name') ?? '', 0); return json_success('获取成功!', $brands); } diff --git a/beike/Repositories/BrandRepo.php b/beike/Repositories/BrandRepo.php index 176d7b2c..4eab90a0 100644 --- a/beike/Repositories/BrandRepo.php +++ b/beike/Repositories/BrandRepo.php @@ -104,14 +104,16 @@ class BrandRepo return $results; } - public static function autocomplete($name) + public static function autocomplete($name, $onlyActive = 1) { - $brands = Brand::query() + $builder = Brand::query() ->where('name', 'like', "$name%") - ->where('status', 1) - ->select('id', 'name') - ->limit(10)->get(); - return $brands; + ->select('id', 'name', 'status'); + if ($onlyActive) { + $builder->where('status', 1); + } + + return $builder->limit(10)->get(); } /** diff --git a/public/build/beike/admin/js/app.js b/public/build/beike/admin/js/app.js index 1da0244a..4e5fc6d8 100644 --- a/public/build/beike/admin/js/app.js +++ b/public/build/beike/admin/js/app.js @@ -2168,13 +2168,6 @@ __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); -/* - * @copyright 2022 opencart.cn - All Rights Reserved. - * @link https://www.guangdawangluo.com - * @Author PS - * @Date 2022-08-09 09:39:34 - * @LastEditTime 2022-08-09 09:43:18 - */ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ fileManagerIframe: function fileManagerIframe(callback) { var base = document.querySelector('base').href; @@ -2199,6 +2192,21 @@ __webpack_require__.r(__webpack_exports__); }; } }); + }, + debounce: function debounce(fn, delay) { + var timeout = null; // 创建一个标记用来存放定时器的返回值 + + return function (e) { + var _arguments = arguments, + _this = this; + + // 每当用户输入的时候把前一个 setTimeout clear 掉 + clearTimeout(timeout); // 然后又创建一个新的 setTimeout, 这样就能保证interval 间隔内如果时间持续触发,就不会执行 fn 函数 + + timeout = setTimeout(function () { + fn.apply(_this, _arguments); + }, delay); + }; } }); diff --git a/resources/beike/admin/js/common.js b/resources/beike/admin/js/common.js index 213560cd..e064ba10 100644 --- a/resources/beike/admin/js/common.js +++ b/resources/beike/admin/js/common.js @@ -1,10 +1,3 @@ -/* - * @copyright 2022 opencart.cn - All Rights Reserved. - * @link https://www.guangdawangluo.com - * @Author PS - * @Date 2022-08-09 09:39:34 - * @LastEditTime 2022-08-09 09:43:18 - */ export default { fileManagerIframe(callback) { const base = document.querySelector('base').href; @@ -31,4 +24,17 @@ export default { } }); }, + + debounce(fn, delay) { + var timeout = null; // 创建一个标记用来存放定时器的返回值 + + return function (e) { + // 每当用户输入的时候把前一个 setTimeout clear 掉 + clearTimeout(timeout); + // 然后又创建一个新的 setTimeout, 这样就能保证interval 间隔内如果时间持续触发,就不会执行 fn 函数 + timeout = setTimeout(() => { + fn.apply(this, arguments); + }, delay); + } + }, } \ No newline at end of file diff --git a/resources/beike/admin/views/pages/design/builder/component/link_selector.blade.php b/resources/beike/admin/views/pages/design/builder/component/link_selector.blade.php index bf5c3f48..333e4926 100644 --- a/resources/beike/admin/views/pages/design/builder/component/link_selector.blade.php +++ b/resources/beike/admin/views/pages/design/builder/component/link_selector.blade.php @@ -111,6 +111,13 @@ default: false }, + hideTypes: { + type: Array, + default: function () { + return []; + } + }, + type: { default: null }, @@ -125,8 +132,8 @@ types: [ {type: 'product',label: '商品'}, {type: 'category',label: '分类'}, - // {type: 'information',label: ''}, - // {type: 'manufacturer',label: '品牌'}, + {type: 'page',label: '信息页面'}, + {type: 'brand', label: '品牌'}, {type: 'static',label: '固定连接'}, // {type: 'blog',label: '博客'}, {type: 'custom',label: '自定义'} @@ -150,6 +157,11 @@ beforeMount() { this.updateData(); + if (this.hideTypes.length) { + this.types = this.types.filter((item) => { + return this.hideTypes.indexOf(item.type) == -1; + }); + } }, watch: { @@ -179,8 +191,8 @@ case 'category': url = '{{ admin_route('categories.index') }}'; break; - case 'manufacturer': - url = '/'; + case 'brand': + url = ''; break; default: null; @@ -267,8 +279,8 @@ case 'category': url = 'categories/autocomplete?name='; break; - case 'manufacturer': - url = ''; + case 'brand': + url = 'brands/autocomplete?name='; break; default: null; @@ -296,11 +308,13 @@ } if (!this.link.value) return; - if (this.link.type == 'customer') return this.name = this.link.value; + if (this.link.type == 'custom') return this.name = this.link.value; if (this.link.type == 'static') { if (this.static.find(e => e.value == this.link.value)) { this.name = this.static.find(e => e.value == this.link.value).name; } + + return; } this.nameLoading = true; @@ -314,8 +328,8 @@ case 'category': url = `categories/${this.link.value}/name`; break; - case 'manufacturer': - url = ''; + case 'brand': + url = `brands/${this.link.value}/name`; break; default: null; diff --git a/resources/beike/admin/views/pages/design/builder/footer.blade.php b/resources/beike/admin/views/pages/design/builder/footer.blade.php index 04e3b12e..97dd1efe 100644 --- a/resources/beike/admin/views/pages/design/builder/footer.blade.php +++ b/resources/beike/admin/views/pages/design/builder/footer.blade.php @@ -97,7 +97,7 @@ - +
@@ -141,7 +141,7 @@