From 83be5a7c0be2fc12290318eb2b45a036cdbc67f3 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Wed, 8 Apr 2026 16:26:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20mobile=E7=AB=AFclassify=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/controller/Product.php | 69 +- app/index/route/route.php | 2 + app/index/view/mobile/product/category.html | 636 +++--------------- .../view/mobile/product/category0408.html | 93 --- app/index/view/mobile/product/classify.html | 380 +++++++++++ app/index/view/mobile/public/header.html | 8 +- 6 files changed, 539 insertions(+), 649 deletions(-) delete mode 100644 app/index/view/mobile/product/category0408.html create mode 100644 app/index/view/mobile/product/classify.html diff --git a/app/index/controller/Product.php b/app/index/controller/Product.php index fd93d7c3..0d86ca6d 100644 --- a/app/index/controller/Product.php +++ b/app/index/controller/Product.php @@ -149,7 +149,7 @@ class Product extends Common } } View::assign('list', $list); - + return View::fetch('category'); } // 产品分类 - 查看子类 @@ -267,6 +267,59 @@ class Product extends Common return View::fetch('subcategory'); } + + /** + * 单纯分类页 + */ + public function classify() + { + $pid = request()->param('id/d', 0); + + // 获取当前选中的父分类 + $parent = ProductCategoryModel::field(['id', 'name'])->find($pid); + View::assign('parent', $parent); + + // 获取分类及产品信息 + $categorys = ProductCategoryModel::field(['id', 'pid', 'name', 'path', 'level']) + ->language($this->lang_id) + ->displayed(true) + ->children($pid) + ->order(['pid' => 'asc', 'sort' => 'asc', 'id' => 'desc']) + ->select() + ->toArray(); + + // 组装第三级分类所属产品数据 + $lv3_id_arr = array_column(array_filter($categorys, fn($item)=> $item['level'] === 3), 'id'); + $products = ProductModel::field([ + 'id', + 'category_id', + 'name', + 'short_name', + 'cover_image', + 'spu' + ]) + ->byCategory($lv3_id_arr) + ->language($this->lang_id) + ->enabled(true) + ->onSale(true) + ->onShelves(true) + ->select() + ->toArray(); + $product_groups = []; + foreach ($products as $product) { + $product_groups[$product['category_id']][] = $product; + } + foreach ($categorys as $key => $category) { + if ($category['level'] < 3) continue; + $categorys[$key]['products'] = $product_groups[$category['id']] ?? []; + } + + $tree = array_to_tree($categorys, $pid); + View::assign('categorys', $tree); + + return View::fetch('classify'); + } + /** * 产品搜索 */ @@ -329,7 +382,7 @@ class Product extends Common ->bypk($param['id']) ->find(); View::assign('product', $product); - + $product_categorys = []; $product_params = []; $product_skus = []; @@ -352,7 +405,7 @@ class Product extends Common ->order(['id' => 'asc']) ->select() ->toArray(); - + // 获取产品参数信息 $product_params = ProductParamsModel::field(['id', 'name', 'value']) ->byProductId($product['id']) @@ -375,7 +428,7 @@ class Product extends Common $attrs = ProductAttrModel::bypks(array_unique(Arr::pluck($sku_attrs, 'attr_id')))->column(['attr_name'], 'id'); foreach ($sku_attrs as $v) { if (empty($v['attr_value'])) continue; - + $v['attr_name'] = $attrs[$v['attr_id']]?? ''; // 按属性分组 $product_sku_attrs[$v['attr_id']]['attr_id'] = $v['attr_id']; @@ -422,8 +475,8 @@ class Product extends Common // 获取询盘可选国家 $config = $this->basic_config['optional_country_for_product_inquiry']; - View::assign('country_list', explode(',', preg_replace('/\r?\n/', ',', $config['value']?? ''))); - + View::assign('country_list', explode(',', preg_replace('/\r?\n/', ',', $config['value']?? ''))); + return View::fetch('detail'); } @@ -535,7 +588,7 @@ class Product extends Common if ($val['level'] != 2) { continue; } - + foreach ($pro_map as $k => $pro) { if (in_array($val['id'], explode(',', strval($k)))) { $newpros[] = [ @@ -549,7 +602,7 @@ class Product extends Common } } View::assign('newpros', $newpros); - + return View::fetch('newpro'); } } diff --git a/app/index/route/route.php b/app/index/route/route.php index 68203058..af41b7c0 100644 --- a/app/index/route/route.php +++ b/app/index/route/route.php @@ -18,6 +18,8 @@ Route::group('product', function () { Route::get('category/:id', 'Product/category'); // 产品分类 - 查看子类 Route::get('subcategory/:id', 'Product/subcategory'); + // 单纯分类页 + Route::get('classify/:id', 'Product/classify'); // 产品详情页 Route::get('detail/:id', 'Product/detail'); // 产品询盘 diff --git a/app/index/view/mobile/product/category.html b/app/index/view/mobile/product/category.html index 0406771d..7939e03a 100644 --- a/app/index/view/mobile/product/category.html +++ b/app/index/view/mobile/product/category.html @@ -1,545 +1,93 @@ - - - - - - - ORICO 移动硬盘 - - - - - - - -
-
-
- -
-
数据存储
-
-
-
- - - - -
- -
-
-
固态硬盘
-
- -
-
-
-
-
- -
-
-
-
M.2 NVMe 固态硬盘
-
-
ORICO-SSD1T
-
-
-
-
- - -
- -
-
-
磁吸移动硬盘
-
- -
-
-
-
-
- -
-
-
PS5 M.2固态硬盘测试专用九五二七
-
ORICO-e7450
-
-
-
-
- -
-
-
PS5 M.2固态硬盘
-
ORICO-e7450
-
-
-
-
- - -
-
-
桌面移动硬盘
-
-
-
-
-
- -
-
-
3.5英寸桌面硬盘
-
ORICO-3588
-
-
-
-
-
- - -
-
-
内存条
-
-
-
-
-
- -
-
-
DDR4 16G 内存
-
ORICO-RAM
-
-
-
-
- - -
-
-
NAS存储
-
-
-
-
-
- -
-
-
4盘位NAS机箱
-
ORICO-NAS
-
-
-
-
- - -
-
-
U盘/闪存卡
-
-
-
-
-
- -
-
-
高速U盘 128G
-
ORICO-U128
-
-
-
-
- - -
-
-
混合存储
-
-
-
-
-
- -
-
-
多功能扩展坞
-
ORICO-DOCK
-
-
-
-
- -
-
- - - - - -
- -
- - - - - - \ No newline at end of file + }); + $(document).on('mouseup touchend', function() { + isDragging = false; + }); + }); + +{/block} \ No newline at end of file diff --git a/app/index/view/mobile/product/category0408.html b/app/index/view/mobile/product/category0408.html deleted file mode 100644 index 7939e03a..00000000 --- a/app/index/view/mobile/product/category0408.html +++ /dev/null @@ -1,93 +0,0 @@ -{extend name="public/base" /} -{block name="style"} - -{/block} -{block name="main"} -
- - {notempty name="focus_image"} -
- {volist name="focus_image" id="fi"} - - - - {/volist} -
- {/notempty} -
- -
-
- -
-
- - {volist name="list" id="vo"} -
- -
- {notempty name="vo.products"} - - {/notempty} -
-
- {/volist} -
-
-{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/app/index/view/mobile/product/classify.html b/app/index/view/mobile/product/classify.html new file mode 100644 index 00000000..ebd0c3ce --- /dev/null +++ b/app/index/view/mobile/product/classify.html @@ -0,0 +1,380 @@ +{extend name="public/base" /} + +{block name="style"} + + +{/block} + +{block name="main"} + +
+
+
+ +
+
{$parent.name|default=''}
+
+
+
+ + {if condition="!empty($categorys)"} + + + +
+ {volist name="categorys" id="category"} +
+ {if condition="!empty($category.children)"} + {volist name="$category.children" id="child"} +
+
+
{$child.name}
+
+ +
+
+ {if condition="!empty($child.products)"} +
+ {volist name="$child.products" id="pro"} +
+
+ +
+
+
{$pro.name}
+
{$pro.spu}
+
+
+ {/volist} +
+ {/if} +
+ {/volist} + {/if} +
+ {/volist} +
+ {/if} +
+{/block} + +{block name="script"} + + +{/block} diff --git a/app/index/view/mobile/public/header.html b/app/index/view/mobile/public/header.html index 33f651b1..22b10417 100644 --- a/app/index/view/mobile/public/header.html +++ b/app/index/view/mobile/public/header.html @@ -324,7 +324,7 @@ height: 14px; cursor: pointer; opacity: 0.6; - + } .search-clear-box { padding-right: 10px; @@ -449,7 +449,7 @@ {if condition="!empty($header_categorys)"} {/if} @@ -529,7 +529,7 @@
- +
@@ -872,7 +872,7 @@ searchClearBtn.style.display = 'none'; } - } + } }12 searchSubmit.addEventListener('click', function (e) {