作者 景龙
1 个管道 的构建 通过 耗费 0 秒

增加后台视频的首页封面图字段,解决封面图片变形问题

... ... @@ -92,7 +92,7 @@ class IndexController extends HomeBaseController
// cache('res_xqyy', $res_xqyy,86400);//有效期一天
// }
$position = CityCategoryModel::xqyy;
$field = 'id,more,thumbnail';
$field = 'id,more,index_thumbnail';
$res_xqyy = $this->getVideoIndex($position,$field,1);
foreach($res_xqyy as &$value){
$video = json_decode($value['more'],true);
... ...
... ... @@ -149,7 +149,7 @@ class RegionController extends HomeBaseController
$position['city_id'] = $city_id;
$position['category_id'] = CityCategoryModel::xqyy;
$field = 'id,post_title,framing,release_time,city_id,more,thumbnail';
$res = $this->getVideoArticlePage($position,$field);
$res = $star->getChildArticlePage($position,$field);
foreach($res['data']['data'] as &$value){
$more = json_decode($value['more'],true);
$value['video'] = isset($more['video']) && !empty($more['video'])?$more['video']:'';
... ... @@ -166,34 +166,6 @@ class RegionController extends HomeBaseController
return $this->fetch();
}
//获取更多视频
public function getVideoArticlePage($position,$field,$limit = ''){
$pre = CityCategoryModel::pre;
$limit = empty($limit)?$this->more_limit:$limit;
$post_id = Db::table($pre.'portal_category_post')
->whereIn('category_id',$position['category_id'])
->field('post_id')
->select()
->toArray();
$post_id = array_column($post_id,'post_id');
//查询文章
if($position['city_id'] == 0){
//所有
$where = ['delete_time'=>0,'is_show'=>0];
}else{
$where = ['city_id'=>$position['city_id'],'delete_time'=>0,'is_show'=>0];
}
$res = Db::table($pre.'portal_post')
->whereIn('id',$post_id)
->where($where)
->field($field)
->order('weigh desc')
->paginate($limit,false,['query'=>request()->param()]);
$arr['data'] = $res->toArray();
$arr['page'] = $res->render();
return $arr;
}
//获取城市名称
public function getVideoCityName(){
$res = Db::name('city_category')
... ...
... ... @@ -113,7 +113,26 @@
<div class="col-md-3">
<table class="table table-bordered">
<tr>
<th><b>视频封面图<span class="form-required">*</span></b></th>
<th><b>视频首页封面图</b></th>
</tr>
<tr>
<td>
<div style="text-align: center;">
<input type="hidden" name="post[index_thumbnail]" id="index_thumbnail" value="">
<a href="javascript:uploadOneImage('图片上传','#index_thumbnail');">
<img src="__TMPL__/public/assets/images/default-thumbnail.png"
id="index_thumbnail-preview"
width="135" style="cursor: pointer"/>
</a>
<input type="button" class="btn btn-sm btn-cancel-index_thumbnail" value="取消图片">
</div>
<div style="margin-top:30px;">
<span class="form-required">图片参考尺寸:1200*675</span>
</div>
</td>
</tr>
<tr>
<th><b>视频更多封面图<span class="form-required">*</span></b></th>
</tr>
<tr>
<td>
... ... @@ -126,6 +145,9 @@
</a>
<input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片">
</div>
<div style="margin-top:30px;">
<span class="form-required">图片参考尺寸:955*426</span>
</div>
</td>
</tr>
<tr>
... ... @@ -160,7 +182,11 @@
editorcontent.sync();
} catch (err) {
}
//首页缩略图
$('.btn-cancel-index_thumbnail').click(function () {
$('#index_thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
$('#index_thumbnail').val('');
});
$('.btn-cancel-thumbnail').click(function () {
$('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
$('#thumbnail').val('');
... ...
... ... @@ -112,7 +112,33 @@
<div class="col-md-3">
<table class="table table-bordered">
<tr>
<th>视频封面图<span class="form-required">*</span></th>
<th>首页视频封面图</th>
</tr>
<tr>
<td>
<div style="text-align: center;">
<input type="hidden" name="post[index_thumbnail]" id="index_thumbnail"
value="{$post.index_thumbnail|default=''}">
<a href="javascript:uploadOneImage('图片上传','#index_thumbnail');">
<if condition="empty($post.index_thumbnail)">
<img src="__TMPL__/public/assets/images/default-thumbnail.png"
id="index_thumbnail-preview"
width="135" style="cursor: pointer"/>
<else/>
<img src="{:cmf_get_image_preview_url($post.index_thumbnail)}"
id="index_thumbnail-preview"
width="135" style="cursor: pointer"/>
</if>
</a>
<input type="button" class="btn btn-sm btn-cancel-index_thumbnail" value="取消图片">
</div>
<div style="margin-top:30px;">
<span class="form-required">图片参考尺寸:1200*675</span>
</div>
</td>
</tr>
<tr>
<th>视频更多封面图<span class="form-required">*</span></th>
</tr>
<tr>
<td>
... ... @@ -132,6 +158,9 @@
</a>
<input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片">
</div>
<div style="margin-top:30px;">
<span class="form-required">图片参考尺寸:955*426</span>
</div>
</td>
</tr>
<tr>
... ... @@ -173,6 +202,11 @@
} catch (err) {
}
//首页缩略图
$('.btn-cancel-index_thumbnail').click(function () {
$('#index_thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
$('#index_thumbnail').val('');
});
$('.btn-cancel-thumbnail').click(function () {
$('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
$('#thumbnail').val('');
... ...
... ... @@ -688,7 +688,7 @@
<div class="star_video">
<notempty name="res_xqyy">
<video id="video" width="100%" height="675" src="{:cmf_get_file_download_url($res_xqyy.video)}" controlsList="nodownload"></video>
<img class="show_in_poster" src="{:cmf_get_image_url($res_xqyy.thumbnail)}" alt="">
<img class="show_in_poster" src="{:cmf_get_image_url($res_xqyy.index_thumbnail)}" alt="">
<else/>
<video id="video" width="100%" height="675" src="__TMPL__//public/assets/starImg/video.mp4" controlsList="nodownload"></video>
<img class="show_in_poster" src="__TMPL__/public/assets/starImg/bicon_34.png" alt="">
... ...