From faca5683fc62f93a41a9e077f42554f611077b50 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 13 May 2025 09:58:26 +0800 Subject: [PATCH 01/26] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E8=A1=A8=E5=8F=8A=E4=BA=A7=E5=93=81=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E8=A1=A8=E7=9B=B8=E5=BA=94=E5=AD=97=E6=AE=B5=E9=95=BF=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database/migrations/20241218064708_create_product.php | 4 ++-- database/migrations/20241218083326_create_product_params.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/database/migrations/20241218064708_create_product.php b/database/migrations/20241218064708_create_product.php index 937f3f2d..c17add8a 100644 --- a/database/migrations/20241218064708_create_product.php +++ b/database/migrations/20241218064708_create_product.php @@ -32,7 +32,7 @@ class CreateProduct extends Migrator ->addColumn('category_id', 'integer', ['signed' => false , 'null' => true, 'comment' => '分类ID']) ->addColumn('spu', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '产品规格']) ->addColumn('name', 'string', ['limit' => 125, 'null' => false, 'default' => '', 'comment' => '产品名称']) - ->addColumn('short_name', 'string', ['limit' => 64, 'null' => false, 'default' => '', 'comment' => '产品简称']) + ->addColumn('short_name', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '产品简称']) ->addColumn('cover_image', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '产品封面图片']) ->addColumn('desc', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '产品描述']) ->addColumn('video_img', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '产品视频封面']) @@ -47,7 +47,7 @@ class CreateProduct extends Migrator ->addColumn('status', 'boolean', ['null' => false, 'default' => 1, 'comment' => '状态:1启用,-1禁用']) ->addColumn('seo_title', 'string', ['limit' => 255, 'default' => null, 'comment' => 'seo标题']) ->addColumn('seo_keywords', 'string', ['limit' => 255, 'default' => null, 'comment' => 'seo关建词']) - ->addColumn('seo_desc', 'string', ['limit' => 255, 'default' => null, 'comment' => 'seo描述']) + ->addColumn('seo_desc', 'string', ['limit' => 512, 'default' => null, 'comment' => 'seo描述']) ->addColumn('created_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) ->addColumn('updated_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'update' => 'CURRENT_TIMESTAMP', 'comment' => '更新时间']) ->addColumn('deleted_at', 'timestamp', ['null' => true, 'comment' => '删除时间']) diff --git a/database/migrations/20241218083326_create_product_params.php b/database/migrations/20241218083326_create_product_params.php index ba79599c..267f1629 100644 --- a/database/migrations/20241218083326_create_product_params.php +++ b/database/migrations/20241218083326_create_product_params.php @@ -30,7 +30,7 @@ class CreateProductParams extends Migrator $table = $this->table('product_params', ['engine' => 'InnoDB', 'comment' => '产品参数表']); $table->addColumn('product_id', 'integer', ['signed' => false , 'null' => false, 'comment' => '产品ID']) ->addColumn('name', 'string', ['limit' => 125, 'null' => false, 'default' => '', 'comment' => '参数名']) - ->addColumn('value', 'string', ['limit' => 125, 'null' => false, 'default' => '', 'comment' => '参数值']) + ->addColumn('value', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '参数值']) ->addColumn('created_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间']) ->addColumn('updated_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'update' => 'CURRENT_TIMESTAMP', 'comment' => '更新时间']) ->create(); From f7551cad0d64338705b549b335cb22bfc18c64ec Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 13 May 2025 10:19:56 +0800 Subject: [PATCH 02/26] =?UTF-8?q?refactor:=20=E6=96=B0=E5=A2=9E=E4=BE=9D?= =?UTF-8?q?=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 51f53e19..5f3d933c 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,8 @@ }, "require-dev": { "symfony/var-dumper": ">=4.2", - "topthink/think-trace": "^1.0" + "topthink/think-trace": "^1.0", + "swoole/ide-helper": "^6.0" }, "autoload": { "psr-4": { From 54a0175efac9b6c7032bb23f583522a591192025 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 13 May 2025 15:47:38 +0800 Subject: [PATCH 03/26] =?UTF-8?q?feat:=20=E4=BA=A7=E5=93=81=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/controller/Product.php | 33 ++++++++++++++++++++ app/index/model/ProductModel.php | 7 +++++ app/index/view/product/search.html | 50 +++++++++++++++++------------- 3 files changed, 68 insertions(+), 22 deletions(-) diff --git a/app/index/controller/Product.php b/app/index/controller/Product.php index 080502bd..f18ad2d8 100644 --- a/app/index/controller/Product.php +++ b/app/index/controller/Product.php @@ -154,6 +154,39 @@ class Product extends Common return View::fetch('category'); } + /** + * 产品搜索 + */ + public function search() + { + $keywords = request()->param('keywords', ''); + + // 关键词搜索 + $products = ProductModel::field([ + 'id', + 'name', + 'short_name', + 'cover_image', + 'spu' + ]) + ->where(fn ($query) => $query->withSearch(['keywords'], ['keywords' => $keywords])) + ->language($this->lang_id) + ->enabled(true) + ->onSale(true) + ->onShelves(true) + ->order(['sort' => 'asc', 'id' => 'desc']) + ->select() + ->each(function ($item) use($keywords) { + $item['spu'] = str_replace($keywords, ''.$keywords.'', $item['spu']); + $item['name'] = str_replace($keywords, ''.$keywords.'', $item['name']); + $item['short_name'] = str_replace($keywords, ''.$keywords.'', $item['short_name']); + return $item; + }); + View::assign('products', $products); + + return View::fetch('search'); + } + /** * 产品详情页 */ diff --git a/app/index/model/ProductModel.php b/app/index/model/ProductModel.php index e5d18164..5b8a74f3 100644 --- a/app/index/model/ProductModel.php +++ b/app/index/model/ProductModel.php @@ -4,6 +4,7 @@ declare (strict_types = 1); namespace app\index\model; use app\common\model\ProductBaseModel; +use think\facade\Db; use think\model\concern\SoftDelete; /** @@ -74,4 +75,10 @@ class ProductModel extends ProductBaseModel { $query->where('is_new', '=', (int)$stat); } + + // 关键词搜索 + public function searchKeywordsAttr($query, string $keywords) + { + $query->whereRaw('BINARY spu LIKE "%' . $keywords . '%" OR BINARY name LIKE "%' . $keywords . '%" OR BINARY short_name LIKE "%' . $keywords . '%"'); + } } diff --git a/app/index/view/product/search.html b/app/index/view/product/search.html index 0d52260e..2356987d 100644 --- a/app/index/view/product/search.html +++ b/app/index/view/product/search.html @@ -5,27 +5,33 @@ {block name="main"}
-
Store
+ {notempty name="basic_config['navigation_store_url']['value']"}
+
+
{:lang('header_navigation.store')}
+
+ {/notempty}
From 5a80eef8490f71be81dec072d374bbc7389b3766 Mon Sep 17 00:00:00 2001
From: jsasg <735273025@qq.com>
Date: Wed, 14 May 2025 11:23:11 +0800
Subject: [PATCH 06/26] =?UTF-8?q?refactor:=20=E8=B0=83=E6=95=B4=E6=95=B0?=
=?UTF-8?q?=E6=8D=AE=E5=AD=97=E6=AE=B5=E9=95=BF=E5=BA=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
database/migrations/20241218064708_create_product.php | 2 +-
database/migrations/20241218083326_create_product_params.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/database/migrations/20241218064708_create_product.php b/database/migrations/20241218064708_create_product.php
index c17add8a..0d9b680f 100644
--- a/database/migrations/20241218064708_create_product.php
+++ b/database/migrations/20241218064708_create_product.php
@@ -31,7 +31,7 @@ class CreateProduct extends Migrator
$table->addColumn('language_id', 'integer', ['signed' => false, 'null' => false, 'comment' => '语言ID'])
->addColumn('category_id', 'integer', ['signed' => false , 'null' => true, 'comment' => '分类ID'])
->addColumn('spu', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '产品规格'])
- ->addColumn('name', 'string', ['limit' => 125, 'null' => false, 'default' => '', 'comment' => '产品名称'])
+ ->addColumn('name', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '产品名称'])
->addColumn('short_name', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '产品简称'])
->addColumn('cover_image', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '产品封面图片'])
->addColumn('desc', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '产品描述'])
diff --git a/database/migrations/20241218083326_create_product_params.php b/database/migrations/20241218083326_create_product_params.php
index 267f1629..d1256376 100644
--- a/database/migrations/20241218083326_create_product_params.php
+++ b/database/migrations/20241218083326_create_product_params.php
@@ -30,7 +30,7 @@ class CreateProductParams extends Migrator
$table = $this->table('product_params', ['engine' => 'InnoDB', 'comment' => '产品参数表']);
$table->addColumn('product_id', 'integer', ['signed' => false , 'null' => false, 'comment' => '产品ID'])
->addColumn('name', 'string', ['limit' => 125, 'null' => false, 'default' => '', 'comment' => '参数名'])
- ->addColumn('value', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '参数值'])
+ ->addColumn('value', 'string', ['limit' => 1024, 'null' => false, 'default' => '', 'comment' => '参数值'])
->addColumn('created_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间'])
->addColumn('updated_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'update' => 'CURRENT_TIMESTAMP', 'comment' => '更新时间'])
->create();
From 81bcf589b024f81695138466e23bf6042820d6d2 Mon Sep 17 00:00:00 2001
From: jsasg <735273025@qq.com>
Date: Wed, 14 May 2025 11:24:02 +0800
Subject: [PATCH 07/26] =?UTF-8?q?refactor:=20=E9=A6=96=E9=A1=B5=E5=93=81?=
=?UTF-8?q?=E7=89=8C=E6=95=85=E4=BA=8B=E5=B9=B4=E4=BB=BD=E6=98=BE=E7=A4=BA?=
=?UTF-8?q?=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/index/controller/Index.php | 10 +++++++++-
app/index/view/index/index.html | 6 +++---
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/app/index/controller/Index.php b/app/index/controller/Index.php
index ab7610d2..a94b6c43 100644
--- a/app/index/controller/Index.php
+++ b/app/index/controller/Index.php
@@ -19,6 +19,7 @@ class Index extends Common
*/
public function index()
{
+
// 获取banner数据
$banner = $this->getBannerData();
View::assign('focus_images', $banner['focus_images']);
@@ -26,7 +27,14 @@ class Index extends Common
View::assign('featured_topics', $banner['featured_topics']);
View::assign('video', array_shift($banner['video']));
View::assign('scenes', $banner['scenes']);
- View::assign('brand_story', $banner['brand_story']);
+ View::assign('brand_story', array_map(function($item) {
+ $item['year'] = '';
+ $arr = explode('-', $item['title']);
+ if (count($arr) > 1) {
+ $item['year'] = $arr[0];
+ }
+ return $item;
+ }, $banner['brand_story']??null));
View::assign('data_statistics', $banner['data_statistics']);
// 获取明星产品/热点产品
diff --git a/app/index/view/index/index.html b/app/index/view/index/index.html
index 9b56b029..4ba629f5 100644
--- a/app/index/view/index/index.html
+++ b/app/index/view/index/index.html
@@ -167,9 +167,9 @@
From 569d8277667ffebb8d5b33ce56ffd0ae6cd63540 Mon Sep 17 00:00:00 2001
From: jsasg <735273025@qq.com>
Date: Wed, 14 May 2025 11:30:04 +0800
Subject: [PATCH 08/26] =?UTF-8?q?style:=20=E6=A0=BC=E5=BC=8F=E9=97=AE?=
=?UTF-8?q?=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/index/view/public/base.html | 4 ++--
app/index/view/public/footer.html | 5 +++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/app/index/view/public/base.html b/app/index/view/public/base.html
index ec2f923d..829b6c34 100644
--- a/app/index/view/public/base.html
+++ b/app/index/view/public/base.html
@@ -16,8 +16,8 @@
-
-
+
+
{block name="header"}
diff --git a/app/index/view/public/footer.html b/app/index/view/public/footer.html
index 6c2a0bd9..fdfb318b 100644
--- a/app/index/view/public/footer.html
+++ b/app/index/view/public/footer.html
@@ -67,8 +67,9 @@
@@ -11,6 +12,7 @@
Need to contact us? Just send us an e-mail at odmmarket@orico.com.cn