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

修改视频,首页数据缓存cache中

... ... @@ -11,7 +11,7 @@
return [
// 应用调试模式
'app_debug' => false,
'app_debug' => true,
// 应用Trace
'app_trace' => true,
... ...
... ... @@ -21,60 +21,75 @@ class IndexController extends HomeBaseController
$serverModel = new ServerController();
//统计访问量
$serverModel->statistics();
//banner轮播图
$coverImg = $this->getCoverImg(CityCategoryModel::indexImg,3);
$coverImg = cache('coverImg');
if(!$coverImg){
$coverImg = $this->getCoverImg(CityCategoryModel::indexImg,3);
cache('coverImg',$coverImg,86400);
}
$this->assign('coverImg',$coverImg);
//星球奇境,城市分类
$city[1]['id'] = CityCategoryModel::asia;
$city[2]['id'] = CityCategoryModel::europe;
$city[3]['id'] = CityCategoryModel::africa;
$city[4]['id'] = CityCategoryModel::oceania;
$city[5]['id'] = CityCategoryModel::north;
$city[6]['id'] = CityCategoryModel::south;
$city[20]['id'] = CityCategoryModel::antarctica;
$city[43]['id'] = CityCategoryModel::arctic;
$city_name = $this->getCity(array_column($city,'id'));
foreach($city as &$value){
$k = 0;
foreach($city_name as $value1){
$k += 0;
if($value['id'] == $value1['pid']){
$value['name'][$k]['name'] = $value1['name'];
$value['name'][$k]['id'] = $value1['id'];
$k++;
$city = cache('res_city');
if(!$city){
$city[1]['id'] = CityCategoryModel::asia;
$city[2]['id'] = CityCategoryModel::europe;
$city[3]['id'] = CityCategoryModel::africa;
$city[4]['id'] = CityCategoryModel::oceania;
$city[5]['id'] = CityCategoryModel::north;
$city[6]['id'] = CityCategoryModel::south;
$city[20]['id'] = CityCategoryModel::antarctica;
$city[43]['id'] = CityCategoryModel::arctic;
$city_name = $this->getCity(array_column($city,'id'));
foreach($city as &$value){
$k = 0;
foreach($city_name as $value1){
$k += 0;
if($value['id'] == $value1['pid']){
$value['name'][$k]['name'] = $value1['name'];
$value['name'][$k]['id'] = $value1['id'];
$k++;
}
}
}
cache('res_city', $city,86400);//有效期一天
}
$this->assign('res_city',$city);
//星享体验
$res_month = $this->getMonthArticle();
$month = [];
foreach($res_month['data'] as &$value){
$month[$value['month']]['id'] = $value['id'];
$month[$value['month']]['month'] = $value['month'];
$month[$value['month']]['post_title'] = $value['post_title'];
$month[$value['month']]['index_thumbnail'] = $value['index_thumbnail'];
foreach($res_month['category_name'] as $value1){
if($value['id'] == $value1['post_id']){
$month[$value['month']]['category_name'] = $value1['name'];
$month = cache('res_month');
if(!$month){
$res_month = $this->getMonthArticle();
$month = [];
foreach($res_month['data'] as &$value){
$month[$value['month']]['id'] = $value['id'];
$month[$value['month']]['month'] = $value['month'];
$month[$value['month']]['post_title'] = $value['post_title'];
$month[$value['month']]['index_thumbnail'] = $value['index_thumbnail'];
foreach($res_month['category_name'] as $value1){
if($value['id'] == $value1['post_id']){
$month[$value['month']]['category_name'] = $value1['name'];
}
}
}
cache('res_month', $month,86400);//有效期一天
}
$this->assign('res_month',$month);
//星域秀场->星球影院
$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];
$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);//有效期一天
}
$this->assign('res_xqyy',$res_xqyy);
... ... @@ -93,33 +108,49 @@ class IndexController extends HomeBaseController
$this->assign('res_djxq',$res_djxq);
//星域秀场->明星访谈
$position = CityCategoryModel::mxft;
$field = 'id,full_name,position,trade,post_excerpt,thumbnail avatar';
$res_mxft = $this->getChildArticle($position,$field,1);
if($res_mxft){
$res_mxft = $res_mxft[0];
$res_mxft = cache('res_mxft');
if(!$res_mxft){
$position = CityCategoryModel::mxft;
$field = 'id,full_name,position,trade,post_excerpt,thumbnail avatar';
$res_mxft = $this->getChildArticle($position,$field,1);
if($res_mxft){
$res_mxft = $res_mxft[0];
}
cache('res_mxft',$res_mxft,86400);
}
$this->assign('res_mxft',$res_mxft);
//星域秀场->星域画廊
$position = CityCategoryModel::xyhl;
$field = 'id,thumbnail';
$res_xyhl = $this->getChildArticle($position,$field,16);
$res_xyhl = cache('res_xyhl');
if(!$res_xyhl){
$position = CityCategoryModel::xyhl;
$field = 'id,thumbnail';
$res_xyhl = $this->getChildArticle($position,$field,16);
cache('res_xyhl',$res_xyhl,86400);
}
$this->assign('res_xyhl',$res_xyhl);
//星探推荐
$position = CityCategoryModel::xttj;
$field = 'id,post_title,price,index_thumbnail,place';
$res_xttj = $this->getParentArticle($position,$field,16);
$res_xttj = cache('res_xttj');
if(!$res_xttj){
$position = CityCategoryModel::xttj;
$field = 'id,post_title,price,index_thumbnail,place';
$res_xttj = $this->getParentArticle($position,$field,16);
cache('res_xttj',$res_xttj,86400);
}
$this->assign('res_xttj',$res_xttj);
//星际活动
$position = CityCategoryModel::xjhd;
$field = 'id,post_title,thumbnail';
$res_xjhd = $this->getParentArticle($position,$field,2);
$res_xjhd = cache('res_xjhd');
if(!$res_xjhd){
$position = CityCategoryModel::xjhd;
$field = 'id,post_title,thumbnail';
$res_xjhd = $this->getParentArticle($position,$field,2);
cache('res_xjhd',$res_xjhd,86400);
}
$this->assign('res_xjhd',$res_xjhd);
return $this->fetch();
}
... ...
... ... @@ -63,7 +63,7 @@
<div class="mask" id="mask">
<div class="mask_video" >
<img id="nos" src="__TMPL__/public/assets/starImg/nos.png" alt="">
<video autoplay="autoplay" controls id="video2" src="{:cmf_get_file_download_url($res_djxq.video)}" controlslist="nodownload"></video>
<video muted autoplay="autoplay" id="video2" src="{:cmf_get_file_download_url($res_djxq.video)}" controlslist="nodownload"></video>
</div>
</div>
</notempty>
... ... @@ -758,13 +758,15 @@
<div class="star_gall_img swiper-container">
<!-- 轮播图 -->
<ul class="swiper-wrapper">
<volist name="res_xyhl" id="vo">
<li class="swiper-slide">
<a href="/portal/region/getGalleryDetail?id={$vo.id}">
<img class="swiper-slide slide-image" src="{:cmf_get_image_url($vo.thumbnail)}" alt="">
</a>
</li>
</volist>
<notempty name="res_xyhl">
<volist name="res_xyhl" id="vo">
<li class="swiper-slide">
<a href="/portal/region/getGalleryDetail?id={$vo.id}">
<img class="swiper-slide slide-image" src="{:cmf_get_image_url($vo.thumbnail)}" alt="">
</a>
</li>
</volist>
</notempty>
</ul>
<!-- 左右按钮 -->
<div class="swiper-button-next">
... ... @@ -794,23 +796,25 @@
<div class="star_gall_img swiper-container2">
<!-- 轮播图 -->
<ul class="swiper-wrapper">
<volist name="res_xttj" id="vo">
<li class="swiper-slide scout_box">
<div class="scout_image">
<img src="{:cmf_get_image_url($vo.index_thumbnail)}" alt="">
</div>
<empty name="vo.place">
<a href="/portal/scout/getSceneryDetail?id={$vo.id}">
<else />
<a href="/portal/scout/getTravelDetail?id={$vo.id}">
</empty>
<h1>
{$vo.post_title}
</h1>
<p>¥{$vo.price}</p>
</a>
</li>
</volist>
<notempty name="res_xttj">
<volist name="res_xttj" id="vo">
<li class="swiper-slide scout_box">
<div class="scout_image">
<img src="{:cmf_get_image_url($vo.index_thumbnail)}" alt="">
</div>
<empty name="vo.place">
<a href="/portal/scout/getSceneryDetail?id={$vo.id}">
<else />
<a href="/portal/scout/getTravelDetail?id={$vo.id}">
</empty>
<h1>
{$vo.post_title}
</h1>
<p>¥{$vo.price}</p>
</a>
</li>
</volist>
</notempty>
</ul>
<!-- 左右按钮 -->
<div class="swiper-button-next2">
... ... @@ -858,14 +862,8 @@
<script>
// 弹框视频
$('.mask').css('display','block');
// var video2 = document.getElementById("video2"); //获取ID 
// console.log(video2);
// $(function() {
// if (video2.paused) { //判读是否播放    
// // video2.paused = false;            
// video2.play(); //没有就播放      
// }
// });
var video2 = document.getElementById("video2"); //获取ID 
var nos = document.getElementById("nos");
var mask = document.getElementById("mask");
... ...
... ... @@ -55,9 +55,9 @@
<!-- banner视频 -->
<div class="show_index_banner">
<notempty name="res_xqyy">
<video id="video" autoplay="autoplay" controls width="100%" height="660" src="{:cmf_get_file_download_url($res_xqyy.video)}" controlsList="nodownload"></video>
<video id="video" muted autoplay="autoplay" controls width="100%" height="660" src="{:cmf_get_file_download_url($res_xqyy.video)}" controlsList="nodownload"></video>
<else/>
<video id="video" autoplay="autoplay" controls width="100%" height="660" src="__TMPL__/public/assets/starImg/video.mp4" controlsList="nodownload"></video>
<video id="video" muted autoplay="autoplay" controls width="100%" height="660" src="__TMPL__/public/assets/starImg/video.mp4" controlsList="nodownload"></video>
</notempty>
<!-- poster="__TMPL__/public/assets/starImg/aicon_01.png" -->
<!-- <img onclick="bofang()" class="show_in_banner2" src="__TMPL__/public/assets/starImg/aicon_30.png" alt=""> -->
... ...