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

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

@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 11
12 return [ 12 return [
13 // 应用调试模式 13 // 应用调试模式
14 - 'app_debug' => false, 14 + 'app_debug' => true,
15 // 应用Trace 15 // 应用Trace
16 'app_trace' => true, 16 'app_trace' => true,
17 17
@@ -21,60 +21,75 @@ class IndexController extends HomeBaseController @@ -21,60 +21,75 @@ class IndexController extends HomeBaseController
21 $serverModel = new ServerController(); 21 $serverModel = new ServerController();
22 //统计访问量 22 //统计访问量
23 $serverModel->statistics(); 23 $serverModel->statistics();
24 -  
25 //banner轮播图 24 //banner轮播图
26 - $coverImg = $this->getCoverImg(CityCategoryModel::indexImg,3); 25 + $coverImg = cache('coverImg');
  26 + if(!$coverImg){
  27 + $coverImg = $this->getCoverImg(CityCategoryModel::indexImg,3);
  28 + cache('coverImg',$coverImg,86400);
  29 + }
27 $this->assign('coverImg',$coverImg); 30 $this->assign('coverImg',$coverImg);
28 31
29 //星球奇境,城市分类 32 //星球奇境,城市分类
30 - $city[1]['id'] = CityCategoryModel::asia;  
31 - $city[2]['id'] = CityCategoryModel::europe;  
32 - $city[3]['id'] = CityCategoryModel::africa;  
33 - $city[4]['id'] = CityCategoryModel::oceania;  
34 - $city[5]['id'] = CityCategoryModel::north;  
35 - $city[6]['id'] = CityCategoryModel::south;  
36 - $city[20]['id'] = CityCategoryModel::antarctica;  
37 - $city[43]['id'] = CityCategoryModel::arctic;  
38 - $city_name = $this->getCity(array_column($city,'id'));  
39 - foreach($city as &$value){  
40 - $k = 0;  
41 - foreach($city_name as $value1){  
42 - $k += 0;  
43 - if($value['id'] == $value1['pid']){  
44 - $value['name'][$k]['name'] = $value1['name'];  
45 - $value['name'][$k]['id'] = $value1['id'];  
46 - $k++; 33 + $city = cache('res_city');
  34 + if(!$city){
  35 + $city[1]['id'] = CityCategoryModel::asia;
  36 + $city[2]['id'] = CityCategoryModel::europe;
  37 + $city[3]['id'] = CityCategoryModel::africa;
  38 + $city[4]['id'] = CityCategoryModel::oceania;
  39 + $city[5]['id'] = CityCategoryModel::north;
  40 + $city[6]['id'] = CityCategoryModel::south;
  41 + $city[20]['id'] = CityCategoryModel::antarctica;
  42 + $city[43]['id'] = CityCategoryModel::arctic;
  43 + $city_name = $this->getCity(array_column($city,'id'));
  44 + foreach($city as &$value){
  45 + $k = 0;
  46 + foreach($city_name as $value1){
  47 + $k += 0;
  48 + if($value['id'] == $value1['pid']){
  49 + $value['name'][$k]['name'] = $value1['name'];
  50 + $value['name'][$k]['id'] = $value1['id'];
  51 + $k++;
  52 + }
47 } 53 }
48 } 54 }
  55 + cache('res_city', $city,86400);//有效期一天
49 } 56 }
50 $this->assign('res_city',$city); 57 $this->assign('res_city',$city);
51 58
52 //星享体验 59 //星享体验
53 - $res_month = $this->getMonthArticle();  
54 - $month = [];  
55 - foreach($res_month['data'] as &$value){  
56 - $month[$value['month']]['id'] = $value['id'];  
57 - $month[$value['month']]['month'] = $value['month'];  
58 - $month[$value['month']]['post_title'] = $value['post_title'];  
59 - $month[$value['month']]['index_thumbnail'] = $value['index_thumbnail'];  
60 - foreach($res_month['category_name'] as $value1){  
61 - if($value['id'] == $value1['post_id']){  
62 - $month[$value['month']]['category_name'] = $value1['name']; 60 + $month = cache('res_month');
  61 + if(!$month){
  62 + $res_month = $this->getMonthArticle();
  63 + $month = [];
  64 + foreach($res_month['data'] as &$value){
  65 + $month[$value['month']]['id'] = $value['id'];
  66 + $month[$value['month']]['month'] = $value['month'];
  67 + $month[$value['month']]['post_title'] = $value['post_title'];
  68 + $month[$value['month']]['index_thumbnail'] = $value['index_thumbnail'];
  69 + foreach($res_month['category_name'] as $value1){
  70 + if($value['id'] == $value1['post_id']){
  71 + $month[$value['month']]['category_name'] = $value1['name'];
  72 + }
63 } 73 }
64 } 74 }
  75 + cache('res_month', $month,86400);//有效期一天
65 } 76 }
66 $this->assign('res_month',$month); 77 $this->assign('res_month',$month);
67 78
68 //星域秀场->星球影院 79 //星域秀场->星球影院
69 - $position = CityCategoryModel::xqyy;  
70 - $field = 'id,more,thumbnail';  
71 - $res_xqyy = $this->getChildArticle($position,$field,1);  
72 - foreach($res_xqyy as &$value){  
73 - $video = json_decode($value['more'],true);  
74 - $value['video'] = $video['video'];  
75 - }  
76 - if($res_xqyy){  
77 - $res_xqyy = $res_xqyy[0]; 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);//有效期一天
78 } 93 }
79 $this->assign('res_xqyy',$res_xqyy); 94 $this->assign('res_xqyy',$res_xqyy);
80 95
@@ -93,33 +108,49 @@ class IndexController extends HomeBaseController @@ -93,33 +108,49 @@ class IndexController extends HomeBaseController
93 $this->assign('res_djxq',$res_djxq); 108 $this->assign('res_djxq',$res_djxq);
94 109
95 //星域秀场->明星访谈 110 //星域秀场->明星访谈
96 - $position = CityCategoryModel::mxft;  
97 - $field = 'id,full_name,position,trade,post_excerpt,thumbnail avatar';  
98 - $res_mxft = $this->getChildArticle($position,$field,1);  
99 - if($res_mxft){  
100 - $res_mxft = $res_mxft[0]; 111 + $res_mxft = cache('res_mxft');
  112 + if(!$res_mxft){
  113 + $position = CityCategoryModel::mxft;
  114 + $field = 'id,full_name,position,trade,post_excerpt,thumbnail avatar';
  115 + $res_mxft = $this->getChildArticle($position,$field,1);
  116 + if($res_mxft){
  117 + $res_mxft = $res_mxft[0];
  118 + }
  119 + cache('res_mxft',$res_mxft,86400);
101 } 120 }
102 $this->assign('res_mxft',$res_mxft); 121 $this->assign('res_mxft',$res_mxft);
103 122
104 123
105 //星域秀场->星域画廊 124 //星域秀场->星域画廊
106 - $position = CityCategoryModel::xyhl;  
107 - $field = 'id,thumbnail';  
108 - $res_xyhl = $this->getChildArticle($position,$field,16); 125 + $res_xyhl = cache('res_xyhl');
  126 + if(!$res_xyhl){
  127 + $position = CityCategoryModel::xyhl;
  128 + $field = 'id,thumbnail';
  129 + $res_xyhl = $this->getChildArticle($position,$field,16);
  130 + cache('res_xyhl',$res_xyhl,86400);
  131 + }
109 $this->assign('res_xyhl',$res_xyhl); 132 $this->assign('res_xyhl',$res_xyhl);
110 133
111 134
112 //星探推荐 135 //星探推荐
113 - $position = CityCategoryModel::xttj;  
114 - $field = 'id,post_title,price,index_thumbnail,place';  
115 - $res_xttj = $this->getParentArticle($position,$field,16); 136 + $res_xttj = cache('res_xttj');
  137 + if(!$res_xttj){
  138 + $position = CityCategoryModel::xttj;
  139 + $field = 'id,post_title,price,index_thumbnail,place';
  140 + $res_xttj = $this->getParentArticle($position,$field,16);
  141 + cache('res_xttj',$res_xttj,86400);
  142 + }
116 $this->assign('res_xttj',$res_xttj); 143 $this->assign('res_xttj',$res_xttj);
117 144
118 145
119 //星际活动 146 //星际活动
120 - $position = CityCategoryModel::xjhd;  
121 - $field = 'id,post_title,thumbnail';  
122 - $res_xjhd = $this->getParentArticle($position,$field,2); 147 + $res_xjhd = cache('res_xjhd');
  148 + if(!$res_xjhd){
  149 + $position = CityCategoryModel::xjhd;
  150 + $field = 'id,post_title,thumbnail';
  151 + $res_xjhd = $this->getParentArticle($position,$field,2);
  152 + cache('res_xjhd',$res_xjhd,86400);
  153 + }
123 $this->assign('res_xjhd',$res_xjhd); 154 $this->assign('res_xjhd',$res_xjhd);
124 return $this->fetch(); 155 return $this->fetch();
125 } 156 }
@@ -63,7 +63,7 @@ @@ -63,7 +63,7 @@
63 <div class="mask" id="mask"> 63 <div class="mask" id="mask">
64 <div class="mask_video" > 64 <div class="mask_video" >
65 <img id="nos" src="__TMPL__/public/assets/starImg/nos.png" alt=""> 65 <img id="nos" src="__TMPL__/public/assets/starImg/nos.png" alt="">
66 - <video autoplay="autoplay" controls id="video2" src="{:cmf_get_file_download_url($res_djxq.video)}" controlslist="nodownload"></video> 66 + <video muted autoplay="autoplay" id="video2" src="{:cmf_get_file_download_url($res_djxq.video)}" controlslist="nodownload"></video>
67 </div> 67 </div>
68 </div> 68 </div>
69 </notempty> 69 </notempty>
@@ -758,13 +758,15 @@ @@ -758,13 +758,15 @@
758 <div class="star_gall_img swiper-container"> 758 <div class="star_gall_img swiper-container">
759 <!-- 轮播图 --> 759 <!-- 轮播图 -->
760 <ul class="swiper-wrapper"> 760 <ul class="swiper-wrapper">
761 - <volist name="res_xyhl" id="vo">  
762 - <li class="swiper-slide">  
763 - <a href="/portal/region/getGalleryDetail?id={$vo.id}">  
764 - <img class="swiper-slide slide-image" src="{:cmf_get_image_url($vo.thumbnail)}" alt="">  
765 - </a>  
766 - </li>  
767 - </volist> 761 + <notempty name="res_xyhl">
  762 + <volist name="res_xyhl" id="vo">
  763 + <li class="swiper-slide">
  764 + <a href="/portal/region/getGalleryDetail?id={$vo.id}">
  765 + <img class="swiper-slide slide-image" src="{:cmf_get_image_url($vo.thumbnail)}" alt="">
  766 + </a>
  767 + </li>
  768 + </volist>
  769 + </notempty>
768 </ul> 770 </ul>
769 <!-- 左右按钮 --> 771 <!-- 左右按钮 -->
770 <div class="swiper-button-next"> 772 <div class="swiper-button-next">
@@ -794,23 +796,25 @@ @@ -794,23 +796,25 @@
794 <div class="star_gall_img swiper-container2"> 796 <div class="star_gall_img swiper-container2">
795 <!-- 轮播图 --> 797 <!-- 轮播图 -->
796 <ul class="swiper-wrapper"> 798 <ul class="swiper-wrapper">
797 - <volist name="res_xttj" id="vo">  
798 - <li class="swiper-slide scout_box">  
799 - <div class="scout_image">  
800 - <img src="{:cmf_get_image_url($vo.index_thumbnail)}" alt="">  
801 - </div>  
802 - <empty name="vo.place">  
803 - <a href="/portal/scout/getSceneryDetail?id={$vo.id}">  
804 - <else />  
805 - <a href="/portal/scout/getTravelDetail?id={$vo.id}">  
806 - </empty>  
807 - <h1>  
808 - {$vo.post_title}  
809 - </h1>  
810 - <p>¥{$vo.price}</p>  
811 - </a>  
812 - </li>  
813 - </volist> 799 + <notempty name="res_xttj">
  800 + <volist name="res_xttj" id="vo">
  801 + <li class="swiper-slide scout_box">
  802 + <div class="scout_image">
  803 + <img src="{:cmf_get_image_url($vo.index_thumbnail)}" alt="">
  804 + </div>
  805 + <empty name="vo.place">
  806 + <a href="/portal/scout/getSceneryDetail?id={$vo.id}">
  807 + <else />
  808 + <a href="/portal/scout/getTravelDetail?id={$vo.id}">
  809 + </empty>
  810 + <h1>
  811 + {$vo.post_title}
  812 + </h1>
  813 + <p>¥{$vo.price}</p>
  814 + </a>
  815 + </li>
  816 + </volist>
  817 + </notempty>
814 </ul> 818 </ul>
815 <!-- 左右按钮 --> 819 <!-- 左右按钮 -->
816 <div class="swiper-button-next2"> 820 <div class="swiper-button-next2">
@@ -858,14 +862,8 @@ @@ -858,14 +862,8 @@
858 <script> 862 <script>
859 // 弹框视频 863 // 弹框视频
860 $('.mask').css('display','block'); 864 $('.mask').css('display','block');
861 -// var video2 = document.getElementById("video2"); //获取ID   
862 -// console.log(video2);  
863 -// $(function() {  
864 -// if (video2.paused) { //判读是否播放      
865 -// // video2.paused = false;              
866 -// video2.play(); //没有就播放        
867 -// }  
868 -// }); 865 +
  866 + var video2 = document.getElementById("video2"); //获取ID 
869 var nos = document.getElementById("nos"); 867 var nos = document.getElementById("nos");
870 var mask = document.getElementById("mask"); 868 var mask = document.getElementById("mask");
871 869
@@ -55,9 +55,9 @@ @@ -55,9 +55,9 @@
55 <!-- banner视频 --> 55 <!-- banner视频 -->
56 <div class="show_index_banner"> 56 <div class="show_index_banner">
57 <notempty name="res_xqyy"> 57 <notempty name="res_xqyy">
58 - <video id="video" autoplay="autoplay" controls width="100%" height="660" src="{:cmf_get_file_download_url($res_xqyy.video)}" controlsList="nodownload"></video> 58 + <video id="video" muted autoplay="autoplay" controls width="100%" height="660" src="{:cmf_get_file_download_url($res_xqyy.video)}" controlsList="nodownload"></video>
59 <else/> 59 <else/>
60 - <video id="video" autoplay="autoplay" controls width="100%" height="660" src="__TMPL__/public/assets/starImg/video.mp4" controlsList="nodownload"></video> 60 + <video id="video" muted autoplay="autoplay" controls width="100%" height="660" src="__TMPL__/public/assets/starImg/video.mp4" controlsList="nodownload"></video>
61 </notempty> 61 </notempty>
62 <!-- poster="__TMPL__/public/assets/starImg/aicon_01.png" --> 62 <!-- poster="__TMPL__/public/assets/starImg/aicon_01.png" -->
63 <!-- <img onclick="bofang()" class="show_in_banner2" src="__TMPL__/public/assets/starImg/aicon_30.png" alt=""> --> 63 <!-- <img onclick="bofang()" class="show_in_banner2" src="__TMPL__/public/assets/starImg/aicon_30.png" alt=""> -->