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

修改在首页显示视频

... ... @@ -77,19 +77,29 @@ class IndexController extends HomeBaseController
$this->assign('res_month',$month);
//星域秀场->星球影院
$res_xqyy = cache('res_xqyy');
if(!$res_xqyy){
$position = CityCategoryModel::xqyy;
$field = 'id,more,thumbnail';
$res_xqyy = $this->getChildArticle($position,$field,1);
foreach($res_xqyy as &$value){
$video = json_decode($value['more'],true);
$value['video'] = $video['video'];
}
if($res_xqyy){
$res_xqyy = $res_xqyy[0];
}
cache('res_xqyy', $res_xqyy,86400);//有效期一天
// $res_xqyy = cache('res_xqyy');
// if(!$res_xqyy){
// $position = CityCategoryModel::xqyy;
// $field = 'id,more,thumbnail';
// $res_xqyy = $this->getVideoIndex($position,$field,1);
// foreach($res_xqyy as &$value){
// $video = json_decode($value['more'],true);
// $value['video'] = $video['video'];
// }
// if($res_xqyy){
// $res_xqyy = $res_xqyy[0];
// }
// cache('res_xqyy', $res_xqyy,86400);//有效期一天
// }
$position = CityCategoryModel::xqyy;
$field = 'id,more,thumbnail';
$res_xqyy = $this->getVideoIndex($position,$field,1);
foreach($res_xqyy as &$value){
$video = json_decode($value['more'],true);
$value['video'] = $video['video'];
}
if($res_xqyy){
$res_xqyy = $res_xqyy[0];
}
$this->assign('res_xqyy',$res_xqyy);
... ... @@ -206,6 +216,28 @@ class IndexController extends HomeBaseController
return $res;
}
//获取显示首页视频
public function getVideoIndex($position,$field,$limit=''){
$pre = CityCategoryModel::pre;
$limit = empty($limit)?0:$limit;
$post_id = Db::table($pre.'portal_category_post')
->whereIn('category_id',$position)
->field('post_id')
->select()
->toArray();
$post_id = array_column($post_id,'post_id');
//查询文章
$res = Db::table($pre.'portal_post')
->whereIn('id',$post_id)
->where(['delete_time'=>0,'is_show'=>1])
->field($field)
->limit($limit)
->order('weigh desc')
->select()
->toArray();
return $res;
}
//获取推荐视频
public function getVideo($position,$city_id,$field,$limit=''){
$pre = CityCategoryModel::pre;
... ...
... ... @@ -149,11 +149,10 @@ 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';
$star = new StarController();
$res = $star->getChildArticlePage($position,$field);
$res = $this->getVideoArticlePage($position,$field);
foreach($res['data']['data'] as &$value){
$more = json_decode($value['more'],true);
$value['video'] = isset($more['video']) && !empty($more['video'])?$more['video']:'';;
$value['video'] = isset($more['video']) && !empty($more['video'])?$more['video']:'';
$value['city_name'] = $this->getCityCategory($value['city_id']);
}
$this->assign('res',$res['data']);
... ... @@ -167,6 +166,34 @@ 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')
... ...
... ... @@ -57,6 +57,14 @@
</td>
</tr>
<tr>
<th>是否显示首页<span class="form-required">*</span></th>
<td>
否:<input class="" type="radio" name="post[is_show]" checked value="0"/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
是:<input class="" type="radio" name="post[is_show]" value="1"/>
</td>
</tr>
<tr>
<th>视频</th>
<td class="form-inline">
<input id="file-video" class="form-control" type="text" name="post[more][video]"
... ...
... ... @@ -61,6 +61,14 @@
</td>
</tr>
<tr>
<th>是否显示首页<span class="form-required">*</span></th>
<td>
否:<input class="" type="radio" name="post[is_show]" value="0" <eq name="0" value="$post.is_show">checked</eq>/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
是:<input class="" type="radio" name="post[is_show]" value="1" <eq name="1" value="$post.is_show">checked</eq>/>
</td>
</tr>
<tr>
<th>视频</th>
<td class="form-inline">
<input id="file-video" class="form-control" type="text" name="post[more][video]"
... ...
... ... @@ -45,6 +45,7 @@
<!--</notempty>-->
<th width="50">ID</th>
<th width="300">标题</th>
<th width="200">是否显示首页</th>
<th width="100">缩略图</th>
<th width="80">所属城市</th>
<th width="100">取景</th>
... ... @@ -77,6 +78,17 @@
</notempty>
</td>
<td>
<empty name="vo.is_show">
<span class="label label-default">
隐藏
</span>
<else/>
<span class="label label-success">
显示
</span>
</empty>
</td>
<td>
<notempty name="vo.more.thumbnail">
<a href="javascript:parent.imagePreviewDialog('{:cmf_get_image_preview_url($vo.more.thumbnail)}');">
<i class="fa fa-photo fa-fw"></i>
... ...
... ... @@ -40,7 +40,7 @@
<div class="Wheel">
<div class="swiper-container gallery-top swiper-no-swiping">
<div class="swiper-wrapper">
<volist name="res.image_url" id="vo">
<volist name="res.image_url" id="vo" offset="1">
<div class="swiper-slide" style='background-image:url({:cmf_get_image_url($vo.url)})'></div>
</volist>
</div>
... ... @@ -50,7 +50,7 @@
</div>
<div class="swiper-container gallery-thumbs">
<div class="swiper-wrapper">
<volist name="res.image_url" id="vo">
<volist name="res.image_url" id="vo" offset="1">
<div class="swiper-slide" style="background-image:url({:cmf_get_image_url($vo.url)})"></div>
</volist>
</div>
... ...
... ... @@ -26,7 +26,7 @@
<img src="{:cmf_get_image_url($res.avatar)}" alt="">
<div class="show6_con_top2">
<h1>{$res.full_name}</h1>
<h2>{$res.position} {$res.trade}</h2>
<h2 style="margin-top:10px;">{$res.position} {$res.trade}</h2>
<!--<span>{$res.create_time|date="Y-m-d",###}</span>-->
<p class="show6_con_top3">
{$res.post_excerpt}
... ...
... ... @@ -195,9 +195,8 @@ p {
#star_main .star_happy .happy_title p:last-child {
font-size: 16px;
opacity: 0.8;
margin-top: 18px;
font-family: Quicksand-Bold;
color: white;
}
... ...
... ... @@ -892,6 +892,7 @@ body {
font-size: 28px;
font-weight: bold;
color: rgba(26, 26, 26, 1);
margin-bottom:40px;
}
.show_4_con1 span {
... ...