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

修改在首页显示视频

@@ -77,19 +77,29 @@ class IndexController extends HomeBaseController @@ -77,19 +77,29 @@ class IndexController extends HomeBaseController
77 $this->assign('res_month',$month); 77 $this->assign('res_month',$month);
78 78
79 //星域秀场->星球影院 79 //星域秀场->星球影院
80 - $res_xqyy = cache('res_xqyy');  
81 - if(!$res_xqyy){  
82 - $position = CityCategoryModel::xqyy;  
83 - $field = 'id,more,thumbnail';  
84 - $res_xqyy = $this->getChildArticle($position,$field,1);  
85 - foreach($res_xqyy as &$value){  
86 - $video = json_decode($value['more'],true);  
87 - $value['video'] = $video['video'];  
88 - }  
89 - if($res_xqyy){  
90 - $res_xqyy = $res_xqyy[0];  
91 - }  
92 - cache('res_xqyy', $res_xqyy,86400);//有效期一天 80 +// $res_xqyy = cache('res_xqyy');
  81 +// if(!$res_xqyy){
  82 +// $position = CityCategoryModel::xqyy;
  83 +// $field = 'id,more,thumbnail';
  84 +// $res_xqyy = $this->getVideoIndex($position,$field,1);
  85 +// foreach($res_xqyy as &$value){
  86 +// $video = json_decode($value['more'],true);
  87 +// $value['video'] = $video['video'];
  88 +// }
  89 +// if($res_xqyy){
  90 +// $res_xqyy = $res_xqyy[0];
  91 +// }
  92 +// cache('res_xqyy', $res_xqyy,86400);//有效期一天
  93 +// }
  94 + $position = CityCategoryModel::xqyy;
  95 + $field = 'id,more,thumbnail';
  96 + $res_xqyy = $this->getVideoIndex($position,$field,1);
  97 + foreach($res_xqyy as &$value){
  98 + $video = json_decode($value['more'],true);
  99 + $value['video'] = $video['video'];
  100 + }
  101 + if($res_xqyy){
  102 + $res_xqyy = $res_xqyy[0];
93 } 103 }
94 $this->assign('res_xqyy',$res_xqyy); 104 $this->assign('res_xqyy',$res_xqyy);
95 105
@@ -206,6 +216,28 @@ class IndexController extends HomeBaseController @@ -206,6 +216,28 @@ class IndexController extends HomeBaseController
206 return $res; 216 return $res;
207 } 217 }
208 218
  219 + //获取显示首页视频
  220 + public function getVideoIndex($position,$field,$limit=''){
  221 + $pre = CityCategoryModel::pre;
  222 + $limit = empty($limit)?0:$limit;
  223 + $post_id = Db::table($pre.'portal_category_post')
  224 + ->whereIn('category_id',$position)
  225 + ->field('post_id')
  226 + ->select()
  227 + ->toArray();
  228 + $post_id = array_column($post_id,'post_id');
  229 + //查询文章
  230 + $res = Db::table($pre.'portal_post')
  231 + ->whereIn('id',$post_id)
  232 + ->where(['delete_time'=>0,'is_show'=>1])
  233 + ->field($field)
  234 + ->limit($limit)
  235 + ->order('weigh desc')
  236 + ->select()
  237 + ->toArray();
  238 + return $res;
  239 + }
  240 +
209 //获取推荐视频 241 //获取推荐视频
210 public function getVideo($position,$city_id,$field,$limit=''){ 242 public function getVideo($position,$city_id,$field,$limit=''){
211 $pre = CityCategoryModel::pre; 243 $pre = CityCategoryModel::pre;
@@ -149,11 +149,10 @@ class RegionController extends HomeBaseController @@ -149,11 +149,10 @@ class RegionController extends HomeBaseController
149 $position['city_id'] = $city_id; 149 $position['city_id'] = $city_id;
150 $position['category_id'] = CityCategoryModel::xqyy; 150 $position['category_id'] = CityCategoryModel::xqyy;
151 $field = 'id,post_title,framing,release_time,city_id,more,thumbnail'; 151 $field = 'id,post_title,framing,release_time,city_id,more,thumbnail';
152 - $star = new StarController();  
153 - $res = $star->getChildArticlePage($position,$field); 152 + $res = $this->getVideoArticlePage($position,$field);
154 foreach($res['data']['data'] as &$value){ 153 foreach($res['data']['data'] as &$value){
155 $more = json_decode($value['more'],true); 154 $more = json_decode($value['more'],true);
156 - $value['video'] = isset($more['video']) && !empty($more['video'])?$more['video']:'';; 155 + $value['video'] = isset($more['video']) && !empty($more['video'])?$more['video']:'';
157 $value['city_name'] = $this->getCityCategory($value['city_id']); 156 $value['city_name'] = $this->getCityCategory($value['city_id']);
158 } 157 }
159 $this->assign('res',$res['data']); 158 $this->assign('res',$res['data']);
@@ -167,6 +166,34 @@ class RegionController extends HomeBaseController @@ -167,6 +166,34 @@ class RegionController extends HomeBaseController
167 return $this->fetch(); 166 return $this->fetch();
168 } 167 }
169 168
  169 + //获取更多视频
  170 + public function getVideoArticlePage($position,$field,$limit = ''){
  171 + $pre = CityCategoryModel::pre;
  172 + $limit = empty($limit)?$this->more_limit:$limit;
  173 + $post_id = Db::table($pre.'portal_category_post')
  174 + ->whereIn('category_id',$position['category_id'])
  175 + ->field('post_id')
  176 + ->select()
  177 + ->toArray();
  178 + $post_id = array_column($post_id,'post_id');
  179 + //查询文章
  180 + if($position['city_id'] == 0){
  181 + //所有
  182 + $where = ['delete_time'=>0,'is_show'=>0];
  183 + }else{
  184 + $where = ['city_id'=>$position['city_id'],'delete_time'=>0,'is_show'=>0];
  185 + }
  186 + $res = Db::table($pre.'portal_post')
  187 + ->whereIn('id',$post_id)
  188 + ->where($where)
  189 + ->field($field)
  190 + ->order('weigh desc')
  191 + ->paginate($limit,false,['query'=>request()->param()]);
  192 + $arr['data'] = $res->toArray();
  193 + $arr['page'] = $res->render();
  194 + return $arr;
  195 + }
  196 +
170 //获取城市名称 197 //获取城市名称
171 public function getVideoCityName(){ 198 public function getVideoCityName(){
172 $res = Db::name('city_category') 199 $res = Db::name('city_category')
@@ -57,6 +57,14 @@ @@ -57,6 +57,14 @@
57 </td> 57 </td>
58 </tr> 58 </tr>
59 <tr> 59 <tr>
  60 + <th>是否显示首页<span class="form-required">*</span></th>
  61 + <td>
  62 + 否:<input class="" type="radio" name="post[is_show]" checked value="0"/>
  63 + &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  64 + 是:<input class="" type="radio" name="post[is_show]" value="1"/>
  65 + </td>
  66 + </tr>
  67 + <tr>
60 <th>视频</th> 68 <th>视频</th>
61 <td class="form-inline"> 69 <td class="form-inline">
62 <input id="file-video" class="form-control" type="text" name="post[more][video]" 70 <input id="file-video" class="form-control" type="text" name="post[more][video]"
@@ -61,6 +61,14 @@ @@ -61,6 +61,14 @@
61 </td> 61 </td>
62 </tr> 62 </tr>
63 <tr> 63 <tr>
  64 + <th>是否显示首页<span class="form-required">*</span></th>
  65 + <td>
  66 + 否:<input class="" type="radio" name="post[is_show]" value="0" <eq name="0" value="$post.is_show">checked</eq>/>
  67 + &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  68 + 是:<input class="" type="radio" name="post[is_show]" value="1" <eq name="1" value="$post.is_show">checked</eq>/>
  69 + </td>
  70 + </tr>
  71 + <tr>
64 <th>视频</th> 72 <th>视频</th>
65 <td class="form-inline"> 73 <td class="form-inline">
66 <input id="file-video" class="form-control" type="text" name="post[more][video]" 74 <input id="file-video" class="form-control" type="text" name="post[more][video]"
@@ -45,6 +45,7 @@ @@ -45,6 +45,7 @@
45 <!--</notempty>--> 45 <!--</notempty>-->
46 <th width="50">ID</th> 46 <th width="50">ID</th>
47 <th width="300">标题</th> 47 <th width="300">标题</th>
  48 + <th width="200">是否显示首页</th>
48 <th width="100">缩略图</th> 49 <th width="100">缩略图</th>
49 <th width="80">所属城市</th> 50 <th width="80">所属城市</th>
50 <th width="100">取景</th> 51 <th width="100">取景</th>
@@ -77,6 +78,17 @@ @@ -77,6 +78,17 @@
77 </notempty> 78 </notempty>
78 </td> 79 </td>
79 <td> 80 <td>
  81 + <empty name="vo.is_show">
  82 + <span class="label label-default">
  83 + 隐藏
  84 + </span>
  85 + <else/>
  86 + <span class="label label-success">
  87 + 显示
  88 + </span>
  89 + </empty>
  90 + </td>
  91 + <td>
80 <notempty name="vo.more.thumbnail"> 92 <notempty name="vo.more.thumbnail">
81 <a href="javascript:parent.imagePreviewDialog('{:cmf_get_image_preview_url($vo.more.thumbnail)}');"> 93 <a href="javascript:parent.imagePreviewDialog('{:cmf_get_image_preview_url($vo.more.thumbnail)}');">
82 <i class="fa fa-photo fa-fw"></i> 94 <i class="fa fa-photo fa-fw"></i>
@@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
40 <div class="Wheel"> 40 <div class="Wheel">
41 <div class="swiper-container gallery-top swiper-no-swiping"> 41 <div class="swiper-container gallery-top swiper-no-swiping">
42 <div class="swiper-wrapper"> 42 <div class="swiper-wrapper">
43 - <volist name="res.image_url" id="vo"> 43 + <volist name="res.image_url" id="vo" offset="1">
44 <div class="swiper-slide" style='background-image:url({:cmf_get_image_url($vo.url)})'></div> 44 <div class="swiper-slide" style='background-image:url({:cmf_get_image_url($vo.url)})'></div>
45 </volist> 45 </volist>
46 </div> 46 </div>
@@ -50,7 +50,7 @@ @@ -50,7 +50,7 @@
50 </div> 50 </div>
51 <div class="swiper-container gallery-thumbs"> 51 <div class="swiper-container gallery-thumbs">
52 <div class="swiper-wrapper"> 52 <div class="swiper-wrapper">
53 - <volist name="res.image_url" id="vo"> 53 + <volist name="res.image_url" id="vo" offset="1">
54 <div class="swiper-slide" style="background-image:url({:cmf_get_image_url($vo.url)})"></div> 54 <div class="swiper-slide" style="background-image:url({:cmf_get_image_url($vo.url)})"></div>
55 </volist> 55 </volist>
56 </div> 56 </div>
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 <img src="{:cmf_get_image_url($res.avatar)}" alt=""> 26 <img src="{:cmf_get_image_url($res.avatar)}" alt="">
27 <div class="show6_con_top2"> 27 <div class="show6_con_top2">
28 <h1>{$res.full_name}</h1> 28 <h1>{$res.full_name}</h1>
29 - <h2>{$res.position} {$res.trade}</h2> 29 + <h2 style="margin-top:10px;">{$res.position} {$res.trade}</h2>
30 <!--<span>{$res.create_time|date="Y-m-d",###}</span>--> 30 <!--<span>{$res.create_time|date="Y-m-d",###}</span>-->
31 <p class="show6_con_top3"> 31 <p class="show6_con_top3">
32 {$res.post_excerpt} 32 {$res.post_excerpt}
@@ -195,9 +195,8 @@ p { @@ -195,9 +195,8 @@ p {
195 195
196 #star_main .star_happy .happy_title p:last-child { 196 #star_main .star_happy .happy_title p:last-child {
197 font-size: 16px; 197 font-size: 16px;
198 - opacity: 0.8;  
199 margin-top: 18px; 198 margin-top: 18px;
200 - font-family: Quicksand-Bold; 199 + color: white;
201 } 200 }
202 201
203 202
@@ -892,6 +892,7 @@ body { @@ -892,6 +892,7 @@ body {
892 font-size: 28px; 892 font-size: 28px;
893 font-weight: bold; 893 font-weight: bold;
894 color: rgba(26, 26, 26, 1); 894 color: rgba(26, 26, 26, 1);
  895 + margin-bottom:40px;
895 } 896 }
896 897
897 .show_4_con1 span { 898 .show_4_con1 span {