refacotr: 视频
This commit is contained in:
@@ -5,6 +5,8 @@ namespace app\index\controller;
|
||||
|
||||
use app\index\model\AttachmentCategoryModel;
|
||||
use app\index\model\AttachmentModel;
|
||||
use app\index\model\VideoCategoryModel;
|
||||
use app\index\model\VideoModel;
|
||||
use think\facade\View;
|
||||
|
||||
/**
|
||||
@@ -63,16 +65,51 @@ class Attachment extends Common
|
||||
*/
|
||||
public function video()
|
||||
{
|
||||
$param = request()->param([
|
||||
'page/d' => 1,
|
||||
'size/d' => 12
|
||||
]);
|
||||
|
||||
// 获取附件分类
|
||||
$categorys = AttachmentCategoryModel::field([
|
||||
$attachment_categorys = AttachmentCategoryModel::field([
|
||||
'id',
|
||||
'name'
|
||||
])
|
||||
->language($this->lang_id)
|
||||
->parent(0)
|
||||
->isShow(true)
|
||||
->order(['sort' => 'asc', 'id' => 'desc'])
|
||||
->select();
|
||||
View::assign('categorys', $categorys);
|
||||
View::assign('attachment_categorys', $attachment_categorys);
|
||||
|
||||
// 获取视频分类
|
||||
$video_categorys = VideoCategoryModel::field([
|
||||
'id',
|
||||
'name'
|
||||
])
|
||||
->language($this->lang_id)
|
||||
->isShow(true)
|
||||
->order(['sort' => 'asc', 'id' => 'desc'])
|
||||
->select();
|
||||
View::assign('video_categorys', $video_categorys);
|
||||
|
||||
// 获取视频
|
||||
$videos = VideoModel::field([
|
||||
'id',
|
||||
'name',
|
||||
'desc',
|
||||
'image',
|
||||
'video',
|
||||
'link'
|
||||
])
|
||||
->language($this->lang_id)
|
||||
->order(['sort' => 'asc', 'id' => 'desc'])
|
||||
->paginate([
|
||||
'list_rows' => $param['size'],
|
||||
'page' => $param['page'],
|
||||
]);
|
||||
View::assign('videos', $videos);
|
||||
View::assign('page', $videos->render());
|
||||
|
||||
return View::fetch('video');
|
||||
}
|
||||
|
||||
@@ -3,12 +3,29 @@ declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
use think\Model;
|
||||
use app\common\model\VideoCategoryBaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
/**
|
||||
* 视频分类模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class VideoCategoryModel extends Model
|
||||
class VideoCategoryModel extends VideoCategoryBaseModel
|
||||
{
|
||||
//
|
||||
// 启用软删除
|
||||
use SoftDelete;
|
||||
// 软删除字段
|
||||
protected $deleteTime = 'deleted_at';
|
||||
|
||||
// 所属语言范围查询
|
||||
public function scopeLanguage($query, $language)
|
||||
{
|
||||
$query->where('language_id', '=', $language);
|
||||
}
|
||||
|
||||
// 是否显示状态范围查询
|
||||
public function scopeIsShow($query, bool $is_show)
|
||||
{
|
||||
$query->where('is_show', '=', (int)$is_show);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,30 @@ declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
use app\common\model\VideoBaseModel;
|
||||
use think\Model;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
/**
|
||||
* 视频模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class VideoModel extends Model
|
||||
class VideoModel extends VideoBaseModel
|
||||
{
|
||||
//
|
||||
// 启用软删除
|
||||
use SoftDelete;
|
||||
// 软删除字段
|
||||
protected $deleteTime = 'deleted_at';
|
||||
|
||||
// 所属语言范围查询
|
||||
public function scopeLanguage($query, $language)
|
||||
{
|
||||
$query->where('language_id', '=', $language);
|
||||
}
|
||||
|
||||
// 推荐状态范围查询
|
||||
public function scopeRecommend($query, bool $recommend)
|
||||
{
|
||||
$query->where('recommend', '=', (int)$recommend);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
</div>
|
||||
<!-- tab切换 -->
|
||||
<div class="tab">
|
||||
{notempty name="categorys"}
|
||||
{volist name="categorys" id="ca"}
|
||||
{notempty name="attachment_categorys"}
|
||||
{volist name="attachment_categorys" id="ca"}
|
||||
<a href="{:url('attachment/index', ['id' => $ca.id])}">
|
||||
<div class="tabit">
|
||||
{$ca.name}
|
||||
@@ -33,57 +33,42 @@
|
||||
</div>
|
||||
<!-- VIDEO 切换 -->
|
||||
<div class="vidotabs">
|
||||
{notempty name="video_categorys"}
|
||||
<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>
|
||||
{volist name="video_categorys" id="vca"}
|
||||
<li class="vli {eq name='vca.id' value='Request.get.id' }von{/eq}">
|
||||
<a href="{:url('attachment/video', ['id' => $vca.id])}" style="display: block;">{$vca.name}</a>
|
||||
</li>
|
||||
{/volist}
|
||||
</ul>
|
||||
</div>
|
||||
{/notempty}
|
||||
<!-- 视频内容 -->
|
||||
{notempty name="videos"}
|
||||
<div class="bdconten">
|
||||
<ul >
|
||||
<dl class="video_hotul">
|
||||
{volist name="videos" id="vo"}
|
||||
<dd>
|
||||
<div class="hot1">
|
||||
<video preload="none" controls="controls">
|
||||
<source src="/uploads/uk/video/entertainment/RP1 .mp4" type="video/mp4">
|
||||
<video poster="{$vo.image}" preload="none" controls="controls">
|
||||
<source src="{$vo.video}" 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 class="htit1">{$vo.name}</div>
|
||||
<div class="htit2">{$vo.desc}</div>
|
||||
</div>
|
||||
</dd>
|
||||
{/volist}
|
||||
<div class="clear"></div>
|
||||
</dl>
|
||||
<div id="page39">
|
||||
<!-- 分页 s -->
|
||||
<!-- 分页 e -->
|
||||
</div>
|
||||
<div>{$page|raw}</div>
|
||||
</ul>
|
||||
</div>
|
||||
{/notempty}
|
||||
</div>
|
||||
<!-- 如果切换的是 Videos-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user