refactor: 附件

This commit is contained in:
2025-04-15 17:20:19 +08:00
parent 5936301e82
commit 551313bf23
11 changed files with 260 additions and 173 deletions

View File

@@ -4,6 +4,7 @@ declare (strict_types = 1);
namespace app\index\controller; namespace app\index\controller;
use app\index\model\AttachmentCategoryModel; use app\index\model\AttachmentCategoryModel;
use app\index\model\AttachmentModel;
use think\facade\View; use think\facade\View;
/** /**
@@ -11,13 +12,66 @@ use think\facade\View;
*/ */
class Attachment extends Common class Attachment extends Common
{ {
// 分页列表 /**
* 分页列表
*/
public function index() public function index()
{ {
// 获取分类 $param = request()->param([
$category = AttachmentCategoryModel::language($this->lang_id)->select(); 'id',
View::assign('category', $category); 'page/d' => 1,
'size/d' => 12,
]);
// 获取附件分类
$categorys = AttachmentCategoryModel::field([
'id',
'name'
])
->language($this->lang_id)
->parent(0)
->isShow(true)
->select();
View::assign('categorys', $categorys);
// 获取附件
$attachements = AttachmentModel::field([
'id',
'name',
'desc',
'image',
'applicable_to',
'support_platform',
'attach',
])
->language($this->lang_id)
->category($param['id']??null)
->paginate([
'list_rows' => $param['size'],
'page' => $param['page'],
]);
View::assign('attachements', $attachements);
View::assign('page', $attachements->render());
return View::fetch('index'); return View::fetch('index');
} }
/**
* 视频
*/
public function video()
{
// 获取附件分类
$categorys = AttachmentCategoryModel::field([
'id',
'name'
])
->language($this->lang_id)
->parent(0)
->isShow(true)
->select();
View::assign('categorys', $categorys);
return View::fetch('video');
}
} }

View File

@@ -33,9 +33,9 @@ return [
'detail_recommend' => 'Recommended for you', 'detail_recommend' => 'Recommended for you',
], ],
'attachment' => [ 'attachment' => [
'software_drives' => 'Software and Drivers', 'software_drives' => 'Software and Drivers',
'software_download' => 'Software Drives', 'video' => 'Videos',
'manual_download' => 'Manual', 'support_model' => 'Supported Models',
'video' => 'Videos' 'support_platform' => 'Supported Systems',
] ]
]; ];

View File

@@ -33,9 +33,9 @@ return [
'detail_recommend' => '你可能还喜欢', 'detail_recommend' => '你可能还喜欢',
], ],
'attachment' => [ 'attachment' => [
'software_drives' => '软件和驱动程序', 'software_drives' => '软件和驱动程序',
'software_download' => '软件下载', 'video' => '视频',
'manual_download' => '手册', 'support_model' => '支持型号',
'video' => '视频' 'support_platform' => '支持系统',
] ]
]; ];

View File

@@ -22,4 +22,16 @@ class AttachmentCategoryModel extends AttachmentCategoryBaseModel
{ {
return $query->where('language_id', '=', $language); return $query->where('language_id', '=', $language);
} }
// 上级id范围查询
public function scopeParent($query, $pid)
{
return $query->where('pid', '=', $pid);
}
// 是否显示状态范围查询
public function scopeIsShow($query, bool $is_show)
{
return $query->where('is_show', '=', (int)$is_show);
}
} }

View File

@@ -16,4 +16,24 @@ class AttachmentModel extends AttachmentBaseModel
use SoftDelete; use SoftDelete;
// 软删除时间字段名 // 软删除时间字段名
protected $deleteTime = 'deleted_at'; protected $deleteTime = 'deleted_at';
// 设置JSON字段
protected $json = ['attach'];
// 设置JSON数据返回数组
protected $jsonAssoc = true;
// 所属语言范围查询
public function scopeLanguage($query, $language)
{
$query->where('language_id', '=', $language);
}
// 所属分类范围查询
public function scopeCategory($query, $category)
{
if (is_null($category)) {
return;
}
$query->where('category_id', '=', $category);
}
} }

View File

@@ -0,0 +1,14 @@
<?php
declare (strict_types = 1);
namespace app\index\model;
use think\Model;
/**
* @mixin \think\Model
*/
class VideoCategoryModel extends Model
{
//
}

View File

@@ -0,0 +1,14 @@
<?php
declare (strict_types = 1);
namespace app\index\model;
use think\Model;
/**
* @mixin \think\Model
*/
class VideoModel extends Model
{
//
}

View File

@@ -36,7 +36,10 @@ Route::group('article', function() {
// 附件下载 // 附件下载
Route::group('attachment', function() { Route::group('attachment', function() {
// 软件驱动/手册
Route::get('index', 'Attachment/index'); Route::get('index', 'Attachment/index');
// 视频
Route::get('video', 'Attachment/video');
}); });
// 问答中心 // 问答中心

View File

@@ -20,147 +20,51 @@
</div> </div>
<!-- tab切换 --> <!-- tab切换 -->
<div class="tab"> <div class="tab">
<div class="tabit on">{:lang('attachment.software_download')}</div> {notempty name="categorys"}
<div class="tabit">{:lang('attachment.manual_download')}</div> {volist name="categorys" id="ca"}
<div class="tabit">{:lang('attachment.video')}</div> <a href="{:url('attachment/index', ['id' => $ca.id])}">
{if condition="(!$Request.has.id && $key == 0) || $Request.get.id == $ca.id"}
<div class="tabit on">
{else/}
<div class="tabit">
{/if}
{$ca.name}
</div>
</a>
{/volist}
{/notempty}
<a href="{:url('attachment/video')}"><div class="tabit">{:lang('attachment.video')}</div></a>
</div> </div>
<!-- 切换的内容 --> <!-- 切换的内容 -->
{notempty name="attachements"}
<div class="softlist"> <div class="softlist">
{volist name="attachements" id="att"}
<div class="softit"> <div class="softit">
<div class="left_img"><img src="downloadImg/10G.jpg" alt=""></div> <div class="left_img">
<img src="{$att.image}" alt="">
</div>
<div> <div>
<p class="title">Driver for USB-C 10Gb Ethernet Adapter</p> <p class="title">{$att.name}</p>
<p class="sub_title">Supported Models: </p> <p class="sub_title">{:lang('attachment.support_model')}: </p>
<p class="des">ORICO-REA-10</p> <p class="des">{$att.applicable_to}</p>
<p class="sub_title">Supported Systems: </p> <p class="sub_title">{:lang('attachment.support_platform')}: </p>
<p class="des">Windows 10-11, Linux</p> <p class="des">{$att.support_platform}</p>
<p> <p>
<a href="/uploads/download/2024/Linux-Driver.zip" data-cod="dl" data-id="332" {notempty name="att.attach"}
target="_blank"><span class="l_button">Linux</span></a> {volist name="att.attach" id="ch"}
<a href="/uploads/download/2024/Windows 10-11.zip" data-cod="dl" data-id="332" <a href="{$ch.file_path}" data-cod="dl" data-id="{$att.id}" target="_blank">
target="_blank"><span class="l_button">Windows 10-11</span></a> <span class="l_button">{$ch.btn_name}</span>
</a>
{/volist}
{/notempty}
</p> </p>
</div> </div>
</div> </div>
<div class="softit"> {/volist}
<div class="left_img"><img src="downloadImg/10G.jpg" alt=""></div> <div>{$page|raw}</div>
<div>
<p class="title">Driver for USB-C 10Gb Ethernet Adapter</p>
<p class="sub_title">Supported Models: </p>
<p class="des">ORICO-REA-10</p>
<p class="sub_title">Supported Systems: </p>
<p class="des">Windows 10-11, Linux</p>
<p>
<a href="/uploads/download/2024/Linux-Driver.zip" data-cod="dl" data-id="332"
target="_blank"><span class="l_button">Linux</span></a>
<a href="/uploads/download/2024/Windows 10-11.zip" data-cod="dl" data-id="332"
target="_blank"><span class="l_button">Windows 10-11</span></a>
</p>
</div>
</div>
<div class="softit">
<div class="left_img"><img src="downloadImg/10G.jpg" alt=""></div>
<div>
<p class="title">Driver for USB-C 10Gb Ethernet Adapter</p>
<p class="sub_title">Supported Models: </p>
<p class="des">ORICO-REA-10</p>
<p class="sub_title">Supported Systems: </p>
<p class="des">Windows 10-11, Linux</p>
<p>
<a href="/uploads/download/2024/Linux-Driver.zip" data-cod="dl" data-id="332"
target="_blank"><span class="l_button">Linux</span></a>
<a href="/uploads/download/2024/Windows 10-11.zip" data-cod="dl" data-id="332"
target="_blank"><span class="l_button">Windows 10-11</span></a>
</p>
</div>
</div>
<div class="Page">
<span class="p_page">
<a class="a_prev"></a>
<em class="num">
<a class="a_cur">1</a>
<a>2</a>
<a>3</a>
<a>4</a>
</em>
<a class="a_next"></a>
</span>
</div>
</div> </div>
<!-- VIDEO 切换 --> {/notempty}
<div class="vidotabs" style="display: none;">
<div class="hd">
<ul>
<li class="vli von">Data Storage</li>
<li class="vli">Power Transmission</li>
<li class="vli">Smart Life</li>
<li class="vli">Accessories</li>
</ul>
</div>
<!-- 视频内容 -->
<div class="bdconten">
<ul >
<dl class="video_hotul">
<dd>
<div class="hot1">
<video preload="none" controls="controls">
<source src="/uploads/uk/video/entertainment/RP1 .mp4" type="video/mp4">
</video>
</div>
<div class="htit">
<div class="htit1">ORICO RP1 Headphones</div>
<div class="htit2"> ORICO RP1 in-ear music headphones, skin-friendly and
comfortable for long time wearing; black, white, red and blue, four
colors for you to choose. ORICO 2169U3 full mesh 2.5 inch hard drive
enclosure, all-round heat-dissipation; compatible with SATA HDD below
9.5mm. </div>
</div>
</dd>
<dd>
<div class="hot1">
<video preload="none" controls="controls">
<source src="/uploads/uk/video/entertainment/BS16.mp4" type="video/mp4">
</video>
</div>
<div class="htit">
<div class="htit1">ORICO BS16 Bluetooth Speaker</div>
<div class="htit2"> ORICO BS16 unique and delicate pocket Bluetooth speaker,
bring you beautiful music; smaller size, unprecedented endurance. ORICO
2169U3 full mesh 2.5 inch hard drive enclosure, all-round
heat-dissipation; compatible with SATA HDD below 9.5mm. </div>
</div>
</dd>
<div class="clear"></div>
</dl>
<div id="page39">
<!-- 分页 s -->
<!-- 分页 e -->
</div>
</ul>
</div>
</div>
<!-- 如果切换的是 Videos-->
</div> </div>
</div> </div>
</div> </div>
{/block}
{block name="script"}
<script type="text/javascript">
$(document).ready(function() {
// 为所有具有 tabitme 类的元素添加点击事件
$('.tabit').click(function() {
// 移除所有 tabitme 元素的 on 类
$('.tabit').removeClass('on');
// 为当前点击的元素添加 on 类
$(this).addClass('on');
});
// 为所有具有 tabitme 类的元素添加点击事件
$('.vli').click(function() {
// 移除所有 tabitme 元素的 on 类
$('.vli').removeClass('von');
// 为当前点击的元素添加 on 类
$(this).addClass('von');
});
});
</script>
{/block} {/block}

View File

@@ -0,0 +1,90 @@
{extend name="public/base" /}
{block name="style"}
<link rel="stylesheet" href="__CSS__/download.css" />
{/block}
{block name="main"}
<div class="orico_Page_download">
<!-- 内容 -->
<div class="downloadMain">
<div class="topimg">
<img src="__IMAGES__/banner_01.png" />
<div class="banner_title">{:lang('attachment.software_drives')}</div>
</div>
<div class="contact_c">
<!-- 搜索 -->
<div class="search_all">
<input type="text" name="textfield" placeholder="Search model" id="search_software">
<div class="searchbtn" id="search-btn">
<img src="downloadImg/search.png" />
</div>
</div>
<!-- tab切换 -->
<div class="tab">
{notempty name="categorys"}
{volist name="categorys" id="ca"}
<a href="{:url('attachment/index', ['id' => $ca.id])}">
<div class="tabit">
{$ca.name}
</div>
</a>
{/volist}
{/notempty}
<div class="tabit on">{:lang('attachment.video')}</div>
</div>
<!-- VIDEO 切换 -->
<div class="vidotabs">
<div class="hd">
<ul>
<li class="vli von">Data Storage</li>
<li class="vli">Power Transmission</li>
<li class="vli">Smart Life</li>
<li class="vli">Accessories</li>
</ul>
</div>
<!-- 视频内容 -->
<div class="bdconten">
<ul >
<dl class="video_hotul">
<dd>
<div class="hot1">
<video preload="none" controls="controls">
<source src="/uploads/uk/video/entertainment/RP1 .mp4" type="video/mp4">
</video>
</div>
<div class="htit">
<div class="htit1">ORICO RP1 Headphones</div>
<div class="htit2"> ORICO RP1 in-ear music headphones, skin-friendly and
comfortable for long time wearing; black, white, red and blue, four
colors for you to choose. ORICO 2169U3 full mesh 2.5 inch hard drive
enclosure, all-round heat-dissipation; compatible with SATA HDD below
9.5mm. </div>
</div>
</dd>
<dd>
<div class="hot1">
<video preload="none" controls="controls">
<source src="/uploads/uk/video/entertainment/BS16.mp4" type="video/mp4">
</video>
</div>
<div class="htit">
<div class="htit1">ORICO BS16 Bluetooth Speaker</div>
<div class="htit2"> ORICO BS16 unique and delicate pocket Bluetooth speaker,
bring you beautiful music; smaller size, unprecedented endurance. ORICO
2169U3 full mesh 2.5 inch hard drive enclosure, all-round
heat-dissipation; compatible with SATA HDD below 9.5mm. </div>
</div>
</dd>
<div class="clear"></div>
</dl>
<div id="page39">
<!-- 分页 s -->
<!-- 分页 e -->
</div>
</ul>
</div>
</div>
<!-- 如果切换的是 Videos-->
</div>
</div>
</div>
{/block}

View File

@@ -156,52 +156,27 @@
background-color: rgba(0, 75, 250, 0.05); background-color: rgba(0, 75, 250, 0.05);
cursor: pointer; cursor: pointer;
} }
.orico_Page_download .downloadMain .contact_c .softlist .Page { .orico_Page_download .downloadMain .contact_c .pagination {
zoom: 1; zoom: 1;
text-align: center; text-align: center;
color: #555; color: #555;
clear: both; clear: both;
padding-bottom: 2rem; padding-bottom: 2rem;
} }
.orico_Page_download .downloadMain .contact_c .softlist .Page span { .orico_Page_download .downloadMain .contact_c .pagination span {
padding: 0px 0px; padding: 0px 0px;
display: inline-block; display: inline-block;
} }
.orico_Page_download .downloadMain .contact_c .softlist .Page .p_page { .orico_Page_download .downloadMain .contact_c .pagination li {
display: flex;
align-items: center;
justify-content: center;
}
.orico_Page_download .downloadMain .contact_c .softlist .Page .p_page .a_prev,
.orico_Page_download .downloadMain .contact_c .softlist .Page .p_page .a_next {
display: inline-block;
width: 10px;
height: 21px;
}
.orico_Page_download .downloadMain .contact_c .softlist .Page .p_page .a_prev {
background: url(../downloadImg/pfl.png) no-repeat;
margin-right: 10px;
padding: 0 10px;
}
.orico_Page_download .downloadMain .contact_c .softlist .Page .p_page .a_next {
background: url(../downloadImg/prh.png) no-repeat;
margin-left: 10px;
padding: 0 10px;
}
.orico_Page_download .downloadMain .contact_c .softlist .Page .p_page .num a {
display: inline-block; display: inline-block;
width: 34px; width: 34px;
height: 22px; height: 22px;
line-height: 22px; line-height: 22px;
text-align: center;
vertical-align: middle;
font-size: 16px; font-size: 16px;
color: #444;
} }
.orico_Page_download .downloadMain .contact_c .softlist .Page .p_page .num a.a_cur, .orico_Page_download .downloadMain .contact_c .pagination li.active {
.orico_Page_download .downloadMain .contact_c .softlist .Page .p_page .num a:hover { background-color: #444444;
background: #444; color: #ffffff;
color: #fff;
} }
.orico_Page_download .downloadMain .contact_c .vidotabs { .orico_Page_download .downloadMain .contact_c .vidotabs {
margin-top: 32px; margin-top: 32px;
@@ -278,6 +253,7 @@
display: -webkit-box; display: -webkit-box;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
-webkit-line-clamp: 2; -webkit-line-clamp: 2;
line-clamp: 2;
overflow: hidden; overflow: hidden;
font-size: 14px; font-size: 14px;
margin-top: 16px; margin-top: 16px;